Attempt #1
Browse files- app.py +30 -4
- board-game-catan-IMG_4671.jpg +0 -0
- photo-of-macbook-catan-IMG_4817.jpg +0 -0
- requirements.txt +4 -0
app.py
CHANGED
@@ -1,7 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
#
|
3 |
+
# def greet(name):
|
4 |
+
# return "Hello " + name + "!!"
|
5 |
+
#
|
6 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
+
# iface.launch()
|
8 |
+
|
9 |
+
# Cell
|
10 |
+
from fastai.vision.all import *
|
11 |
import gradio as gr
|
12 |
+
import timm
|
13 |
+
import dill
|
14 |
+
|
15 |
+
# Cell
|
16 |
+
learn = load_learner('catan-model.pkl', pickle_module=dill)
|
17 |
+
|
18 |
+
# Cell
|
19 |
+
categories = learn.dls.vocab
|
20 |
+
|
21 |
+
def classify_image(img):
|
22 |
+
pred, idx, probs = learn.predict(img)
|
23 |
+
return dict(zip(categories, map(float, probs)))
|
24 |
+
|
25 |
|
26 |
+
# Cell
|
27 |
+
image = gr.inputs.Image(shape=(192, 192))
|
28 |
+
label = gr.outputs.Label()
|
29 |
+
examples = ['board-game-catan-IMG_4671.jpg', 'photo-of-macbook-catan-IMG_4817.jpg']
|
30 |
|
31 |
+
# Cell
|
32 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
33 |
+
intf.launch()
|
board-game-catan-IMG_4671.jpg
ADDED
photo-of-macbook-catan-IMG_4817.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
torch
|
2 |
+
fastai>2.6.1
|
3 |
+
timm
|
4 |
+
dill
|