Spaces:
Sleeping
Sleeping
| from fastai.vision.all import * | |
| import gradio as gr | |
| # added custom function from my kaggle to ID cat's first letter as uppercase | |
| def is_cat(x): | |
| return x[0].isupper() | |
| # Load the model you trained and exported from Kaggle | |
| learn = load_learner("model.pkl") | |
| # Define a prediction function for Gradio | |
| def classify_image(img): | |
| pred, idx, probs = learn.predict(img) | |
| return {learn.dls.vocab[i]: float(probs[i]) for i in range(len(probs))} | |
| # Create a Gradio interface | |
| interface = gr.Interface( | |
| fn=classify_image, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Label() | |
| ) | |
| # Launch the interface when the app runs | |
| if __name__ == "__main__": | |
| interface.launch() | |