File size: 980 Bytes
99219af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
from transformers import pipeline

# Load the image classification pipeline
pipe = pipeline("image-classification", model="imfarzanansari/skintelligent-acne")

# Define the prediction function
def classify_acne(image_url):
    # Use the pipeline to classify the image from the URL
    predictions = pipe(image_url)
    
    # Extract the label and score from the predictions
    label = predictions[0]['label']
    score = predictions[0]['score']
    
    return f"Grade: {label}, Confidence: {score:.2f}"

# Create a Gradio interface
interface = gr.Interface(
    fn=classify_acne,            # Prediction function
    inputs=gr.Textbox(label="Image URL"),  # Input type: text (for image URL)
    outputs="text",              # Output type: text
    title="Acne Level Classifier",  # Title of the app
    description="Enter the URL of an image to classify the acne levels."  # Description
)

# Launch the app
if __name__ == "__main__":
    interface.launch()