File size: 627 Bytes
d8d8ab1
 
 
 
88431d8
d8d8ab1
 
 
 
 
 
 
 
 
 
 
6429486
d8d8ab1
1df0d79
d8d8ab1
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from fastai.vision.all import load_learner, PILImage

# Load the pre-trained FastAI model
model_path = "model.pkl"
learn = load_learner(model_path)

# Define the prediction function
def predict(image):
    img = PILImage.create(image)
    pred_class, pred_idx, probs = learn.predict(img)
    return f"Prediction: {pred_class}, Probability: {probs[pred_idx]:.4f}"

# Create the Gradio interface
demo = gr.Interface(
    fn=predict,
    inputs=gr.Image(type="pil"),
    outputs="text",
    title="Homa image validation",
    description="Upload an image and get the model's text prediction."
)

demo.launch()