flower
Browse files- app.py +37 -0
- flower.py +0 -7
- flower_export.pkl +3 -0
- rose.jpg +0 -0
- sunflower.jpg +0 -0
- tulip.jpg +0 -0
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: flower.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['temp', 'learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% flower.ipynb 1
|
| 7 |
+
#! pip install -Uqq fastai
|
| 8 |
+
#! pip install -Uqq gradio
|
| 9 |
+
|
| 10 |
+
# %% flower.ipynb 2
|
| 11 |
+
! pip install -Uqq nbdev
|
| 12 |
+
|
| 13 |
+
# %% flower.ipynb 3
|
| 14 |
+
from fastai.vision.all import *
|
| 15 |
+
import gradio as gr
|
| 16 |
+
|
| 17 |
+
# %% flower.ipynb 4
|
| 18 |
+
import pathlib
|
| 19 |
+
temp = pathlib.PosixPath
|
| 20 |
+
pathlib.PosixPath = pathlib.WindowsPath
|
| 21 |
+
|
| 22 |
+
learn = load_learner('flower_export.pkl')
|
| 23 |
+
|
| 24 |
+
# %% flower.ipynb 5
|
| 25 |
+
categories = ('rose', 'sunflower', 'tulip')
|
| 26 |
+
|
| 27 |
+
def classify_image(img):
|
| 28 |
+
pred, idx, probs = learn.predict(img)
|
| 29 |
+
return dict(zip(categories, map(float, probs)))
|
| 30 |
+
|
| 31 |
+
# %% flower.ipynb 6
|
| 32 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 33 |
+
label = gr.outputs.Label()
|
| 34 |
+
examples = ['rose.jpg', 'sunflower.jpg', 'tulip.jpg']
|
| 35 |
+
|
| 36 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 37 |
+
intf.launch(inline=False)
|
flower.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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flower_export.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8921c029d78169901954fb995e1af7ee4a6c6dde3f055a0b605388ba1d4e36c2
|
| 3 |
+
size 46971599
|
rose.jpg
ADDED
|
sunflower.jpg
ADDED
|
tulip.jpg
ADDED
|