from fastai.vision.all import * import gradio as gr # Cell learn = load_learner('resnet101model_2.pkl') # Cell categories = ("anna's", 'green-crowned', 'marvelous spatuletail', 'ruby-throated', 'violetear') def classify_image(img): pred,idx,probs = learn.predict(img) return dict(zip(categories, map(float,probs))) # Cell image = gr.inputs.Image(shape=(224, 224)) label = gr.outputs.Label() examples = ['annas.jpeg', 'green-crowned.jpeg', 'marvelous_spatuletail.png', 'ruby-throated.jpeg', 'violetear.jpeg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, description="A Hummingbird classifier with a 90% accuracy. The following are the possible categories the model can predict: anna's, green-crowned, marvelous spatuletail, ruby-throated, violetear") intf.launch(inline=False)