yigewu commited on
Commit
b424d9d
1 Parent(s): eaf12c0

finished app.py

Browse files
Files changed (3) hide show
  1. app.ipynb +0 -21
  2. app.py +24 -4
  3. app/app.py +0 -27
app.ipynb CHANGED
@@ -381,27 +381,6 @@
381
  "# *export*"
382
  ]
383
  },
384
- {
385
- "cell_type": "code",
386
- "execution_count": 27,
387
- "metadata": {},
388
- "outputs": [
389
- {
390
- "ename": "ImportError",
391
- "evalue": "cannot import name 'notebook2script' from 'nbdev.export' (/diskmnt/Projects/Users/yigewu/tools/miniconda3/envs/deep_learning/lib/python3.10/site-packages/nbdev/export.py)",
392
- "output_type": "error",
393
- "traceback": [
394
- "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
395
- "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
396
- "Cell \u001b[0;32mIn [27], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mnbdev\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mexport\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m notebook2script\n",
397
- "\u001b[0;31mImportError\u001b[0m: cannot import name 'notebook2script' from 'nbdev.export' (/diskmnt/Projects/Users/yigewu/tools/miniconda3/envs/deep_learning/lib/python3.10/site-packages/nbdev/export.py)"
398
- ]
399
- }
400
- ],
401
- "source": [
402
- "from nbdev.export import notebook2script"
403
- ]
404
- },
405
  {
406
  "cell_type": "code",
407
  "execution_count": 28,
 
381
  "# *export*"
382
  ]
383
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  {
385
  "cell_type": "code",
386
  "execution_count": 28,
app.py CHANGED
@@ -1,7 +1,27 @@
 
 
 
 
 
 
 
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()
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% ../app.ipynb 1
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% ../app.ipynb 7
11
+ from fastcore.all import *
12
+ learn = load_learner('donut_model2.pkl')
13
+
14
+ # %% ../app.ipynb 9
15
+ categories = ('donut', 'scone')
16
+
17
+ def classify_image(img):
18
+ pred,idx,probs = learn.predict(img)
19
+ return dict(zip(categories, map(float, probs)))
20
+
21
+ # %% ../app.ipynb 11
22
+ image = gr.inputs.Image(shape = (192,192))
23
+ label = gr.outputs.Label()
24
+ examples = ['donut.jpg', 'scone.jpg']
25
 
26
+ intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
27
+ intf.launch(inline=False, share=True)
app/app.py DELETED
@@ -1,27 +0,0 @@
1
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
2
-
3
- # %% auto 0
4
- __all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
5
-
6
- # %% ../app.ipynb 1
7
- from fastai.vision.all import *
8
- import gradio as gr
9
-
10
- # %% ../app.ipynb 7
11
- from fastcore.all import *
12
- learn = load_learner('donut_model2.pkl')
13
-
14
- # %% ../app.ipynb 9
15
- categories = ('donut', 'scone')
16
-
17
- def classify_image(img):
18
- pred,idx,probs = learn.predict(img)
19
- return dict(zip(categories, map(float, probs)))
20
-
21
- # %% ../app.ipynb 11
22
- image = gr.inputs.Image(shape = (192,192))
23
- label = gr.outputs.Label()
24
- examples = ['donut.jpg', 'scone.jpg']
25
-
26
- intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples)
27
- intf.launch(inline=False, share=True)