Spaces:
Build error
Build error
helo
#2
by
procodec
- opened
- .gitattributes +0 -1
- README copy.md +0 -12
- app.py +0 -155
- export.pkl +0 -3
- img1.jpg +0 -3
- img2.jpg +0 -3
- img3.jpg +0 -3
- requirements.txt +0 -17
.gitattributes
CHANGED
|
@@ -33,4 +33,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
*.jpg filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
README copy.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
| 1 |
-
---
|
| 2 |
-
title: Skinlesion
|
| 3 |
-
emoji: 🌍
|
| 4 |
-
colorFrom: green
|
| 5 |
-
colorTo: blue
|
| 6 |
-
sdk: gradio
|
| 7 |
-
sdk_version: 4.29.0
|
| 8 |
-
app_file: app.py
|
| 9 |
-
pinned: false
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.py
DELETED
|
@@ -1,155 +0,0 @@
|
|
| 1 |
-
import warnings
|
| 2 |
-
from fastai.vision.all import *
|
| 3 |
-
import gradio as gr
|
| 4 |
-
import pathlib
|
| 5 |
-
|
| 6 |
-
# Suppress the pickle warning for demo purposes
|
| 7 |
-
warnings.filterwarnings("ignore", category=UserWarning, module="fastai.learner")
|
| 8 |
-
|
| 9 |
-
# Load the model
|
| 10 |
-
learn = load_learner("export.pkl")
|
| 11 |
-
labels = learn.dls.vocab
|
| 12 |
-
|
| 13 |
-
def predict(img):
|
| 14 |
-
"""
|
| 15 |
-
Predict skin lesion classification for the given image.
|
| 16 |
-
|
| 17 |
-
Args:
|
| 18 |
-
img: PIL Image object from Gradio
|
| 19 |
-
|
| 20 |
-
Returns:
|
| 21 |
-
dict: Classification probabilities for each class
|
| 22 |
-
"""
|
| 23 |
-
try:
|
| 24 |
-
# Convert to PILImage if needed
|
| 25 |
-
img = PILImage.create(img)
|
| 26 |
-
pred, pred_idx, probs = learn.predict(img)
|
| 27 |
-
|
| 28 |
-
# Return as dictionary with float probabilities for JSON serialization
|
| 29 |
-
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 30 |
-
except Exception as e:
|
| 31 |
-
raise gr.Error(f"Error processing image: {str(e)}")
|
| 32 |
-
|
| 33 |
-
# App metadata
|
| 34 |
-
title = "Skin Lesion Classifier [RESNET 50]"
|
| 35 |
-
description = "A skin lesion classifier trained on the ISIC2019 dataset with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 36 |
-
article = "<p style='text-align: center'><a href='https://challenge.isic-archive.com/data/' target='_blank'>Link to ISIC Dataset</a></p>"
|
| 37 |
-
|
| 38 |
-
# Example images
|
| 39 |
-
examples = ['img1.jpg', 'img2.jpg', 'img3.jpg'] if all(pathlib.Path(f).exists() for f in ['img1.jpg', 'img2.jpg', 'img3.jpg']) else None
|
| 40 |
-
|
| 41 |
-
# Create the modern Gradio interface
|
| 42 |
-
def create_interface():
|
| 43 |
-
"""Create and return the Gradio interface"""
|
| 44 |
-
|
| 45 |
-
with gr.Blocks(
|
| 46 |
-
title=title,
|
| 47 |
-
theme=gr.themes.Soft(),
|
| 48 |
-
css=".gradio-container {max-width: 700px; margin: auto;}"
|
| 49 |
-
) as demo:
|
| 50 |
-
|
| 51 |
-
gr.Markdown(f"# {title}")
|
| 52 |
-
gr.Markdown(description)
|
| 53 |
-
|
| 54 |
-
with gr.Row():
|
| 55 |
-
with gr.Column():
|
| 56 |
-
image_input = gr.Image(
|
| 57 |
-
label="Upload Skin Lesion Image",
|
| 58 |
-
type="pil",
|
| 59 |
-
)
|
| 60 |
-
|
| 61 |
-
predict_btn = gr.Button(
|
| 62 |
-
"Classify Lesion",
|
| 63 |
-
variant="primary",
|
| 64 |
-
)
|
| 65 |
-
|
| 66 |
-
with gr.Column():
|
| 67 |
-
output_label = gr.Label(
|
| 68 |
-
label="Classification Results",
|
| 69 |
-
)
|
| 70 |
-
|
| 71 |
-
# Add examples if available
|
| 72 |
-
if examples:
|
| 73 |
-
gr.Examples(
|
| 74 |
-
examples=examples,
|
| 75 |
-
inputs=image_input,
|
| 76 |
-
outputs=output_label,
|
| 77 |
-
fn=predict,
|
| 78 |
-
cache_examples=True
|
| 79 |
-
)
|
| 80 |
-
|
| 81 |
-
# Event handlers
|
| 82 |
-
predict_btn.click(
|
| 83 |
-
fn=predict,
|
| 84 |
-
inputs=image_input,
|
| 85 |
-
outputs=output_label,
|
| 86 |
-
show_progress=True
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
# Also trigger on image upload
|
| 90 |
-
image_input.upload(
|
| 91 |
-
fn=predict,
|
| 92 |
-
inputs=image_input,
|
| 93 |
-
outputs=output_label,
|
| 94 |
-
show_progress=True
|
| 95 |
-
)
|
| 96 |
-
|
| 97 |
-
gr.Markdown(article)
|
| 98 |
-
|
| 99 |
-
return demo
|
| 100 |
-
|
| 101 |
-
if __name__ == '__main__':
|
| 102 |
-
# Create and launch the interface
|
| 103 |
-
demo = create_interface()
|
| 104 |
-
demo.launch(
|
| 105 |
-
server_name="0.0.0.0",
|
| 106 |
-
server_port=7860,
|
| 107 |
-
share=False,
|
| 108 |
-
show_error=True
|
| 109 |
-
)
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
# import gradio as gr
|
| 128 |
-
# from fastai.vision.all import *
|
| 129 |
-
# import skimage
|
| 130 |
-
# #Importing necessary libraries
|
| 131 |
-
# import gradio as gr
|
| 132 |
-
# #import scikit-learn as sklearn
|
| 133 |
-
# from fastai.vision.all import *
|
| 134 |
-
# from sklearn.metrics import roc_auc_score
|
| 135 |
-
|
| 136 |
-
# learn = load_learner('export.pkl')
|
| 137 |
-
|
| 138 |
-
# labels = learn.dls.vocab
|
| 139 |
-
# def predict(img):
|
| 140 |
-
# img = PILImage.create(img)
|
| 141 |
-
# pred,pred_idx,probs = learn.predict(img)
|
| 142 |
-
# return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
# examples = ['img1.jpg','img2.jpg','img3.jpg']
|
| 146 |
-
|
| 147 |
-
# #Launching the gradio application
|
| 148 |
-
# gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(512, 512)),
|
| 149 |
-
# outputs=gr.outputs.Label(num_top_classes=1),
|
| 150 |
-
# title=title,
|
| 151 |
-
# description=description,article=article,
|
| 152 |
-
# examples=examples,
|
| 153 |
-
# enable_queue=enable_queue).launch(inline=False)
|
| 154 |
-
|
| 155 |
-
# #gr.Interface(fn=predict,inputs=gr.inputs.Image(shape=(224, 224)),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,examples=examples,interpretation=interpretation,enable_queue=enable_queue).launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export.pkl
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:ddee7a008adf2aad9f0c445aa6358b109026116573b66f5b3fba2a18e219c804
|
| 3 |
-
size 103303797
|
|
|
|
|
|
|
|
|
|
|
|
img1.jpg
DELETED
Git LFS Details
|
img2.jpg
DELETED
Git LFS Details
|
img3.jpg
DELETED
Git LFS Details
|
requirements.txt
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
# Core dependencies
|
| 2 |
-
fastai>=2.7.10,<2.8.0
|
| 3 |
-
torch>=1.13.0
|
| 4 |
-
torchvision>=0.14.0
|
| 5 |
-
|
| 6 |
-
# Gradio - modern version
|
| 7 |
-
gradio>=4.0.0,<5.0.0
|
| 8 |
-
|
| 9 |
-
# Image processing
|
| 10 |
-
Pillow>=9.0.0
|
| 11 |
-
scikit-image>=0.19.0
|
| 12 |
-
|
| 13 |
-
# Utilities
|
| 14 |
-
pathlib-abc>=0.1.0
|
| 15 |
-
|
| 16 |
-
# Optional: For better performance
|
| 17 |
-
uvicorn[standard]>=0.18.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|