Spaces:
Runtime error
Runtime error
Mohammed Alakhras
commited on
Commit
•
d5702ed
1
Parent(s):
2f4ec9f
first commit
Browse files
app.py
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import subprocess
|
2 |
+
import sys
|
3 |
+
|
4 |
+
def install(package):
|
5 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
|
6 |
+
|
7 |
+
install('fastbook')
|
8 |
+
|
9 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
|
10 |
+
|
11 |
+
# %% auto 0
|
12 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
|
13 |
+
|
14 |
+
# %% app.ipynb 1
|
15 |
+
from fastbook import *
|
16 |
+
|
17 |
+
from fastai.vision.all import *
|
18 |
+
from fastai.vision.widgets import ImageClassifierCleaner
|
19 |
+
|
20 |
+
import gradio as gr
|
21 |
+
|
22 |
+
# %% app.ipynb 2
|
23 |
+
learn = load_learner('model.pkl')
|
24 |
+
|
25 |
+
# %% app.ipynb 3
|
26 |
+
categories=('bird','forest')
|
27 |
+
|
28 |
+
def classify_image(img):
|
29 |
+
pred,indx,probs=learn.predict(img)
|
30 |
+
return dict(zip(categories,map(float,probs)))
|
31 |
+
|
32 |
+
|
33 |
+
# %% app.ipynb 4
|
34 |
+
image=gr.inputs.Image(shape=(192,192))
|
35 |
+
label=gr.outputs.Label()
|
36 |
+
examples=['imagesExample/a.jpg', 'imagesExample/b.jpg', 'imagesExample/dunno.jpg','imagesExample/c.jpg','imagesExample/d.jpg'
|
37 |
+
,'imagesExample/e.jpg','imagesExample/f.jpg','imagesExample/g.jpg']
|
38 |
+
|
39 |
+
interface=gr.Interface(fn=classify_image, inputs=image ,outputs=label,examples=examples)
|
40 |
+
interface.launch(inline=False)
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c39d7d05de265adb13433779de8b2b062bac291bb3bcdfd94cef21efab9df2e1
|
3 |
+
size 46952721
|