Spaces:
Sleeping
Sleeping
File size: 811 Bytes
e8a63a2 1de9dfd e8a63a2 |
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 fastai.vision.all import load_learner, PILImage
# Load the model
model_path = "anime.pkl"
learn = load_learner(model_path)
# Define categories
categories = learn.dls.vocab
# Define the image classification function
def Classify_image(img):
pred,idx,probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# Define the Gradio interface with Blocks
with gr.Blocks() as demo:
gr.Markdown("# Anime-character Classifier")
with gr.Row():
with gr.Column():
image_input = gr.Image()
classify_button = gr.Button("Classify")
with gr.Column():
output_label = gr.Label(label="Classification Result")
classify_button.click(Classify_image, inputs=image_input, outputs=output_label)
demo.launch()
|