Spaces:
Runtime error
Runtime error
godspeed added in learner and examples
Browse files- app.py +17 -4
- favela_rio_01.jpg +0 -0
- requirements.txt +2 -0
- spain_favela_01.pkl +3 -0
- torrox_01.jpg +0 -0
app.py
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
return "Hello " + name + "!"
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
+
import timm
|
| 4 |
|
| 5 |
+
learn = load_learner('spain_favela_01.pkl')
|
|
|
|
| 6 |
|
| 7 |
+
categories = learn.dls.vocab
|
| 8 |
+
|
| 9 |
+
def classify_image(img):
|
| 10 |
+
pred,idx,probs = learn.predict(img)
|
| 11 |
+
return dict(zip(categories, map(float,probs)))
|
| 12 |
+
|
| 13 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 14 |
+
label = gr.outputs.Label()
|
| 15 |
+
examples = ['favela_rio_01.jpg', 'torrox_01.jpg']
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 20 |
+
intf.launch()
|
favela_rio_01.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai>2.6.1
|
| 2 |
+
timm
|
spain_favela_01.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea9fe635b6210aadb6b2d87ffd135d8384c2de80492ea28bd172fb8d4e0eff4d
|
| 3 |
+
size 46958639
|
torrox_01.jpg
ADDED
|