from fastai.vision.all import * import gradio as gr import os os.environ["OMP_NUM_THREADS"] = "1" os.environ["MKL_NUM_THREADS"] = "1" learn = load_learner('model.pkl', cpu=True) learn.model.eval() categories = ('damaged', 'intact') def classify_image(img): img = PILImage.create(img) pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) image = gr.Image(width=192, height=192, type="pil") label = gr.Label() examples = ['por.jpeg', 'dam.jpeg', 'damm.jpeg'] intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples, cache_examples=False) intf.launch(inline=False)