Spaces:
Runtime error
Runtime error
bonosa
commited on
Commit
Β·
95fb4df
1
Parent(s):
5e6ce46
yay!
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import torch
|
| 2 |
import sys
|
| 3 |
import pathlib
|
|
|
|
| 4 |
from fastai.vision.all import load_learner, PILImage
|
| 5 |
import gradio
|
| 6 |
from gradio import Interface, Image, Label
|
|
@@ -12,7 +13,8 @@ def custom_resnet_splitter(model):
|
|
| 12 |
|
| 13 |
def predict_parrot_species(image):
|
| 14 |
try:
|
| 15 |
-
|
|
|
|
| 16 |
pred, _, _ = learn_inf.predict(image)
|
| 17 |
return pred
|
| 18 |
except Exception as e:
|
|
@@ -20,6 +22,7 @@ def predict_parrot_species(image):
|
|
| 20 |
return "Error during inference"
|
| 21 |
|
| 22 |
|
|
|
|
| 23 |
input_image = Image(shape=(224, 224))
|
| 24 |
output_label = Label()
|
| 25 |
|
|
|
|
| 1 |
import torch
|
| 2 |
import sys
|
| 3 |
import pathlib
|
| 4 |
+
from pathlib import Path
|
| 5 |
from fastai.vision.all import load_learner, PILImage
|
| 6 |
import gradio
|
| 7 |
from gradio import Interface, Image, Label
|
|
|
|
| 13 |
|
| 14 |
def predict_parrot_species(image):
|
| 15 |
try:
|
| 16 |
+
model_path = Path('parrotclass.pkl') # Use Path instead of a string
|
| 17 |
+
learn_inf = load_learner(model_path)
|
| 18 |
pred, _, _ = learn_inf.predict(image)
|
| 19 |
return pred
|
| 20 |
except Exception as e:
|
|
|
|
| 22 |
return "Error during inference"
|
| 23 |
|
| 24 |
|
| 25 |
+
|
| 26 |
input_image = Image(shape=(224, 224))
|
| 27 |
output_label = Label()
|
| 28 |
|