Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('model.pkl')
|
6 |
+
#examples = [['Images/PKG - Breast-Metastases-MSKCC/Breast-Metastases-MSKCC/HobI16-053768896760.jpeg'], ['Images/PKG - CPTAC-BRCA/BRCA/01BR001-4ffefc66-d0ba-4a36-b4fa-35bd91.jpeg']]
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
pred,pred_idx,probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
title = "Proliferative Retinopathy Detection"
|
15 |
+
description = """Detects severity of diabetic retinopathy -
|
16 |
+
|
17 |
+
0 - No DR
|
18 |
+
|
19 |
+
1 - Mild
|
20 |
+
|
21 |
+
2 - Moderate
|
22 |
+
|
23 |
+
3 - Severe
|
24 |
+
|
25 |
+
4 - Proliferative DR
|
26 |
+
"""
|
27 |
+
article="<p style='text-align: center'><a href='https://www.kaggle.com/code/josemauriciodelgado/proliferative-retinopathy' target='_blank'>Notebook</a></p>"
|
28 |
+
interpretation='default'
|
29 |
+
enable_queue=True
|
30 |
+
|
31 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=6),title=title,description=description,article=article,examples=examples , interpretation=interpretation,enable_queue=enable_queue).launch()
|