|
import gradio as gr |
|
from transformers import pipeline, AutoConfig, AutoModelForImageClassification, AutoImageProcessor |
|
|
|
|
|
config = AutoConfig.from_pretrained("./model/checkpoint-9730/config.json") |
|
model = AutoModelForImageClassification.from_pretrained( |
|
"./model/checkpoint-9730/", config=config |
|
) |
|
image_processor = AutoImageProcessor.from_pretrained("./model/checkpoint-9730/") |
|
|
|
|
|
pipe = pipeline("image-classification", model=model, feature_extractor=image_processor) |
|
def predict(image): |
|
predictions = pipe(image) |
|
return {p["label"]: p["score"] for p in predictions} |
|
|
|
gr.Interface( |
|
predict, |
|
inputs=gr.inputs.Image(label="Upload Skin Disease Image", type="filepath"), |
|
outputs=gr.outputs.Label(num_top_classes=3), |
|
title="Detect your skin disease", |
|
).launch() |