Spaces:
Runtime error
Runtime error
File size: 1,022 Bytes
9dae3ee |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# This Gradio app uses the Hugging Face model `google/derm-foundation` to classify skin conditions.
import gradio as gr
from transformers_js_py import pipeline # Use transformers_js_py instead of transformers
# Load the Hugging Face model for skin condition classification
model = pipeline("image-classification", model="google/derm-foundation")
# Define a function to classify an image using the model
def classify_skin_condition(image):
# Run the image through the model
result = model(image)
# Extract the top prediction
top_prediction = result[0]
# Return the label and confidence score
return f"Condition: {top_prediction['label']}, Confidence: {top_prediction['score']:.2f}"
# Create a Gradio interface that takes an image input, runs it through the classify_skin_condition function, and returns the output to a textbox.
demo = gr.Interface(fn=classify_skin_condition, inputs="image", outputs="textbox")
# Launch the interface.
if __name__ == "__main__":
demo.launch(show_error=True) |