Autogenerate app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
|
2 |
+
|
3 |
+
__all__ = ['classify_image', 'learner', 'categories']
|
4 |
+
|
5 |
+
# Cell
|
6 |
+
from fastai.vision.all import *
|
7 |
import gradio as gr
|
8 |
|
9 |
+
# Cell
|
10 |
+
learner = load_learner("model.pkl")
|
11 |
+
|
12 |
+
categories = "Formula 1","Indy","Nascar"
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred,_,probs = learner.predict(img)
|
16 |
+
return dict(zip(categories, map(float, probs)))
|
17 |
|
18 |
+
# Cell
|
19 |
+
gr.Interface(
|
20 |
+
fn=classify_image,
|
21 |
+
inputs=gr.components.Image(shape=(192,192)),
|
22 |
+
outputs=gr.components.Label(),
|
23 |
+
examples=["formula-1.jpg", "indy.jpg", "nascar.jpg"],
|
24 |
+
).launch(inline=False)
|