Sazzz02 commited on
Commit
d1dae66
·
verified ·
1 Parent(s): 916154c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -3,13 +3,12 @@ from transformers import AutoModelForImageClassification, AutoImageProcessor
3
  from PIL import Image
4
  import torch
5
 
6
- # Load the pretrained model and processor from Hugging Face
7
- model_name = "HuggingFaceM4/swin-tiny-patch4-window7-224-finetuned-isic"
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
- # Gradio Interface
24
- interface = gr.Interface(
25
  fn=predict,
26
  inputs=gr.Image(type="pil"),
27
  outputs="text",
28
- title="Skin Lesion Classifier (ISIC Pretrained)",
29
- description="Upload a skin or scalp image. The model predicts the skin condition using a fine-tuned Swin Transformer."
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