Spaces:
Sleeping
Sleeping
francoisMav
commited on
Commit
•
99219af
1
Parent(s):
32646a3
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the image classification pipeline
|
5 |
+
pipe = pipeline("image-classification", model="imfarzanansari/skintelligent-acne")
|
6 |
+
|
7 |
+
# Define the prediction function
|
8 |
+
def classify_acne(image_url):
|
9 |
+
# Use the pipeline to classify the image from the URL
|
10 |
+
predictions = pipe(image_url)
|
11 |
+
|
12 |
+
# Extract the label and score from the predictions
|
13 |
+
label = predictions[0]['label']
|
14 |
+
score = predictions[0]['score']
|
15 |
+
|
16 |
+
return f"Grade: {label}, Confidence: {score:.2f}"
|
17 |
+
|
18 |
+
# Create a Gradio interface
|
19 |
+
interface = gr.Interface(
|
20 |
+
fn=classify_acne, # Prediction function
|
21 |
+
inputs=gr.Textbox(label="Image URL"), # Input type: text (for image URL)
|
22 |
+
outputs="text", # Output type: text
|
23 |
+
title="Acne Level Classifier", # Title of the app
|
24 |
+
description="Enter the URL of an image to classify the acne levels." # Description
|
25 |
+
)
|
26 |
+
|
27 |
+
# Launch the app
|
28 |
+
if __name__ == "__main__":
|
29 |
+
interface.launch()
|