MohammedAlakhras commited on
Commit
1407cdc
1 Parent(s): 6e135e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -19
app.py CHANGED
@@ -1,31 +1,45 @@
1
- # AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
2
-
3
- __all__ = ['is_cat', 'learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
4
  import platform
5
  import pathlib
6
  plt = platform.system()
7
  pathlib.WindowsPath = pathlib.PosixPath
8
-
9
- # Cell
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  from fastai.vision.all import *
11
- import gradio as gr
12
 
13
- def is_cat(x): return x[0].isupper()
14
 
15
- # Cell
16
- learn = load_learner('model.pkl')
17
 
18
- # Cell
19
- categories = ('Dog', 'Cat')
20
 
21
  def classify_image(img):
22
- pred,idx,probs = learn.predict(img)
23
- return dict(zip(categories, map(float,probs)))
 
24
 
25
- # Cell
26
- image = gr.inputs.Image(shape=(192, 192))
27
- label = gr.outputs.Label()
28
- examples = ['a.jpg', 'b.jpg', 'c.jpg']
29
 
30
- intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
31
- intf.launch(inline=False)
 
 
 
 
1
  import platform
2
  import pathlib
3
  plt = platform.system()
4
  pathlib.WindowsPath = pathlib.PosixPath
5
+
6
+ #import subprocess
7
+ #import sys
8
+
9
+ #def install(package):
10
+ # subprocess.check_call([sys.executable, "-m", "pip", "install", package])
11
+
12
+ #install('fastbook')
13
+
14
+
15
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
16
+
17
+ # %% auto 0
18
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'interface', 'classify_image']
19
+
20
+ # %% app.ipynb 1
21
+ #from fastbook import *
22
+
23
  from fastai.vision.all import *
24
+ from fastai.vision.widgets import ImageClassifierCleaner
25
 
26
+ import gradio as gr
27
 
28
+ # %% app.ipynb 2
29
+ learn = load_learner('./model.pkl')
30
 
31
+ # %% app.ipynb 3
32
+ categories=('bird','forest')
33
 
34
  def classify_image(img):
35
+ pred,indx,probs=learn.predict(img)
36
+ return dict(zip(categories,map(float,probs)))
37
+
38
 
39
+ # %% app.ipynb 4
40
+ image=gr.inputs.Image(shape=(192,192))
41
+ label=gr.outputs.Label()
42
+ examples=['a.jpg', 'b.jpg','c.jpg','d.jpg']
43
 
44
+ interface=gr.Interface(fn=classify_image, inputs=image ,outputs=label,examples=examples)
45
+ interface.launch(inline=False)