from fastai.vision.all import * import gradio as gr import timm import dill import os learn = load_learner('./models/catan-model-paperspace-5.pkl', pickle_module=dill) # learn = load_learner('catan-model.pkl', pickle_module=dill) # categories = learn.dls.vocab categories = ('Not Catan', 'Catan') def classify_image(img): pred, idx, probs = learn.predict(img) return dict(zip(categories, map(float, probs))) # Cell image = gr.inputs.Image(shape=(192, 192)) label = gr.outputs.Label() examples_dir_path = './examples/' examples = [(examples_dir_path + filename) for filename in os.listdir(examples_dir_path) if filename[:1] != '.'] # Cell intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples) intf.launch()