Spaces:
Runtime error
Runtime error
AgrimSomani
commited on
Commit
•
04eb825
1
Parent(s):
e2d2bee
added my trained model
Browse files
app.py
CHANGED
@@ -1,9 +1,20 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
|
|
3 |
|
4 |
-
|
5 |
-
return "Hello " + name + "!!"
|
6 |
|
7 |
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
learner = load_learner('model.pkl')
|
5 |
|
6 |
+
categories = ('linked-list', 'table', 'graph', 'code', 'math')
|
|
|
7 |
|
8 |
|
9 |
+
def classify_img(img):
|
10 |
+
pred, idx, probs = learner.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probs)))
|
12 |
+
|
13 |
+
|
14 |
+
image = gr.inputs.Image(shape(192, 192))
|
15 |
+
label = gr.outputs.Label()
|
16 |
+
examples = ['linked-list.png', 'code.png',
|
17 |
+
'table.png', 'graph.png', 'math.png']
|
18 |
+
|
19 |
+
intf = gr.Interface(fn=classify_img, inputs=image, outputs=label)
|
20 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:67833d7a29ee4fb3e8ec03ea18fa368ca66f0d2d0f744d181c1833597fe40305
|
3 |
+
size 46970533
|