Spaces:
Sleeping
Sleeping
Gabriel
commited on
Commit
•
487ec32
1
Parent(s):
9b08a10
feat: app, req
Browse files- app.py +24 -0
- requirements.txt +1 -0
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import warnings
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
warnings.simplefilter("ignore", category=UserWarning)
|
6 |
+
|
7 |
+
learn = load_learner('model.pkl')
|
8 |
+
|
9 |
+
warnings.resetwarnings()
|
10 |
+
|
11 |
+
categories = ('Bee', 'Wasp')
|
12 |
+
|
13 |
+
def classify_image(img):
|
14 |
+
_, _, probs = learn.predict(img)
|
15 |
+
return dict(zip(categories, map(float, probs)))
|
16 |
+
|
17 |
+
image = gr.Image()
|
18 |
+
label = gr.Label()
|
19 |
+
|
20 |
+
examples = ['bee.jpg', 'wasp.jpg']
|
21 |
+
|
22 |
+
interface = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
23 |
+
|
24 |
+
interface.launch(inline=False)
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|