from fastai.vision.all import * import gradio as gr learn = load_learner('model.pkl') categories = ['calling', 'clapping', 'cycling', 'dancing', 'drinking', 'eating', 'fighting', 'hugging', 'laughing', 'listening_to_music', 'running', 'sitting', 'sleeping', 'texting', 'using_laptop'] def classify_image(img): pred, idx, probs = learn.predict(img) return {cat: float(prob) for cat, prob in zip(categories, probs)} demo = gr.Interface( fn=classify_image, inputs=gr.Image(), outputs=gr.Label(), examples=[ 'laughing.jpg', 'dancing.jpg', 'drinking.jpg' ] ) demo.launch()