update
Browse files- .gitignore +6 -0
- Cat.jpg +0 -0
- README.md +2 -0
- app.py +26 -4
- dog.jpg +0 -0
- export.pkl +3 -0
- heh.jpg +0 -0
- model.pkl +3 -0
.gitignore
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.ipynb
|
2 |
+
|
3 |
+
|
4 |
+
|
5 |
+
|
6 |
+
|
Cat.jpg
ADDED
README.md
CHANGED
@@ -10,4 +10,6 @@ pinned: false
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
|
|
|
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
10 |
license: apache-2.0
|
11 |
---
|
12 |
|
13 |
+
Following FASTAI course, lesson 2, I have created a simple app to classify images of bunnies. The app is deployed on Hugging Face Spaces and can be accessed at https://huggingface.co/spaces/akhaliq/FastAI-02
|
14 |
+
|
15 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -1,7 +1,29 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
# def greet(name):
|
5 |
+
# return "Hello " + name + "!!"
|
6 |
+
im = PILImage.create('Cat.jpg')
|
7 |
|
8 |
+
categories = ('Dog','Cat')
|
9 |
+
learn = load_learner('model.pkl')
|
10 |
+
|
11 |
+
def is_cat(x):
|
12 |
+
return x[0].isupper()
|
13 |
+
|
14 |
+
def classify_image(img):
|
15 |
+
pred,idx,probs = learn.predict(img)
|
16 |
+
return dict(zip(categories,map(float,probs)))
|
17 |
+
|
18 |
+
# classify_image(im)
|
19 |
+
|
20 |
+
image = gr.inputs.Image(shape = (192,192))
|
21 |
+
label = gr.outputs.Label()
|
22 |
+
examples = ['./Cat.jpg','./dog.jpg','./heh.jpg']
|
23 |
+
|
24 |
+
intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
|
25 |
+
intf.launch(inline=False,share=True)
|
26 |
+
|
27 |
+
|
28 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
29 |
+
# iface.launch(share='True')
|
dog.jpg
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bf1424fc2d016c25f573df9618d9eef56ac5b2e7fc25fa4a3a0220e51225a73b
|
3 |
+
size 46975422
|
heh.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d87f9bf95b98d3f0b88f586bf1b02c49b476a74d4855485c236498961dc1a995
|
3 |
+
size 47061419
|