Spaces:
Running
Running
George Sergia
commited on
Commit
·
52a03fc
1
Parent(s):
9d4cfbb
Add initial data
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
+
from huggingface_hub import push_to_hub_fastai, from_pretrained_fastai
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
#learner = from_pretrained_fastai("kolkhi/bears")
|
6 |
+
learner = load_learner("model.pkl")
|
7 |
+
|
8 |
+
categories = learner.dls.vocab
|
9 |
+
def classify_bear(img):
|
10 |
+
img_new = PILImage.create(img)
|
11 |
+
img_new.resize((128,128))
|
12 |
+
pred,idx,probs=learner.predict(img_new)
|
13 |
+
return dict(zip(categories, map(float,probs)))
|
14 |
+
|
15 |
+
|
16 |
+
image = gr.components.Image(width=192,height=192)
|
17 |
+
label = gr.components.Label()
|
18 |
+
examples=["deer.jpg", "wolf.jpg", "car.jpg", "ship.jpg"]
|
19 |
+
|
20 |
+
iface = gr.Interface(fn=classify_bear, inputs=image, outputs=label, examples=examples)
|
21 |
+
iface.launch(inline=False, share=True)
|
car.jpg
ADDED
![]() |
deer.jpg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8975a114468962ec376688f28dede643a8d6c6537862c1e56da0198ed951091d
|
3 |
+
size 102979586
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
toml
|
2 |
+
fastai==2.7.18
|
3 |
+
fastbook==0.0.29
|
4 |
+
fastcore==1.7.27
|
5 |
+
scikit-image
|
ship.jpg
ADDED
![]() |
wolf.jpg
ADDED
![]() |