Spaces:
Runtime error
Runtime error
Dane Summers
commited on
Commit
·
90fc31d
1
Parent(s):
0a6e65f
Load the model from huggingface
Browse files- app.py +5 -1
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.learner import load_learner
|
3 |
from fastai.vision.core import PILImage
|
|
|
|
|
|
|
|
|
4 |
|
5 |
learner = load_learner('export.pkl')
|
6 |
|
7 |
def predict_bear_type(img_path):
|
8 |
img = PILImage.create(img_path)
|
9 |
-
pred,pred_idx,probs = learner.predict(img)
|
10 |
return f"Prediction: {pred}; Probability: {probs[pred_idx]:.02f}"
|
11 |
|
12 |
iface = gr.Interface(fn=predict_bear_type, inputs="image", outputs="text")
|
|
|
1 |
import gradio as gr
|
2 |
from fastai.learner import load_learner
|
3 |
from fastai.vision.core import PILImage
|
4 |
+
from huggingface_hub import hb_hub_download
|
5 |
+
|
6 |
+
learner = load_learner(hb_hub_download("pinkpekoe/lesson2-bear-classifier", "export.pkl"))
|
7 |
+
|
8 |
|
9 |
learner = load_learner('export.pkl')
|
10 |
|
11 |
def predict_bear_type(img_path):
|
12 |
img = PILImage.create(img_path)
|
13 |
+
pred, pred_idx, probs = learner.predict(img)
|
14 |
return f"Prediction: {pred}; Probability: {probs[pred_idx]:.02f}"
|
15 |
|
16 |
iface = gr.Interface(fn=predict_bear_type, inputs="image", outputs="text")
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
fastai
|
|
|
|
1 |
fastai
|
2 |
+
huggingface_hub
|