tristan k
commited on
Commit
·
2ac04fa
1
Parent(s):
c3a66e2
move model to hub, update learner and imports
Browse files- app.py +4 -9
- bear_model.pkl +0 -3
app.py
CHANGED
@@ -1,18 +1,13 @@
|
|
1 |
-
! [ -e /content ] && pip install -Uqq fastbook
|
2 |
import gradio as gr
|
3 |
-
import
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
from fastbook import *
|
8 |
-
from fastai.vision.widgets import *
|
9 |
-
|
10 |
-
learn = load_learner('bear_model.pkl')
|
11 |
|
12 |
categories = ("black", "grizzly", "teddy")
|
13 |
|
14 |
def classify_image(img):
|
15 |
-
pred,idx,probs =
|
16 |
return dict(zip(categories, map(float, probs)))
|
17 |
|
18 |
demo = gr.Interface(fn=classify_image, inputs="image", outputs="label")
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from huggingface_hub import from_pretrained_fastai
|
3 |
|
4 |
+
repo_id = "triskuit/bears"
|
5 |
+
learner = from_pretrained_fastai(repo_id)
|
|
|
|
|
|
|
|
|
6 |
|
7 |
categories = ("black", "grizzly", "teddy")
|
8 |
|
9 |
def classify_image(img):
|
10 |
+
pred,idx,probs = learner.predict(img)
|
11 |
return dict(zip(categories, map(float, probs)))
|
12 |
|
13 |
demo = gr.Interface(fn=classify_image, inputs="image", outputs="label")
|
bear_model.pkl
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:9a2e0511ba2930127a3035de9dff6146f4cf120e995037fa5f65fffa7b98c9a9
|
3 |
-
size 46971593
|
|
|
|
|
|
|
|