adding back without lfs
Browse files- README.md +13 -0
- app.py +30 -0
- black.jpg +0 -0
- grizzly.png +0 -0
- teddy.jpg +0 -0
README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Test
|
| 3 |
+
emoji: 📚
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.11.0
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__all__=['learn','categories','classify_image','image','label','examples','iface']
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from fastai import *
|
| 5 |
+
from fastai.vision.widgets import *
|
| 6 |
+
#load_learner is in here
|
| 7 |
+
from fastai.vision.all import *
|
| 8 |
+
learn=load_learner('export.pkl')
|
| 9 |
+
|
| 10 |
+
categories=('Black','Grizzly','Teddy')
|
| 11 |
+
|
| 12 |
+
def classify_image(img):
|
| 13 |
+
pred,idx,probs=learn.predict(img)
|
| 14 |
+
#map needed because output (tensor) is not handled by gradio
|
| 15 |
+
return dict(zip(categories,map(float,probs)))
|
| 16 |
+
|
| 17 |
+
image=gr.inputs.Image(shape=(224,224))
|
| 18 |
+
label = gr.outputs.Label()
|
| 19 |
+
|
| 20 |
+
examples=['black.jpg','grizzly.jpg','teddy.jpg']
|
| 21 |
+
iface=gr.Interface(fn=classify_image,inputs=image,outputs=label,example=examples)
|
| 22 |
+
iface.launch()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
#Can be autogenerated from cells preceded by #|export
|
| 26 |
+
# Using
|
| 27 |
+
|
| 28 |
+
#|default_exp <name off the created .py>
|
| 29 |
+
#from nbdev.export import notebook2script
|
| 30 |
+
#notebook2script('notebookname.ipynb')
|
black.jpg
ADDED
|
grizzly.png
ADDED
|
teddy.jpg
ADDED
|