CatOrNot / app.py
Gords's picture
added function iscat
694b10c
raw
history blame contribute delete
732 Bytes
import gradio as gr
from fastai.learner import load_learner # Assuming FastAI is used
# Define a custom function named 'is_cat' (replace with your actual function)
def is_cat(x):
# Your actual function logic here
return x[0].isupper()
# Load your pre-trained FastAI model (replace 'model.pkl' with your actual model path)
model = load_learner('model.pkl')
def classify_image(image):
# Use your FastAI model to make a prediction
pred_class, pred_idx, outputs = model.predict(image)
return f"This image is {str(pred_class)} with confidence {outputs[pred_idx]:.2f}"
# Update the Gradio interface
iface = gr.Interface(fn=classify_image, inputs=gr.inputs.Image(shape=(224, 224)), outputs='text')
iface.launch()