gaze_ai / app.py
francoisMav's picture
Create app.py
99219af verified
raw
history blame contribute delete
980 Bytes
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()