import gradio as gr from fastai.vision.all import * import skimage learn = load_learner('movements_05_02_22_4pm.pkl') def predict(img): labels = learn.dls.vocab im = PILImage.create(img) pred,pred_idx,probs = learn.predict(im) return {label: float(prob) for (label,prob) in zip(labels,probs)} examples = [f"Image{n:02d}.jpg" for n in range(25)] gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=((512,512))), outputs=gr.outputs.Label(num_top_classes=5), title = "Art Movements", examples = [f"Image{n:02d}" for n in range(10)], description= "What Art Movement Matches the Image Best? Expressionism | Impressionism | Hudson River School | Ukiyo-e | Pre-Raphaelite").launch(share=True, enable_queue=True)