Update app.py
Browse files
app.py
CHANGED
|
@@ -3,13 +3,12 @@ from transformers import AutoModelForImageClassification, AutoImageProcessor
|
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
| 6 |
-
# Load
|
| 7 |
-
model_name = "
|
| 8 |
model = AutoModelForImageClassification.from_pretrained(model_name)
|
| 9 |
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 10 |
labels = model.config.id2label
|
| 11 |
|
| 12 |
-
# Prediction function
|
| 13 |
def predict(image):
|
| 14 |
image = image.convert("RGB")
|
| 15 |
inputs = processor(images=image, return_tensors="pt")
|
|
@@ -20,14 +19,11 @@ def predict(image):
|
|
| 20 |
label = labels[str(predicted_idx)]
|
| 21 |
return f"Prediction: {label}"
|
| 22 |
|
| 23 |
-
|
| 24 |
-
interface = gr.Interface(
|
| 25 |
fn=predict,
|
| 26 |
inputs=gr.Image(type="pil"),
|
| 27 |
outputs="text",
|
| 28 |
-
title="Skin
|
| 29 |
-
description="Upload a skin or scalp image.
|
| 30 |
-
)
|
| 31 |
-
|
| 32 |
-
interface.launch()
|
| 33 |
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
import torch
|
| 5 |
|
| 6 |
+
# Load public model
|
| 7 |
+
model_name = "nateraw/vit-base-patch16-224-in21k-finetuned-dermnet"
|
| 8 |
model = AutoModelForImageClassification.from_pretrained(model_name)
|
| 9 |
processor = AutoImageProcessor.from_pretrained(model_name)
|
| 10 |
labels = model.config.id2label
|
| 11 |
|
|
|
|
| 12 |
def predict(image):
|
| 13 |
image = image.convert("RGB")
|
| 14 |
inputs = processor(images=image, return_tensors="pt")
|
|
|
|
| 19 |
label = labels[str(predicted_idx)]
|
| 20 |
return f"Prediction: {label}"
|
| 21 |
|
| 22 |
+
gr.Interface(
|
|
|
|
| 23 |
fn=predict,
|
| 24 |
inputs=gr.Image(type="pil"),
|
| 25 |
outputs="text",
|
| 26 |
+
title="Skin Condition Classifier (DermNet)",
|
| 27 |
+
description="Upload a skin or scalp image. This model classifies dermatological conditions using a ViT model trained on DermNet."
|
| 28 |
+
).launch()
|
|
|
|
|
|
|
| 29 |
|