Spaces:
Runtime error
Runtime error
added app code
Browse files- app.py +22 -0
- mario.jpg +0 -0
- mario_popeye_model.pkl +3 -0
- popeye.png +0 -0
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastcore.all import *
|
3 |
+
|
4 |
+
sd
|
5 |
+
categories = ["Mario", "Popeye"]
|
6 |
+
|
7 |
+
predictor = load_learner("mario_popeye_model.pkl")
|
8 |
+
|
9 |
+
|
10 |
+
def classify_image(img):
|
11 |
+
pre, idx, prob = predictor.predict(img)
|
12 |
+
return dict(zip(categories, map(float, prob)))
|
13 |
+
|
14 |
+
|
15 |
+
image = gr.inputs.Image(192, 192)
|
16 |
+
label = gr.outputs.Label()
|
17 |
+
examples = ["mario.jpg", "popeye.png"]
|
18 |
+
|
19 |
+
gr_interface = gr.Interface(
|
20 |
+
fn=classify_image, inputs=image, outputs=label, examples=examples,
|
21 |
+
)
|
22 |
+
gr_interface.launch(inline=False)
|
mario.jpg
ADDED
mario_popeye_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f19d30925950e91581f242c77432f966c0960da227692270ed58b2d267b56e5f
|
3 |
+
size 46959407
|
popeye.png
ADDED