Spaces:
Runtime error
Runtime error
Dane Summers
commited on
Commit
·
5bba94e
1
Parent(s):
4aa1057
Use openai learner to predict bear type.
Browse files
app.py
CHANGED
@@ -1,18 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from fastai.learner import load_learner
|
3 |
from fastai.vision.core import PILImage
|
4 |
-
from PIL import Image
|
5 |
|
6 |
learner = load_learner('export.pkl')
|
7 |
|
8 |
def predict_bear_type(img_path):
|
9 |
-
img =
|
10 |
-
img = PILImage.create(img)
|
11 |
pred,pred_idx,probs = learner.predict(img)
|
12 |
-
return pred
|
13 |
|
14 |
-
|
15 |
-
return predict_bear_type(img_path)
|
16 |
-
|
17 |
-
iface = gr.Interface(fn=greet, inputs="image", outputs="text")
|
18 |
iface.launch()
|
|
|
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")
|
|
|
|
|
|
|
13 |
iface.launch()
|