Spaces:
Runtime error
Runtime error
chuckma
commited on
Commit
·
3b11161
1
Parent(s):
6040ccf
add image file
Browse files- .gitattributes +2 -0
- app.py +27 -2
- cat.jpg +3 -0
- cos.png +3 -0
- dog.jpg +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -1,3 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
-
def
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import gradio as gr
|
2 |
+
# def greet (name): return f"Hello {name}!"
|
3 |
+
# gr.Interface(fn=greet, inputs="text", outputs="text"). launch()
|
4 |
+
|
5 |
+
_all_ = ['is_cat', 'learn', 'classify_image'
|
6 |
+
, 'categories',
|
7 |
+
'image',
|
8 |
+
'label', 'examples', 'intf']
|
9 |
+
# Cell
|
10 |
+
from fastai.vision.al1 import *
|
11 |
import gradio as gr
|
12 |
+
def is_cat(x): return x[0].isupper()
|
13 |
+
# Cell
|
14 |
+
learn = load_learner('model.pkl')
|
15 |
+
# Cell
|
16 |
+
categories = ('Dog', 'Cat')
|
17 |
+
format_float = lambda x: "{:.10f}".format(float(x))
|
18 |
+
|
19 |
+
def classify_image(img):
|
20 |
+
pred,idx,probs = learn.predict(img)
|
21 |
+
return dict (zip(categories, map (format_float,probs)))
|
22 |
+
|
23 |
+
image = gr.inputs.Image(shape=(192, 192))
|
24 |
+
label = gr.outputs.Label()
|
25 |
+
examples = ['dog.jpg'
|
26 |
+
, 'cat.jpg', 'cos.png']
|
27 |
+
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
28 |
+
intf.launch (inline=False)
|
cat.jpg
ADDED
Git LFS Details
|
cos.png
ADDED
Git LFS Details
|
dog.jpg
ADDED
Git LFS Details
|