Spaces:
Sleeping
Sleeping
File size: 732 Bytes
d0233e6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import gradio as gr
from fastai.vision.all import load_learner, PILImage
# Load your exported fastai model
model_path = "export.pkl" # your exported .pkl
learn = load_learner(model_path)
# Prediction function
def predict(image):
img = PILImage.create(image) # ensure it's a fastai PILImage
pred_class, pred_idx, outputs = learn.predict(img)
return (str(pred_class))
# Gradio interface
iface = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Textbox(label="Prediction"),
title="FastAI Image Classification",
description="Upload an image to get prediction from your exported fastai model."
)
if __name__ == "__main__":
iface.launch(server_name="0.0.0.0", server_port=7860)
|