Spaces:
Runtime error
Runtime error
Julien Ajdenbaum
commited on
Commit
•
a1c3c86
1
Parent(s):
a76b709
first commit
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .idea/.gitignore +8 -0
- .idea/HairLossPredictionDemo.iml +11 -0
- .idea/inspectionProfiles/Project_Default.xml +7 -0
- .idea/inspectionProfiles/profiles_settings.xml +6 -0
- .idea/misc.xml +7 -0
- .idea/modules.xml +8 -0
- .idea/vcs.xml +6 -0
- app.py +81 -0
- requirements.txt +4 -0
- results.png +0 -0
- tmp/124.png +0 -0
- tmp/1293.png +0 -0
- tmp/1532.png +0 -0
- tmp/1638.png +0 -0
- tmp/1742.png +0 -0
- tmp/1770.png +0 -0
- tmp/1896.png +0 -0
- tmp/2003.png +0 -0
- tmp/2390.png +0 -0
- tmp/252.png +0 -0
- tmp/2640.png +0 -0
- tmp/2755.png +0 -0
- tmp/2786.png +0 -0
- tmp/2945.png +0 -0
- tmp/337.png +0 -0
- tmp/3394.png +0 -0
- tmp/3676.png +0 -0
- tmp/3725.png +0 -0
- tmp/3743.png +0 -0
- tmp/4124.png +0 -0
- tmp/4181.png +0 -0
- tmp/4412.png +0 -0
- tmp/4514.png +0 -0
- tmp/4531.png +0 -0
- tmp/4672.png +0 -0
- tmp/468.png +0 -0
- tmp/4851.png +0 -0
- tmp/4986.png +0 -0
- tmp/5650.png +0 -0
- tmp/599.png +0 -0
- tmp/6030.png +0 -0
- tmp/6060.png +0 -0
- tmp/6173.png +0 -0
- tmp/6176.png +0 -0
- tmp/6729.png +0 -0
- tmp/7318.png +0 -0
- tmp/746.png +0 -0
- tmp/7759.png +0 -0
- tmp/7808.png +0 -0
- tmp/7996.png +0 -0
.idea/.gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
4 |
+
# Editor-based HTTP Client requests
|
5 |
+
/httpRequests/
|
6 |
+
# Datasource local storage ignored files
|
7 |
+
/dataSources/
|
8 |
+
/dataSources.local.xml
|
.idea/HairLossPredictionDemo.iml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<module type="PYTHON_MODULE" version="4">
|
3 |
+
<component name="NewModuleRootManager">
|
4 |
+
<content url="file://$MODULE_DIR$" />
|
5 |
+
<orderEntry type="inheritedJdk" />
|
6 |
+
<orderEntry type="sourceFolder" forTests="false" />
|
7 |
+
</component>
|
8 |
+
<component name="PackageRequirementsSettings">
|
9 |
+
<option name="versionSpecifier" value="Don't specify version" />
|
10 |
+
</component>
|
11 |
+
</module>
|
.idea/inspectionProfiles/Project_Default.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<profile version="1.0">
|
3 |
+
<option name="myName" value="Project Default" />
|
4 |
+
<inspection_tool class="GrazieInspection" enabled="false" level="GRAMMAR_ERROR" enabled_by_default="false" />
|
5 |
+
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
6 |
+
</profile>
|
7 |
+
</component>
|
.idea/inspectionProfiles/profiles_settings.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<component name="InspectionProjectProfileManager">
|
2 |
+
<settings>
|
3 |
+
<option name="USE_PROJECT_PROFILE" value="false" />
|
4 |
+
<version value="1.0" />
|
5 |
+
</settings>
|
6 |
+
</component>
|
.idea/misc.xml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="Black">
|
4 |
+
<option name="sdkName" value="$USER_HOME$/anaconda3" />
|
5 |
+
</component>
|
6 |
+
<component name="ProjectRootManager" version="2" project-jdk-name="$USER_HOME$/anaconda3" project-jdk-type="Python SDK" />
|
7 |
+
</project>
|
.idea/modules.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="ProjectModuleManager">
|
4 |
+
<modules>
|
5 |
+
<module fileurl="file://$PROJECT_DIR$/.idea/HairLossPredictionDemo.iml" filepath="$PROJECT_DIR$/.idea/HairLossPredictionDemo.iml" />
|
6 |
+
</modules>
|
7 |
+
</component>
|
8 |
+
</project>
|
.idea/vcs.xml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<project version="4">
|
3 |
+
<component name="VcsDirectoryMappings">
|
4 |
+
<mapping directory="" vcs="Git" />
|
5 |
+
</component>
|
6 |
+
</project>
|
app.py
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import math
|
3 |
+
import numpy as np
|
4 |
+
import os
|
5 |
+
import matplotlib.pyplot as plt
|
6 |
+
import random
|
7 |
+
from skimage import io as skio
|
8 |
+
|
9 |
+
def evolution_plot(current_age):
|
10 |
+
n = 10000
|
11 |
+
maxi = 100
|
12 |
+
x = np.linspace(0, maxi, 10000)
|
13 |
+
max_state = 7
|
14 |
+
final_state = 5
|
15 |
+
y = 1 / (1 + np.exp(-(x / 8) + 5))
|
16 |
+
y = (y - np.min(y)) / (np.max(y - np.min(y))) * (final_state - 1) + 1
|
17 |
+
plt.title("Hair Loss Evolution Prediction")
|
18 |
+
plt.xlabel("Age")
|
19 |
+
plt.ylabel("Nordwood State")
|
20 |
+
plt.ylim(1, max_state)
|
21 |
+
actual = np.where(x < int(current_age))[0][-1]
|
22 |
+
plt.plot(x[:actual], y[:actual])
|
23 |
+
plt.plot(x[actual:], y[actual:], '--')
|
24 |
+
im_save_path = f'tmp/{random.randint(0, 10000)}.png'
|
25 |
+
plt.savefig(im_save_path)
|
26 |
+
plt.clf()
|
27 |
+
plot = skio.imread(im_save_path)
|
28 |
+
return plot
|
29 |
+
|
30 |
+
def pad(arr):
|
31 |
+
arr = list(map(str, arr))
|
32 |
+
max_len = 0
|
33 |
+
for i in arr:
|
34 |
+
if len(i)>max_len:
|
35 |
+
max_len = len(i)
|
36 |
+
for i in range(len(arr)):
|
37 |
+
for j in range(max_len-len(arr[i])):
|
38 |
+
arr[i] = arr[i] + " "
|
39 |
+
return arr
|
40 |
+
|
41 |
+
def predict(file, age, parent, gp):
|
42 |
+
product = ['Computer', 'Monitor ', 'Laptop ', 'Printer ', 'Tablet ']
|
43 |
+
quantity = pad(np.array([320, 450, 300, 120, 280]) / 500)
|
44 |
+
min_normal = pad(np.array([250, 200, 210, 100, 250]) / 500)
|
45 |
+
max_normal = pad(np.array([400, 300, 450, 150, 300]) / 500)
|
46 |
+
txt = 'Bacteria\t\t\t\t\t\tMin\t\t\tMax\n\n'
|
47 |
+
for i in range(len(product)):
|
48 |
+
txt += product[i]
|
49 |
+
txt += "\t\t\t"
|
50 |
+
txt += quantity[i] + "\t\t" + min_normal[i] + "\t\t" + max_normal[i] + "\t"
|
51 |
+
txt += '\n'
|
52 |
+
txt = str(txt)
|
53 |
+
|
54 |
+
useful_products = ("Hydrating Shampoo : https://www.google.com\n"
|
55 |
+
"Light Hat : https://www.google.com")
|
56 |
+
return skio.imread("results.png"), 'Dermatitis\nDryness\nDandruff', evolution_plot(age), useful_products
|
57 |
+
# GUI
|
58 |
+
title = 'Hair loss prediction'
|
59 |
+
description = 'Metagenomics Scalp Analysis for Hair Loss Prediction'
|
60 |
+
# examples = [[f'examples/{name}', 3] for name in sorted(os.listdir('examples'))]
|
61 |
+
|
62 |
+
iface = gr.Interface(
|
63 |
+
fn=predict,
|
64 |
+
inputs=[
|
65 |
+
gr.File(type='file', label='Scalp sample'),
|
66 |
+
gr.Textbox(label='Age'),
|
67 |
+
gr.CheckboxGroup(choices=["Yes", "No", "Do not know"], label="Has the father experienced hair loss ?"),
|
68 |
+
gr.CheckboxGroup(choices=["0", "1", "2", "Do not know"], label="How many grand-parents have experienced hair loss ?")
|
69 |
+
],
|
70 |
+
outputs=[
|
71 |
+
gr.Image(label='Scalp Metagenomics Analysis Results'),
|
72 |
+
gr.Text(label='Current issues :'),
|
73 |
+
gr.Image(label='Future Evolution'),
|
74 |
+
gr.Text(label='Useful Care Products')
|
75 |
+
],
|
76 |
+
allow_flagging='never',
|
77 |
+
cache_examples=False,
|
78 |
+
title=title,
|
79 |
+
description=description
|
80 |
+
)
|
81 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
numpy
|
3 |
+
matplotlib
|
4 |
+
scikit-image
|
results.png
ADDED
tmp/124.png
ADDED
tmp/1293.png
ADDED
tmp/1532.png
ADDED
tmp/1638.png
ADDED
tmp/1742.png
ADDED
tmp/1770.png
ADDED
tmp/1896.png
ADDED
tmp/2003.png
ADDED
tmp/2390.png
ADDED
tmp/252.png
ADDED
tmp/2640.png
ADDED
tmp/2755.png
ADDED
tmp/2786.png
ADDED
tmp/2945.png
ADDED
tmp/337.png
ADDED
tmp/3394.png
ADDED
tmp/3676.png
ADDED
tmp/3725.png
ADDED
tmp/3743.png
ADDED
tmp/4124.png
ADDED
tmp/4181.png
ADDED
tmp/4412.png
ADDED
tmp/4514.png
ADDED
tmp/4531.png
ADDED
tmp/4672.png
ADDED
tmp/468.png
ADDED
tmp/4851.png
ADDED
tmp/4986.png
ADDED
tmp/5650.png
ADDED
tmp/599.png
ADDED
tmp/6030.png
ADDED
tmp/6060.png
ADDED
tmp/6173.png
ADDED
tmp/6176.png
ADDED
tmp/6729.png
ADDED
tmp/7318.png
ADDED
tmp/746.png
ADDED
tmp/7759.png
ADDED
tmp/7808.png
ADDED
tmp/7996.png
ADDED