Spaces:
Runtime error
Runtime error
Tolga
commited on
Commit
•
c862bde
1
Parent(s):
fab0507
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('model.pkl')
|
5 |
+
|
6 |
+
image = gr.inputs.Image(shape=(128, 128))
|
7 |
+
label = gr.outputs.Label()
|
8 |
+
examples = ['coral.jpg', 'crabs.jpg', 'dolphin.jpg', 'sea_rays.jpg', 'seahorse.jpg', 'turtle_tortoise.jpg']
|
9 |
+
|
10 |
+
categories = ('corals','crabs','dolphin','eel','jelly fish','lobster','nudibranchs','octopus','penguin','puffers','sea rays','sea urchins','seahorse','seal','sharks','squid','starfish','turtle_tortoise','whale')
|
11 |
+
|
12 |
+
def classify_img(img):
|
13 |
+
pred,idx,probs = learn.predict(img)
|
14 |
+
return dict(zip(categories, map(float, probs)))
|
15 |
+
|
16 |
+
interface = gr.Interface(fn=classify_img,
|
17 |
+
inputs=image,
|
18 |
+
outputs=label,
|
19 |
+
examples=examples)
|
20 |
+
|
21 |
+
interface.launch(inline=False)
|
22 |
+
|
23 |
+
|