File size: 648 Bytes
f1b2686
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('resnet.pkl')

categories = ('Leão', 'Tigre')

# 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 = ['Lion.jpg','Tiger.jpg','L2.jpg','T2.jpg','P1.jpg','T3.jpg','king.png']

# Create Gradio Interface
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)

# Launch the Gradio interface
intf.launch(inline=False)