Spaces:
Runtime error
Runtime error
Dane Summers
aider: Modify Gradio interface to accept an image as input, call `predict_bear_type` with the image, and display the prediction.
4aa1057
import gradio as gr | |
from fastai.learner import load_learner | |
from fastai.vision.core import PILImage | |
from PIL import Image | |
learner = load_learner('export.pkl') | |
def predict_bear_type(img_path): | |
img = Image.open(img_path) | |
img = PILImage.create(img) | |
pred,pred_idx,probs = learner.predict(img) | |
return pred | |
def greet(img_path): | |
return predict_bear_type(img_path) | |
iface = gr.Interface(fn=greet, inputs="image", outputs="text") | |
iface.launch() | |