import warnings from fastai.vision.all import * import gradio as gr warnings.simplefilter("ignore", category=UserWarning) learn = load_learner('model.pkl') warnings.resetwarnings() categories = ('Orca', 'Estrela do mar') def classify_image(img): _, _, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) image = gr.Image() label = gr.Label() examples = ['k_whale.jpg', 'starfish.jpg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch(inline=False)