File size: 653 Bytes
0c0ceb9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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)