Sungmin Son commited on
Commit
12ecde9
·
1 Parent(s): e934e03

Made app really

Browse files
Files changed (2) hide show
  1. app.py +0 -7
  2. app.py/app/py.py +30 -0
app.py DELETED
@@ -1,7 +0,0 @@
1
- import gradio as gr
2
-
3
- def greet(name):
4
- return "Hello " + name + "!!"
5
-
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
app.py/app/py.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../../Untitled-1.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['model_path', 'learn', 'categories', 'is_cat', 'classify_image']
5
+
6
+ # %% ../../Untitled-1.ipynb 0
7
+ import gradio as gr
8
+ from fastai.vision.all import *
9
+ def is_cat(x): return x[0].isupper()
10
+
11
+ # %% ../../Untitled-1.ipynb 2
12
+ model_path = Path('model.pkl')
13
+ learn = load_learner(model_path)
14
+
15
+ # %% ../../Untitled-1.ipynb 4
16
+ categories = ('dog', 'cat')
17
+
18
+ def classify_image(img):
19
+ pred,idx,probs = learn.predict(img)
20
+ return dict(zip(categories, map(float,probs)))
21
+
22
+
23
+ # %% ../../Untitled-1.ipynb 6
24
+ gr.Interface(fn = classify_image,
25
+ inputs="image",
26
+ outputs="label",
27
+ title = "Dog or Cat",
28
+ description="Sample workflow",
29
+ examples = ['dog.jpg']
30
+ ).launch()