Spaces:
Runtime error
Runtime error
jeanpoll
commited on
Commit
•
eee8e74
1
Parent(s):
ecf78d4
initial commit
Browse files- .gitattributes +1 -1
- .gitignore +147 -0
- README.md +4 -4
- app.py +91 -0
- examples/ISIC_0025402.jpg +0 -0
- examples/PXL_20221103_153018529.jpg +0 -0
- examples/PXL_20221103_153129579.jpg +0 -0
- examples/PXL_20221103_153137616.jpg +0 -0
- examples/PXL_20221103_153217034.jpg +0 -0
- examples/PXL_20221103_153256612.jpg +0 -0
- examples/Thumbs.db +0 -0
- examples/not used/ISIC_0024362.jpg +0 -0
- examples/not used/ISIC_0024385.jpg +0 -0
- examples/not used/ISIC_0024392.jpg +0 -0
- examples/not used/ISIC_0024422.jpg +0 -0
- examples/not used/ISIC_0024457.jpg +0 -0
- examples/not used/ISIC_0024478.jpg +0 -0
- examples/not used/ISIC_0024655.jpg +0 -0
- examples/not used/ISIC_0025120.jpg +0 -0
- examples/not used/ISIC_0025897.jpg +0 -0
- examples/not used/ISIC_0027316.jpg +0 -0
- examples/not used/ISIC_0027455.jpg +0 -0
- examples/not used/ISIC_0027654.jpg +0 -0
- examples/not used/ISIC_0027779.jpg +0 -0
- examples/not used/ISIC_0029452.jpg +0 -0
- examples/not used/ISIC_0029535.jpg +0 -0
- examples/not used/mel/1.jpg +0 -0
- examples/not used/mel/2.jpg +0 -0
- examples/not used/mel/3.jpg +0 -0
- examples/not used/mel/4.jpeg +0 -0
- examples/not used/mel/5.jpeg +0 -0
- examples/not used/mel/6.jpeg +0 -0
- examples/not used/mel/Thumbs.db +0 -0
- examples/not used/nv/1.jpg +0 -0
- examples/not used/nv/2.jpg +0 -0
- examples/not used/nv/Thumbs.db +0 -0
- mole_39_dev.yml +218 -0
- mole_models/ed52a28a7b504ff7ba851c850221d1dd/MLmodel +13 -0
- mole_models/ed52a28a7b504ff7ba851c850221d1dd/conda.yaml +9 -0
- mole_models/ed52a28a7b504ff7ba851c850221d1dd/model.fastai +3 -0
- mole_models/ed52a28a7b504ff7ba851c850221d1dd/python_env.yaml +7 -0
- mole_models/ed52a28a7b504ff7ba851c850221d1dd/requirements.txt +2 -0
- mole_models/pipeline.rf_classifier_mole +0 -0
- requirements.txt +9 -0
- useful_functions.py +71 -0
.gitattributes
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
@@ -32,3 +31,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
2 |
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
|
|
5 |
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
*.h5 filter=lfs diff=lfs merge=lfs -text
|
|
|
31 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
32 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
33 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
34 |
+
*.fastai filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Byte-compiled / optimized / DLL files
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
|
6 |
+
# C extensions
|
7 |
+
*.so
|
8 |
+
|
9 |
+
# Distribution / packaging
|
10 |
+
.Python
|
11 |
+
build/
|
12 |
+
develop-eggs/
|
13 |
+
dist/
|
14 |
+
downloads/
|
15 |
+
eggs/
|
16 |
+
.eggs/
|
17 |
+
lib/
|
18 |
+
lib64/
|
19 |
+
parts/
|
20 |
+
sdist/
|
21 |
+
var/
|
22 |
+
wheels/
|
23 |
+
share/python-wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
MANIFEST
|
28 |
+
|
29 |
+
# PyInstaller
|
30 |
+
# Usually these files are written by a python script from a template
|
31 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
+
*.manifest
|
33 |
+
*.spec
|
34 |
+
|
35 |
+
# Installer logs
|
36 |
+
pip-log.txt
|
37 |
+
pip-delete-this-directory.txt
|
38 |
+
|
39 |
+
# Unit test / coverage reports
|
40 |
+
htmlcov/
|
41 |
+
.tox/
|
42 |
+
.nox/
|
43 |
+
.coverage
|
44 |
+
.coverage.*
|
45 |
+
.cache
|
46 |
+
nosetests.xml
|
47 |
+
coverage.xml
|
48 |
+
*.cover
|
49 |
+
*.py,cover
|
50 |
+
.hypothesis/
|
51 |
+
.pytest_cache/
|
52 |
+
cover/
|
53 |
+
|
54 |
+
# Translations
|
55 |
+
*.mo
|
56 |
+
*.pot
|
57 |
+
|
58 |
+
# Django stuff:
|
59 |
+
*.log
|
60 |
+
local_settings.py
|
61 |
+
db.sqlite3
|
62 |
+
db.sqlite3-journal
|
63 |
+
|
64 |
+
# Flask stuff:
|
65 |
+
instance/
|
66 |
+
.webassets-cache
|
67 |
+
|
68 |
+
# Scrapy stuff:
|
69 |
+
.scrapy
|
70 |
+
|
71 |
+
# Sphinx documentation
|
72 |
+
docs/_build/
|
73 |
+
|
74 |
+
# PyBuilder
|
75 |
+
.pybuilder/
|
76 |
+
target/
|
77 |
+
|
78 |
+
# Jupyter Notebook
|
79 |
+
.ipynb_checkpoints
|
80 |
+
|
81 |
+
# IPython
|
82 |
+
profile_default/
|
83 |
+
ipython_config.py
|
84 |
+
|
85 |
+
# pyenv
|
86 |
+
# For a library or package, you might want to ignore these files since the code is
|
87 |
+
# intended to run in multiple environments; otherwise, check them in:
|
88 |
+
# .python-version
|
89 |
+
|
90 |
+
# pipenv
|
91 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
+
# install all needed dependencies.
|
95 |
+
#Pipfile.lock
|
96 |
+
|
97 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
98 |
+
__pypackages__/
|
99 |
+
|
100 |
+
# Celery stuff
|
101 |
+
celerybeat-schedule
|
102 |
+
celerybeat.pid
|
103 |
+
|
104 |
+
# SageMath parsed files
|
105 |
+
*.sage.py
|
106 |
+
|
107 |
+
# Environments
|
108 |
+
.env
|
109 |
+
.venv
|
110 |
+
env/
|
111 |
+
venv/
|
112 |
+
ENV/
|
113 |
+
env.bak/
|
114 |
+
venv.bak/
|
115 |
+
|
116 |
+
# Pycharm
|
117 |
+
.idea/
|
118 |
+
|
119 |
+
# Spyder project settings
|
120 |
+
.spyderproject
|
121 |
+
.spyproject
|
122 |
+
|
123 |
+
# Rope project settings
|
124 |
+
.ropeproject
|
125 |
+
|
126 |
+
# mkdocs documentation
|
127 |
+
/site
|
128 |
+
|
129 |
+
# mypy
|
130 |
+
.mypy_cache/
|
131 |
+
.dmypy.json
|
132 |
+
dmypy.json
|
133 |
+
|
134 |
+
# Pyre type checker
|
135 |
+
.pyre/
|
136 |
+
|
137 |
+
# pytype static type analyzer
|
138 |
+
.pytype/
|
139 |
+
|
140 |
+
# Cython debug symbols
|
141 |
+
cython_debug/
|
142 |
+
|
143 |
+
# additionnals stuff
|
144 |
+
logs/
|
145 |
+
notebooks/
|
146 |
+
mlruns/
|
147 |
+
flagged/
|
README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
---
|
2 |
title: Mole Analyzer
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
1 |
---
|
2 |
title: Mole Analyzer
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.8.2
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
app.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
from useful_functions import *
|
5 |
+
import useful_functions
|
6 |
+
|
7 |
+
f_load_cancer_classifier()
|
8 |
+
f_load_cnn_model()
|
9 |
+
|
10 |
+
HF_TOKEN = os.getenv('HF_TOKEN')
|
11 |
+
hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "mole-dataset", private=True)
|
12 |
+
|
13 |
+
|
14 |
+
def image_classifier(file_path, age, sex, localization):
|
15 |
+
if age == 0:
|
16 |
+
age = 40
|
17 |
+
if sex == "":
|
18 |
+
sex = "unknown"
|
19 |
+
if localization == "":
|
20 |
+
localization = "unknown"
|
21 |
+
|
22 |
+
# file_path = file_path if file_path is not None else file_path_webcam
|
23 |
+
|
24 |
+
preds = f_predict_cnn_with_tta(file_path)
|
25 |
+
label = f_predict_cancer(preds, age, sex, localization)
|
26 |
+
return (dict(zip(useful_functions.lesion_model.dls.vocab, preds)),
|
27 |
+
label)
|
28 |
+
|
29 |
+
input_img = gr.Image(tool="editor", type="filepath", source="upload")
|
30 |
+
# input_webcam = gr.Image(tool="editor", type="filepath", source="webcam")
|
31 |
+
|
32 |
+
input_age = gr.Number(label="age (optionnel)")
|
33 |
+
input_sex = gr.Dropdown(label="sex (optionnel)", choices=["male", "female"])
|
34 |
+
input_localization = gr.Dropdown(label="localization (optionnel)", choices=["abdomen", "back", "chest", "ear",
|
35 |
+
"face", "foot", "genital", "hand",
|
36 |
+
"lower extremity", "neck", "scalp", "trunk", "upper extremity"])
|
37 |
+
|
38 |
+
output_lesion = gr.Label(label="Lesion detected")
|
39 |
+
output_malign = gr.Label(label="Classification")
|
40 |
+
|
41 |
+
list_files_examples = os.listdir("examples")
|
42 |
+
# examples = [[os.path.join("examples", file), 0, "", ""] for file in list_files_examples if file.endswith("jpg")]
|
43 |
+
examples = []
|
44 |
+
examples.append([os.path.join("examples", "PXL_20221103_153018529.jpg"), 40, "female", "back"])
|
45 |
+
examples.append([os.path.join("examples", "PXL_20221103_153129579.jpg"), 40, "male", "neck"])
|
46 |
+
examples.append([os.path.join("examples", "PXL_20221103_153137616.jpg"), 40, "male", "neck"])
|
47 |
+
examples.append([os.path.join("examples", "PXL_20221103_153217034.jpg"), 40, "male", "back"])
|
48 |
+
examples.append([os.path.join("examples", "PXL_20221103_153256612.jpg"), 40, "male", "upper extremity"])
|
49 |
+
examples.append([os.path.join("examples", "ISIC_0025402.jpg"), 70, "male", "lower extremity"])
|
50 |
+
|
51 |
+
|
52 |
+
demo = gr.Interface(title="Skin mole analyzer",
|
53 |
+
description=r"""This is a side project I have been working on to practice working with images.
|
54 |
+
The purpose is to classify skin lesions (Based on kaggle dataset Skin Cancer MNIST: HAM10000).
|
55 |
+
The framework used is FastAI/pytorch and the model used is a pre-trained cnn (resnet152).
|
56 |
+
I added an extra layer to use age, sex, localization and output of resnet152 to classify the lesion
|
57 |
+
as suspicious or not (randomForest model).
|
58 |
+
The lesions detected are the following:
|
59 |
+
<ul>
|
60 |
+
<li>Actinic keratoses and intraepithelial carcinoma / Bowen's disease (akiec)</li>
|
61 |
+
<li>basal cell carcinoma (bcc)</li>
|
62 |
+
<li>benign keratosis-like lesions (bkl)</li>
|
63 |
+
<li>dermatofibroma (df)</li>
|
64 |
+
<li>melanoma (mel)</li>
|
65 |
+
<li>melanocytic nevi (nv)</li>
|
66 |
+
<li>vascular lesions (vasc)</li>
|
67 |
+
</ul>
|
68 |
+
<b> This is in no case intended as a medical advice, just a pedagogical exercise.</b> <br />
|
69 |
+
<i>*Pictures should be relatively well centered on the mole to obtain the best results (cf examples).
|
70 |
+
You can use the tools available in the right corner to crop optimally.</i>
|
71 |
+
""",
|
72 |
+
article="""[1] Noel Codella, Veronica Rotemberg, Philipp Tschandl, M. Emre Celebi, Stephen Dusza, David Gutman,
|
73 |
+
Brian Helba, Aadi Kalloo, Konstantinos Liopyris, Michael Marchetti, Harald Kittler, Allan Halpern:
|
74 |
+
"Skin Lesion Analysis Toward Melanoma Detection 2018: A Challenge Hosted by the International Skin Imaging Collaboration (ISIC)",
|
75 |
+
2018;"<a href="https://arxiv.org/abs/1902.03368">"https://arxiv.org/abs/1902.03368"</a><br />
|
76 |
+
[2] Tschandl, P., Rosendahl, C. & Kittler, H. The HAM10000 dataset, a large collection of multi-source dermatoscopic
|
77 |
+
images of common pigmented skin lesions. Sci. Data 5, 180161 doi:10.1038/sdata.2018.161 (2018).""",
|
78 |
+
fn=image_classifier,
|
79 |
+
inputs= [input_img,
|
80 |
+
input_age,
|
81 |
+
input_sex,
|
82 |
+
input_localization],
|
83 |
+
outputs=[output_lesion,
|
84 |
+
output_malign],
|
85 |
+
examples=examples,
|
86 |
+
allow_flagging="auto",
|
87 |
+
flagging_options=list(useful_functions.lesion_model.dls.vocab) + ["other"],
|
88 |
+
flagging_callback=hf_writer
|
89 |
+
)
|
90 |
+
|
91 |
+
demo.launch()
|
examples/ISIC_0025402.jpg
ADDED
examples/PXL_20221103_153018529.jpg
ADDED
examples/PXL_20221103_153129579.jpg
ADDED
examples/PXL_20221103_153137616.jpg
ADDED
examples/PXL_20221103_153217034.jpg
ADDED
examples/PXL_20221103_153256612.jpg
ADDED
examples/Thumbs.db
ADDED
Binary file (204 kB). View file
|
|
examples/not used/ISIC_0024362.jpg
ADDED
examples/not used/ISIC_0024385.jpg
ADDED
examples/not used/ISIC_0024392.jpg
ADDED
examples/not used/ISIC_0024422.jpg
ADDED
examples/not used/ISIC_0024457.jpg
ADDED
examples/not used/ISIC_0024478.jpg
ADDED
examples/not used/ISIC_0024655.jpg
ADDED
examples/not used/ISIC_0025120.jpg
ADDED
examples/not used/ISIC_0025897.jpg
ADDED
examples/not used/ISIC_0027316.jpg
ADDED
examples/not used/ISIC_0027455.jpg
ADDED
examples/not used/ISIC_0027654.jpg
ADDED
examples/not used/ISIC_0027779.jpg
ADDED
examples/not used/ISIC_0029452.jpg
ADDED
examples/not used/ISIC_0029535.jpg
ADDED
examples/not used/mel/1.jpg
ADDED
examples/not used/mel/2.jpg
ADDED
examples/not used/mel/3.jpg
ADDED
examples/not used/mel/4.jpeg
ADDED
examples/not used/mel/5.jpeg
ADDED
examples/not used/mel/6.jpeg
ADDED
examples/not used/mel/Thumbs.db
ADDED
Binary file (52.2 kB). View file
|
|
examples/not used/nv/1.jpg
ADDED
examples/not used/nv/2.jpg
ADDED
examples/not used/nv/Thumbs.db
ADDED
Binary file (24.6 kB). View file
|
|
mole_39_dev.yml
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: mole_39_dev
|
2 |
+
channels:
|
3 |
+
- pytorch
|
4 |
+
- conda-forge
|
5 |
+
- defaults
|
6 |
+
dependencies:
|
7 |
+
- anyio=3.5.0=py39haa95532_0
|
8 |
+
- argon2-cffi=21.3.0=pyhd3eb1b0_0
|
9 |
+
- argon2-cffi-bindings=21.2.0=py39h2bbff1b_0
|
10 |
+
- asttokens=2.0.5=pyhd3eb1b0_0
|
11 |
+
- attrs=21.4.0=pyhd3eb1b0_0
|
12 |
+
- babel=2.9.1=pyhd3eb1b0_0
|
13 |
+
- backcall=0.2.0=pyhd3eb1b0_0
|
14 |
+
- beautifulsoup4=4.11.1=py39haa95532_0
|
15 |
+
- blas=2.116=mkl
|
16 |
+
- blas-devel=3.9.0=16_win64_mkl
|
17 |
+
- bleach=4.1.0=pyhd3eb1b0_0
|
18 |
+
- brotlipy=0.7.0=py39h2bbff1b_1003
|
19 |
+
- ca-certificates=2022.6.15.1=h5b45459_0
|
20 |
+
- certifi=2022.6.15.1=pyhd8ed1ab_0
|
21 |
+
- cffi=1.15.1=py39h2bbff1b_0
|
22 |
+
- charset-normalizer=2.0.4=pyhd3eb1b0_0
|
23 |
+
- colorama=0.4.5=py39haa95532_0
|
24 |
+
- cryptography=2.9.2=py39hcd4344a_0
|
25 |
+
- cudatoolkit=11.6.0=hc0ea762_10
|
26 |
+
- debugpy=1.5.1=py39hd77b12b_0
|
27 |
+
- decorator=5.1.1=pyhd3eb1b0_0
|
28 |
+
- defusedxml=0.7.1=pyhd3eb1b0_0
|
29 |
+
- entrypoints=0.4=py39haa95532_0
|
30 |
+
- executing=0.8.3=pyhd3eb1b0_0
|
31 |
+
- freetype=2.10.4=h546665d_1
|
32 |
+
- glib=2.69.1=h5dc1a3c_1
|
33 |
+
- gst-plugins-base=1.18.5=h9e645db_0
|
34 |
+
- gstreamer=1.18.5=hd78058f_0
|
35 |
+
- icu=58.2=ha925a31_3
|
36 |
+
- idna=3.3=pyhd3eb1b0_0
|
37 |
+
- intel-openmp=2022.1.0=h57928b3_3787
|
38 |
+
- ipykernel=6.15.2=py39haa95532_0
|
39 |
+
- ipython=8.4.0=py39haa95532_0
|
40 |
+
- ipython_genutils=0.2.0=pyhd3eb1b0_1
|
41 |
+
- ipywidgets=7.6.5=pyhd3eb1b0_1
|
42 |
+
- jedi=0.18.1=py39haa95532_1
|
43 |
+
- jinja2=3.0.3=pyhd3eb1b0_0
|
44 |
+
- jpeg=9e=h2bbff1b_0
|
45 |
+
- json5=0.9.6=pyhd3eb1b0_0
|
46 |
+
- jsonschema=4.4.0=py39haa95532_0
|
47 |
+
- jupyter=1.0.0=py39haa95532_8
|
48 |
+
- jupyter_client=7.3.5=py39haa95532_0
|
49 |
+
- jupyter_console=6.4.3=pyhd3eb1b0_0
|
50 |
+
- jupyter_core=4.10.0=py39haa95532_0
|
51 |
+
- jupyter_server=1.18.1=py39haa95532_0
|
52 |
+
- jupyterlab=3.4.4=py39haa95532_0
|
53 |
+
- jupyterlab_pygments=0.1.2=py_0
|
54 |
+
- jupyterlab_server=2.12.0=py39haa95532_0
|
55 |
+
- jupyterlab_widgets=1.0.0=pyhd3eb1b0_1
|
56 |
+
- lcms2=2.12=h2a16943_0
|
57 |
+
- libblas=3.9.0=16_win64_mkl
|
58 |
+
- libcblas=3.9.0=16_win64_mkl
|
59 |
+
- libclang=12.0.0=default_h627e005_2
|
60 |
+
- libffi=3.4.2=hd77b12b_4
|
61 |
+
- libiconv=1.16=h2bbff1b_2
|
62 |
+
- liblapack=3.9.0=16_win64_mkl
|
63 |
+
- liblapacke=3.9.0=16_win64_mkl
|
64 |
+
- libogg=1.3.5=h2bbff1b_1
|
65 |
+
- libpng=1.6.37=h2a8f88b_0
|
66 |
+
- libsodium=1.0.18=h62dcd97_0
|
67 |
+
- libtiff=4.2.0=h0c97f57_3
|
68 |
+
- libuv=1.44.2=h8ffe710_0
|
69 |
+
- libvorbis=1.3.7=he774522_0
|
70 |
+
- libwebp=1.2.2=h2bbff1b_0
|
71 |
+
- libxml2=2.9.14=h0ad7f3c_0
|
72 |
+
- libxslt=1.1.35=h2bbff1b_0
|
73 |
+
- lz4-c=1.9.3=h2bbff1b_1
|
74 |
+
- m2w64-gcc-libgfortran=5.3.0=6
|
75 |
+
- m2w64-gcc-libs=5.3.0=7
|
76 |
+
- m2w64-gcc-libs-core=5.3.0=7
|
77 |
+
- m2w64-gmp=6.1.0=2
|
78 |
+
- m2w64-libwinpthread-git=5.0.0.4634.697f757=2
|
79 |
+
- markupsafe=2.1.1=py39h2bbff1b_0
|
80 |
+
- matplotlib-inline=0.1.6=py39haa95532_0
|
81 |
+
- mistune=0.8.4=py39h2bbff1b_1000
|
82 |
+
- mkl=2022.1.0=h6a75c08_874
|
83 |
+
- mkl-devel=2022.1.0=h57928b3_875
|
84 |
+
- mkl-include=2022.1.0=h6a75c08_874
|
85 |
+
- msys2-conda-epoch=20160418=1
|
86 |
+
- nbclassic=0.3.5=pyhd3eb1b0_0
|
87 |
+
- nbclient=0.5.13=py39haa95532_0
|
88 |
+
- nbconvert=6.4.4=py39haa95532_0
|
89 |
+
- nbformat=5.3.0=py39haa95532_0
|
90 |
+
- nest-asyncio=1.5.5=py39haa95532_0
|
91 |
+
- notebook=6.4.12=py39haa95532_0
|
92 |
+
- numpy=1.23.2=py39h1a62c8c_0
|
93 |
+
- olefile=0.46=pyh9f0ad1d_1
|
94 |
+
- openjpeg=2.4.0=hb211442_1
|
95 |
+
- openssl=1.1.1q=h8ffe710_0
|
96 |
+
- packaging=21.3=pyhd3eb1b0_0
|
97 |
+
- pandocfilters=1.5.0=pyhd3eb1b0_0
|
98 |
+
- parso=0.8.3=pyhd3eb1b0_0
|
99 |
+
- pcre=8.45=hd77b12b_0
|
100 |
+
- pickleshare=0.7.5=pyhd3eb1b0_1003
|
101 |
+
- pillow=8.2.0=py39h1a9d4f7_1
|
102 |
+
- pip=22.1.2=py39haa95532_0
|
103 |
+
- ply=3.11=py39haa95532_0
|
104 |
+
- prometheus_client=0.14.1=py39haa95532_0
|
105 |
+
- prompt-toolkit=3.0.20=pyhd3eb1b0_0
|
106 |
+
- prompt_toolkit=3.0.20=hd3eb1b0_0
|
107 |
+
- psutil=5.9.0=py39h2bbff1b_0
|
108 |
+
- pure_eval=0.2.2=pyhd3eb1b0_0
|
109 |
+
- pycparser=2.21=pyhd3eb1b0_0
|
110 |
+
- pygments=2.11.2=pyhd3eb1b0_0
|
111 |
+
- pyopenssl=20.0.1=pyhd3eb1b0_1
|
112 |
+
- pyparsing=3.0.9=py39haa95532_0
|
113 |
+
- pyqt=5.15.7=py39hd77b12b_0
|
114 |
+
- pyqt5-sip=12.11.0=py39hd77b12b_0
|
115 |
+
- pyrsistent=0.18.0=py39h196d8e1_0
|
116 |
+
- pysocks=1.7.1=py39haa95532_0
|
117 |
+
- python=3.9.13=h6244533_1
|
118 |
+
- python-dateutil=2.8.2=pyhd3eb1b0_0
|
119 |
+
- python-fastjsonschema=2.16.2=py39haa95532_0
|
120 |
+
- python_abi=3.9=2_cp39
|
121 |
+
- pytz=2022.1=py39haa95532_0
|
122 |
+
- pywinpty=2.0.2=py39h5da7b33_0
|
123 |
+
- pyzmq=23.2.0=py39hd77b12b_0
|
124 |
+
- qt-main=5.15.2=he8e5bd7_7
|
125 |
+
- qt-webengine=5.15.9=hb9a9bb5_4
|
126 |
+
- qtconsole=5.3.2=py39haa95532_0
|
127 |
+
- qtpy=2.2.0=py39haa95532_0
|
128 |
+
- qtwebkit=5.212=h3ad3cdb_4
|
129 |
+
- requests=2.28.1=py39haa95532_0
|
130 |
+
- send2trash=1.8.0=pyhd3eb1b0_1
|
131 |
+
- setuptools=63.4.1=py39haa95532_0
|
132 |
+
- sip=6.6.2=py39hd77b12b_0
|
133 |
+
- six=1.16.0=pyhd3eb1b0_1
|
134 |
+
- sniffio=1.2.0=py39haa95532_1
|
135 |
+
- soupsieve=2.3.1=pyhd3eb1b0_0
|
136 |
+
- sqlite=3.39.2=h2bbff1b_0
|
137 |
+
- stack_data=0.2.0=pyhd3eb1b0_0
|
138 |
+
- tbb=2021.5.0=h2d74725_1
|
139 |
+
- terminado=0.13.1=py39haa95532_0
|
140 |
+
- testpath=0.6.0=py39haa95532_0
|
141 |
+
- tk=8.6.12=h8ffe710_0
|
142 |
+
- toml=0.10.2=pyhd3eb1b0_0
|
143 |
+
- tornado=6.2=py39h2bbff1b_0
|
144 |
+
- traitlets=5.1.1=pyhd3eb1b0_0
|
145 |
+
- typing-extensions=4.3.0=py39haa95532_0
|
146 |
+
- typing_extensions=4.3.0=py39haa95532_0
|
147 |
+
- tzdata=2022a=hda174b7_0
|
148 |
+
- urllib3=1.26.11=py39haa95532_0
|
149 |
+
- vc=14.2=h21ff451_1
|
150 |
+
- vs2015_runtime=14.27.29016=h5e58377_2
|
151 |
+
- wcwidth=0.2.5=pyhd3eb1b0_0
|
152 |
+
- webencodings=0.5.1=py39haa95532_1
|
153 |
+
- websocket-client=0.58.0=py39haa95532_4
|
154 |
+
- wheel=0.37.1=pyhd3eb1b0_0
|
155 |
+
- widgetsnbextension=3.5.2=py39haa95532_0
|
156 |
+
- win_inet_pton=1.1.0=py39haa95532_0
|
157 |
+
- wincertstore=0.2=py39haa95532_2
|
158 |
+
- winpty=0.4.3=4
|
159 |
+
- xz=5.2.6=h8d14728_0
|
160 |
+
- zeromq=4.3.4=hd77b12b_0
|
161 |
+
- zlib=1.2.12=h8cc25b3_3
|
162 |
+
- zstd=1.5.2=h19a0ad4_0
|
163 |
+
- pip:
|
164 |
+
- alembic==1.8.1
|
165 |
+
- blis==0.9.1
|
166 |
+
- catalogue==2.0.8
|
167 |
+
- click==8.1.3
|
168 |
+
- cloudpickle==2.2.0
|
169 |
+
- confection==0.0.1
|
170 |
+
- cycler==0.11.0
|
171 |
+
- cymem==2.0.6
|
172 |
+
- databricks-cli==0.17.3
|
173 |
+
- docker==5.0.3
|
174 |
+
- fastai==2.7.9
|
175 |
+
- fastcore==1.5.26
|
176 |
+
- fastdownload==0.0.7
|
177 |
+
- fastprogress==1.0.3
|
178 |
+
- flask==2.2.2
|
179 |
+
- fonttools==4.37.1
|
180 |
+
- gitdb==4.0.9
|
181 |
+
- gitpython==3.1.27
|
182 |
+
- greenlet==1.1.3
|
183 |
+
- importlib-metadata==4.12.0
|
184 |
+
- itsdangerous==2.1.2
|
185 |
+
- kiwisolver==1.4.4
|
186 |
+
- langcodes==3.3.0
|
187 |
+
- mako==1.2.2
|
188 |
+
- matplotlib==3.5.3
|
189 |
+
- mlflow==1.28.0
|
190 |
+
- murmurhash==1.0.8
|
191 |
+
- oauthlib==3.2.1
|
192 |
+
- pathy==0.6.2
|
193 |
+
- preshed==3.0.7
|
194 |
+
- prometheus-flask-exporter==0.20.3
|
195 |
+
- protobuf==4.21.5
|
196 |
+
- pydantic==1.9.2
|
197 |
+
- pyjwt==2.4.0
|
198 |
+
- pywin32==227
|
199 |
+
- pyyaml==6.0
|
200 |
+
- querystring-parser==1.2.4
|
201 |
+
- smart-open==5.2.1
|
202 |
+
- smmap==5.0.0
|
203 |
+
- spacy==3.4.1
|
204 |
+
- spacy-legacy==3.0.10
|
205 |
+
- spacy-loggers==1.0.3
|
206 |
+
- sqlalchemy==1.4.41
|
207 |
+
- sqlparse==0.4.2
|
208 |
+
- srsly==2.4.4
|
209 |
+
- tabulate==0.8.10
|
210 |
+
- thinc==8.1.1
|
211 |
+
- torchviz==0.0.2
|
212 |
+
- tqdm==4.64.1
|
213 |
+
- typer==0.4.2
|
214 |
+
- waitress==2.1.2
|
215 |
+
- wasabi==0.10.1
|
216 |
+
- werkzeug==2.2.2
|
217 |
+
- zipp==3.8.1
|
218 |
+
prefix: C:\Users\jeanpoll\.conda\envs\mole_39_dev
|
mole_models/ed52a28a7b504ff7ba851c850221d1dd/MLmodel
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
flavors:
|
2 |
+
fastai:
|
3 |
+
code: null
|
4 |
+
data: model.fastai
|
5 |
+
fastai_version: 2.7.9
|
6 |
+
python_function:
|
7 |
+
data: model.fastai
|
8 |
+
env: conda.yaml
|
9 |
+
loader_module: mlflow.fastai
|
10 |
+
python_version: 3.9.13
|
11 |
+
mlflow_version: 1.28.0
|
12 |
+
model_uuid: 7811b4341435426287805c26e84e31d6
|
13 |
+
utc_time_created: '2022-10-22 17:09:31.990516'
|
mole_models/ed52a28a7b504ff7ba851c850221d1dd/conda.yaml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
channels:
|
2 |
+
- conda-forge
|
3 |
+
dependencies:
|
4 |
+
- python=3.9.13
|
5 |
+
- pip<=22.1.2
|
6 |
+
- pip:
|
7 |
+
- mlflow
|
8 |
+
- fastai==2.7.9
|
9 |
+
name: mlflow-env
|
mole_models/ed52a28a7b504ff7ba851c850221d1dd/model.fastai
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:96db40fa4c0819530b82edee1cc58725057fa05b1b9679d5b9fc0b6d5da852f1
|
3 |
+
size 244863906
|
mole_models/ed52a28a7b504ff7ba851c850221d1dd/python_env.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
python: 3.9.13
|
2 |
+
build_dependencies:
|
3 |
+
- pip==22.1.2
|
4 |
+
- setuptools==63.4.1
|
5 |
+
- wheel==0.37.1
|
6 |
+
dependencies:
|
7 |
+
- -r requirements.txt
|
mole_models/ed52a28a7b504ff7ba851c850221d1dd/requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
mlflow
|
2 |
+
fastai==2.7.9
|
mole_models/pipeline.rf_classifier_mole
ADDED
Binary file (464 kB). View file
|
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
numpy
|
2 |
+
pandas==1.5.1
|
3 |
+
torch==1.12.1
|
4 |
+
scikit-learn==1.1.3
|
5 |
+
gradio==3.15
|
6 |
+
fastai==2.7.9
|
7 |
+
mlflow==1.28.0
|
8 |
+
huggingface_hub==0.10.1
|
9 |
+
|
useful_functions.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import mlflow
|
2 |
+
import pandas as pd
|
3 |
+
import joblib
|
4 |
+
import os
|
5 |
+
|
6 |
+
from fastai.data.block import MultiCategoryBlock, RandomSplitter, DataBlock, CategoryBlock
|
7 |
+
from fastai.vision.data import *
|
8 |
+
from fastai.vision.learner import *
|
9 |
+
from fastai.vision.all import *
|
10 |
+
import pathlib
|
11 |
+
plt = platform.system()
|
12 |
+
if plt == 'Linux': pathlib.WindowsPath = pathlib.PosixPath
|
13 |
+
|
14 |
+
|
15 |
+
lesion_model = None
|
16 |
+
pipe_cancer = None
|
17 |
+
|
18 |
+
|
19 |
+
def f_load_cnn_model():
|
20 |
+
global lesion_model
|
21 |
+
logged_model = os.path.join("mole_models", "ed52a28a7b504ff7ba851c850221d1dd")
|
22 |
+
lesion_model = mlflow.fastai.load_model(logged_model)
|
23 |
+
lesion_model.cbs.remove(lesion_model.cbs[6])
|
24 |
+
lesion_model.cbs.remove(lesion_model.cbs[4])
|
25 |
+
lesion_model.cbs.remove(lesion_model.cbs[3])
|
26 |
+
|
27 |
+
|
28 |
+
def get_image_files(df):
|
29 |
+
# df = df.assign(path=lambda x: working_dataset_path + x["path"])
|
30 |
+
return df
|
31 |
+
|
32 |
+
def get_x(df):
|
33 |
+
return df["path"]
|
34 |
+
|
35 |
+
def get_y(df):
|
36 |
+
return df["dx"]
|
37 |
+
|
38 |
+
|
39 |
+
def f_create_df_with_files_input(file_path):
|
40 |
+
list_files = [file_path]
|
41 |
+
list_labels = [""]
|
42 |
+
df = pd.DataFrame(data={"path": list_files, "dx": list_labels})
|
43 |
+
return df
|
44 |
+
|
45 |
+
|
46 |
+
def f_predict_cnn_with_tta(file_path):
|
47 |
+
df = f_create_df_with_files_input(file_path)
|
48 |
+
dl = lesion_model.dls.test_dl(df)
|
49 |
+
dl.after_item = Pipeline([ToTensor, Resize(700, method=ResizeMethod.Crop), RandomResizedCrop(350)])
|
50 |
+
pred, _targ = lesion_model.tta(dl=dl, n=4, use_max=False)
|
51 |
+
return pred.tolist()[0]
|
52 |
+
|
53 |
+
|
54 |
+
def f_predict_cnn_simple(file_path):
|
55 |
+
preds = lesion_model.predict(file_path)
|
56 |
+
return preds[2].tolist()
|
57 |
+
|
58 |
+
|
59 |
+
def f_load_cancer_classifier():
|
60 |
+
global pipe_cancer
|
61 |
+
pipe_cancer = joblib.load(os.path.join("mole_models", "pipeline.rf_classifier_mole"))
|
62 |
+
|
63 |
+
def f_predict_cancer(preds, age, sex, localization):
|
64 |
+
df = pd.DataFrame(data=[preds], columns=lesion_model.dls.vocab)
|
65 |
+
df["age"] = age
|
66 |
+
df["sex"] = sex
|
67 |
+
df["localization"] = localization
|
68 |
+
df["label"] = ""
|
69 |
+
label = pipe_cancer.predict(df)[0]
|
70 |
+
label = "Possibly suspicious" if label=="cancer" else "benign"
|
71 |
+
return label
|