Dane Summers
aider: Created a function `predict_bear_type(img_path)` that opens the image at the given path, converts it to a PILImage, and uses the learner to predict the type of bear in the image.
bdfca3e
raw
history blame
434 Bytes
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():
return "Hello, World!"
iface = gr.Interface(fn=greet, inputs=[], outputs="text")
iface.launch()