Spaces:
Runtime error
Runtime error
from fastai.vision.all import * | |
import gradio as gr | |
import skimage | |
# Load the pre-trained model | |
learn_inf = load_learner('export.pkl') | |
labels = learn_inf.dls.vocab | |
# Prediction function | |
def predict(img): | |
img = PILImage.create(img) | |
pred, pred_idx, probs = learn_inf.predict(img) | |
return {labels[i]: float(probs[i]) for i in range(len(labels))} | |
# Create and launch the Gradio interface | |
interface = gr.Interface( | |
fn=predict, | |
inputs=gr.Image(), | |
outputs=gr.Label(num_top_classes=3), | |
title="Fish Classifier", | |
description="Fish classifier using a deep learning model" | |
) | |
interface.launch(share=True) | |