Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load your Hugging Face model using transformers pipeline for image classification
|
| 5 |
+
classifier = pipeline("image-classification", model="anismizi/skin-type-classifier")
|
| 6 |
+
|
| 7 |
+
def analyze_skin(image):
|
| 8 |
+
# Run inference
|
| 9 |
+
results = classifier(image)
|
| 10 |
+
# Format results for display or API response
|
| 11 |
+
return {res['label']: float(res['score']) for res in results}
|
| 12 |
+
|
| 13 |
+
# Create Gradio Interface
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=analyze_skin,
|
| 16 |
+
inputs=gr.Image(type="pil"),
|
| 17 |
+
outputs=gr.Label(num_top_classes=2),
|
| 18 |
+
title="Skin Condition Analyzer",
|
| 19 |
+
description="Classify skin as dry or oily from image."
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
if __name__ == "__main__":
|
| 23 |
+
iface.launch()
|