Spaces:
Runtime error
Runtime error
nuevo
Browse files- app.py +28 -0
- model.pkl +3 -0
- requirements.txt +5 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../clasificacion_imagenes.ipynb.
|
| 2 |
+
|
| 3 |
+
# %% auto 0
|
| 4 |
+
__all__ = ['learn_inf', 'categories', 'image', 'label', 'examples', 'intf', 'is_bear', 'classify_image']
|
| 5 |
+
|
| 6 |
+
# %% ../clasificacion_imagenes.ipynb 8
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
import gradio as gr
|
| 9 |
+
|
| 10 |
+
def is_bear(x): return x[0].isupper()
|
| 11 |
+
|
| 12 |
+
# %% ../clasificacion_imagenes.ipynb 67
|
| 13 |
+
learn_inf = load_learner('model.pkl')
|
| 14 |
+
|
| 15 |
+
# %% ../clasificacion_imagenes.ipynb 73
|
| 16 |
+
categories = ('black','grizzly', 'teddy')
|
| 17 |
+
|
| 18 |
+
def classify_image(img):
|
| 19 |
+
pred,idx,probs = learn_inf.predict(img)
|
| 20 |
+
return dict(zip(categories, map(float, probs)))
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
# %% ../clasificacion_imagenes.ipynb 76
|
| 24 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 25 |
+
label = gr.outputs.Label()
|
| 26 |
+
examples = ['images/grizzly.jpg', 'images/black.jpg', 'images/teddy.jpg']
|
| 27 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 28 |
+
intf.launch(inline=False, share=True, debug=True)
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:684af2f6b987d7cc8bb61d84f2238b5ae441aadd843e9658ca957a730437ac95
|
| 3 |
+
size 46967293
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
torch
|
| 3 |
+
gradio
|
| 4 |
+
numpy
|
| 5 |
+
pandas
|