Spaces:
Runtime error
Runtime error
Commit Β·
a1c5266
1
Parent(s): 0f54621
Final app creation
Browse files- .gitignore +2 -0
- app.ipynb +0 -0
- app.py +33 -5
.gitignore
CHANGED
|
@@ -1 +1,3 @@
|
|
| 1 |
.venv
|
|
|
|
|
|
|
|
|
| 1 |
.venv
|
| 2 |
+
flagged/
|
| 3 |
+
basset.jpg
|
app.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
app.py
CHANGED
|
@@ -1,7 +1,35 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
import sys
|
| 8 |
+
import subprocess
|
| 9 |
+
|
| 10 |
+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'gradio==3.50'])
|
| 11 |
+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'fastai'])
|
| 12 |
+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'ipywidgets'])
|
| 13 |
+
|
| 14 |
+
from fastai.vision.all import *
|
| 15 |
+
import gradio as gr
|
| 16 |
+
import timm
|
| 17 |
+
|
| 18 |
+
# %% ../app.ipynb 3
|
| 19 |
+
learn = load_learner('model.pkl')
|
| 20 |
+
|
| 21 |
+
# %% ../app.ipynb 5
|
| 22 |
+
categories = learn.dls.vocab
|
| 23 |
+
|
| 24 |
+
def classify_image(img):
|
| 25 |
+
pred, idx, probs = learn.predict(img)
|
| 26 |
+
return dict(zip(categories, map(fload, probs)))
|
| 27 |
+
|
| 28 |
+
# %% ../app.ipynb 7
|
| 29 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 30 |
+
label = gr.outputs.Label()
|
| 31 |
+
examples = ['basset.jpg']
|
| 32 |
+
|
| 33 |
+
# %% ../app.ipynb 8
|
| 34 |
+
intf = gr.Interface(fn=classify_image, inputs = image, outputs=label)
|
| 35 |
+
intf.launch(inline=False)
|