Spaces:
Runtime error
Runtime error
hello new init
#2
by
procodec
- opened
- .gitattributes +1 -0
- README.md +1 -1
- app.py +32 -6
- img1.jpg +0 -0
- img2.jpg +0 -0
- img3.jpg +0 -0
- requirements.txt +4 -1
.gitattributes
CHANGED
|
@@ -32,3 +32,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
|
|
|
|
|
|
| 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
|
| 35 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: π
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
|
|
|
| 4 |
colorFrom: green
|
| 5 |
colorTo: blue
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.29.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
app.py
CHANGED
|
@@ -6,17 +6,43 @@ learn = load_learner("export.pkl")
|
|
| 6 |
labels = learn.dls.vocab
|
| 7 |
|
| 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 |
title = "Skin Lesion Classifier [RESNET 50]"
|
| 13 |
description = "A skin lesion classifier trained on the ISIC2019 dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 14 |
-
article="<p style='text-align: center'><a href='https://challenge.isic-archive.com/data/' target='_blank'>Link to ISIC Dataset</a></p>"
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
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()
|
| 20 |
|
| 21 |
|
| 22 |
|
|
|
|
| 6 |
labels = learn.dls.vocab
|
| 7 |
|
| 8 |
def predict(img):
|
| 9 |
+
# Ensure img is a PILImage object; if it's already PIL, create won't harm it.
|
| 10 |
+
# If it's a numpy array (e.g. from Gradio's Image component with type="numpy"),
|
| 11 |
+
# PILImage.create will convert it.
|
| 12 |
img = PILImage.create(img)
|
| 13 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 14 |
+
# Ensure probs are float for JSON serialization if necessary
|
| 15 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 16 |
+
|
| 17 |
title = "Skin Lesion Classifier [RESNET 50]"
|
| 18 |
description = "A skin lesion classifier trained on the ISIC2019 dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 19 |
+
article = "<p style='text-align: center'><a href='https://challenge.isic-archive.com/data/' target='_blank'>Link to ISIC Dataset</a></p>"
|
| 20 |
+
examples = ['img1.jpg', 'img2.jpg', 'img3.jpg']
|
| 21 |
+
|
| 22 |
+
# Updated Gradio Interface
|
| 23 |
+
# gr.inputs.Image becomes gr.Image
|
| 24 |
+
# gr.outputs.Label becomes gr.Label
|
| 25 |
+
# 'shape' parameter for gr.Image is deprecated. Image size is handled by the component or by resizing in the predict function if needed.
|
| 26 |
+
# 'type="pil"' ensures the input to predict() is a PIL Image, aligning with PILImage.create().
|
| 27 |
+
# 'num_top_classes' is a valid parameter for gr.Label.
|
| 28 |
+
# 'interpretation' parameter is deprecated and removed.
|
| 29 |
+
# 'enable_queue' is True by default, so explicit setting is often not needed but kept for clarity.
|
| 30 |
+
|
| 31 |
+
iface = gr.Interface(
|
| 32 |
+
fn=predict,
|
| 33 |
+
inputs=gr.Image(type="pil", label="Upload Skin Lesion Image"),
|
| 34 |
+
outputs=gr.Label(num_top_classes=3, label="Classification Results"),
|
| 35 |
+
title=title,
|
| 36 |
+
description=description,
|
| 37 |
+
article=article,
|
| 38 |
+
examples=examples,
|
| 39 |
+
# interpretation='default', # Removed
|
| 40 |
+
enable_queue=True
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
if __name__ == '__main__':
|
| 44 |
+
iface.launch()
|
| 45 |
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
|
img1.jpg
CHANGED
|
|
Git LFS Details
|
img2.jpg
CHANGED
|
|
Git LFS Details
|
img3.jpg
CHANGED
|
|
Git LFS Details
|
requirements.txt
CHANGED
|
@@ -1 +1,4 @@
|
|
| 1 |
-
fastai
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai~=2.7.10
|
| 2 |
+
gradio~=4.0
|
| 3 |
+
scikit-image
|
| 4 |
+
Werkzeug
|