Update app.py
Browse files
app.py
CHANGED
|
@@ -1,43 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
from pathlib import Path
|
| 5 |
-
import gradio.components as components
|
| 6 |
-
from gradio.blocks import Block
|
| 7 |
-
from gradio import encryptor, external, networking, queueing, routes, strings, utils
|
| 8 |
-
from gradio import components, utils
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
repo_id = "Saim8250/Skin-Diseases-Classification"
|
| 17 |
-
path = Path("./")
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
learner = from_pretrained_fastai(repo_id)
|
| 26 |
-
labels = learner.dls.vocab
|
| 27 |
|
| 28 |
-
|
| 29 |
-
label_predict,_,probs = learner.predict(image)
|
| 30 |
-
labels_probs = {labels[i]: float(probs[i]) for i, _ in enumerate(labels)}
|
| 31 |
-
return labels_probs
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
gr.Interface(
|
| 36 |
-
fn=inference,
|
| 37 |
-
title="Skin Diseases classification",
|
| 38 |
-
description = "Predict which type of skin disease",
|
| 39 |
-
inputs="image",
|
| 40 |
-
examples=examples,
|
| 41 |
-
outputs=gr.outputs.Label(num_top_classes=5, label='Prediction'),
|
| 42 |
-
cache_examples=False,
|
| 43 |
-
).launch(debug=True, enable_queue=False)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
learn = load_learner('resnett.pkl')
|
| 6 |
|
| 7 |
+
labels = learn.dls.vocab
|
| 8 |
+
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
title = "Skin Diseases Classifier"
|
| 14 |
+
#description = "A pet breed classifier trained on the Oxford Pets dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 15 |
+
#article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
| 16 |
+
#examples = ['siamese.jpg']
|
| 17 |
+
interpretation='default'
|
| 18 |
+
enable_queue=True
|
|
|
|
|
|
|
| 19 |
|
| 20 |
+
gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|