Spaces:
Sleeping
Sleeping
from fastai.vision.all import load_learner | |
import gradio as gr | |
from PIL import Image | |
# Define the missing function | |
def is_cat(x): | |
return x[0].isupper() | |
# Load the trained model | |
model = load_learner('model.pkl') | |
# Define a function to make predictions | |
def predict(image): | |
pred, _, probs = model.predict(image) | |
return f"Prediction: {pred} (Confidence: {probs.max():.2f})" | |
# Create the Gradio web interface | |
interface = gr.Interface( | |
fn=predict, | |
inputs=gr.inputs.Image(type="pil"), | |
outputs="text", | |
title="Cat vs Dog Classifier", | |
description="Upload an image of a cat or dog and let the model classify it!" | |
) | |
# Launch the Gradio app | |
interface.launch() | |