Spaces:
Runtime error
Runtime error
Commit
·
da8b83a
1
Parent(s):
bd2e2fd
model file inlcuded, app updated
Browse files
app.py
CHANGED
@@ -1,6 +1,19 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
# load the trained model
|
5 |
+
learn = load_learner('model.pkl')
|
6 |
|
7 |
+
categories = ['ironman','hulk','captain america','captain marvel','thanos','thor','vision','ant man','black panther','black widow','doctor strange','spiderman']
|
8 |
+
|
9 |
+
def classify_image(img):
|
10 |
+
pred, idx, probab = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probab)))
|
12 |
+
|
13 |
+
image = gr.inputs.Image(shape=(192,192))
|
14 |
+
label = gr.outputs.Label()
|
15 |
+
examples = ['ironman.jpg','hulk.jpg','captainamerica.jpg','captainmarvel.jpg','thanos.jpg',
|
16 |
+
'thor.jpg','vision.jpg','ant man.jpg','blackpanther.jpg','blackwidow.jpg','doctorstrange.jpg','spiderman.jpg']
|
17 |
+
|
18 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
19 |
+
intf.launch(inline=False)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf5fef21c246d7f562c4fa96ffda24cacc4e7c2ab3fa992ed0067a9ddc479243
|
3 |
+
size 87486117
|