from fastai.vision.all import * import gradio as gr learn = load_learner('model.pkl') catergories = ('Cashew anthracnose', 'Cashew gumosis', 'Cashew healthy', 'Cashew leaf miner', 'Cashew red rust', 'Cassava bacterial blight', 'Cassava brown spot', 'Cassava green mite', 'Cassava healthy', 'Cassava mosaic', 'Maize fall armyworm', 'Maize grasshoper', 'Maize healthy', 'Maize leaf beetle', 'Maize leaf blight', 'Maize leaf spot', 'Maize streak virus', 'Tomato healthy', 'Tomato leaf blight', 'Tomato leaf curl', 'Tomato septoria leaf spot', 'Tomato verticulium wilt') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(catergories, map(float,probs))) image = gr.Image() label = gr.Label() examples = ['sample.jpg'] intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples) intf.launch(inline = False)