Spaces:
Sleeping
Sleeping
Commit
·
7ea3a67
1
Parent(s):
2def7ae
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
|
5 |
+
learn = load_learner('resnet.pkl')
|
6 |
+
|
7 |
+
categories = ('Leão', 'Tigre')
|
8 |
+
|
9 |
+
# Function to classify the image using the selected model
|
10 |
+
def classify_image(img):
|
11 |
+
_, _, probs = learn.predict(img)
|
12 |
+
return dict(zip(categories, map(float, probs)))
|
13 |
+
|
14 |
+
# Define input and output components
|
15 |
+
image = gr.Image()
|
16 |
+
label = gr.Label()
|
17 |
+
|
18 |
+
# Examples for testing
|
19 |
+
examples = ['Lion.jpg','Tiger.jpg','L2.jpeg','T2.jpg','P1.png','T3.png','king.png']
|
20 |
+
|
21 |
+
# Create Gradio Interface
|
22 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
|
24 |
+
# Launch the Gradio interface
|
25 |
+
intf.launch(inline=False)
|