File size: 732 Bytes
d38e6cc
827f962
d38e6cc
694b10c
 
 
 
520f4ae
827f962
 
d38e6cc
827f962
 
 
 
 
 
 
520f4ae
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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()