AlGouvea's picture
Create app.py
0c0ceb9
Raw History Blame Contribute Delete
653 Bytes
from fastai.vision.all import *
import gradio as gr
learn = load_learner('learn.pkl')
categories = ('Polvo', 'Lula')
# Function to classify the image using the selected model
def classify_image(img):
_, _, probs = learn.predict(img)
return dict(zip(categories, map(float, probs)))
# Define input and output components
image = gr.Image()
label = gr.Label()
# Examples for testing
examples = ['Squid.jpg','Octopus.jpg','Lula.jpeg','Polvo.jpg','Graploct.png','Jelly.png']
# Create Gradio Interface
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
# Launch the Gradio interface
intf.launch(inline=False)