adr commited on
Commit
306f319
1 Parent(s): 13c66a0

Autogenerate app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -4
app.py CHANGED
@@ -1,7 +1,24 @@
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name: str) -> str:
4
- return f"Hello {name}!"
 
 
 
 
 
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
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)