Spaces:
Runtime error

File size: 748 Bytes
3f6e4c3
68b31b2
3f6e4c3
68b31b2
3f6e4c3
68b31b2
 
3f6e4c3
68b31b2
 
3f6e4c3
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# app.py
from fastai.vision.all import *
import gradio as gr

# Load the trained model
learn = load_learner('export.pkl')

# Define the classification function that Gradio will use
def classify_image(img):
    pred, idx, probs = learn.predict(img)
    # Assuming your model's predictions are 'T-shirt' and 'Trousers'
    return {pred: max(probs.tolist())}

# Define the Gradio interface
gr_interface = gr.Interface(fn=classify_image,
                            inputs=gr.inputs.Image(type='pil'),
                            outputs=gr.outputs.Label(num_top_classes=2),
                            examples=['path/to/sample_tshirt.jpg', 'path/to/sample_trousers.jpg'])

# Launch the Gradio app
if __name__ == "__main__":
    gr_interface.launch()