Aryan Kumar commited on
Commit ·
25bfb8a
1
Parent(s): 7972508
modified: app.ipynb
Browse files
app.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
CHANGED
|
@@ -17,23 +17,27 @@ import gradio as gr
|
|
| 17 |
# %%
|
| 18 |
#im = PILImage.create('teddybear.jpg')
|
| 19 |
#im = PILImage.create('grizzly.jpg')
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
# im.thumbnail((192, 192))
|
| 23 |
-
# im
|
| 24 |
|
| 25 |
# %% [markdown]
|
| 26 |
# Let's import the model and create the learner:
|
| 27 |
|
| 28 |
# %%
|
| 29 |
#|export
|
|
|
|
|
|
|
|
|
|
| 30 |
learn = load_learner('export.pkl')
|
| 31 |
|
| 32 |
# %% [markdown]
|
| 33 |
# With the learner we can to the predictions (inference):
|
| 34 |
|
| 35 |
# %%
|
| 36 |
-
|
| 37 |
|
| 38 |
# %% [markdown]
|
| 39 |
# The available categories are contained in the vocab:
|
|
@@ -54,7 +58,7 @@ def classify_image(img):
|
|
| 54 |
# Testing the function:
|
| 55 |
|
| 56 |
# %%
|
| 57 |
-
|
| 58 |
|
| 59 |
# %% [markdown]
|
| 60 |
# ## Gradio App
|
|
@@ -77,7 +81,7 @@ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=exa
|
|
| 77 |
intf.launch(inline=False)
|
| 78 |
|
| 79 |
# %%
|
| 80 |
-
|
| 81 |
|
| 82 |
# %% [markdown]
|
| 83 |
# ## Export
|
|
|
|
| 17 |
# %%
|
| 18 |
#im = PILImage.create('teddybear.jpg')
|
| 19 |
#im = PILImage.create('grizzly.jpg')
|
| 20 |
+
im = PILImage.create('blackbear.jpg')
|
| 21 |
+
|
| 22 |
+
im.thumbnail((192, 192))
|
| 23 |
+
im
|
| 24 |
|
|
|
|
|
|
|
| 25 |
|
| 26 |
# %% [markdown]
|
| 27 |
# Let's import the model and create the learner:
|
| 28 |
|
| 29 |
# %%
|
| 30 |
#|export
|
| 31 |
+
import pathlib
|
| 32 |
+
plt = platform.system()
|
| 33 |
+
if plt == 'Windows': pathlib.PosixPath = pathlib.WindowsPath
|
| 34 |
learn = load_learner('export.pkl')
|
| 35 |
|
| 36 |
# %% [markdown]
|
| 37 |
# With the learner we can to the predictions (inference):
|
| 38 |
|
| 39 |
# %%
|
| 40 |
+
learn.predict(im)
|
| 41 |
|
| 42 |
# %% [markdown]
|
| 43 |
# The available categories are contained in the vocab:
|
|
|
|
| 58 |
# Testing the function:
|
| 59 |
|
| 60 |
# %%
|
| 61 |
+
classify_image(im)
|
| 62 |
|
| 63 |
# %% [markdown]
|
| 64 |
# ## Gradio App
|
|
|
|
| 81 |
intf.launch(inline=False)
|
| 82 |
|
| 83 |
# %%
|
| 84 |
+
intf.close()
|
| 85 |
|
| 86 |
# %% [markdown]
|
| 87 |
# ## Export
|