import gradio as gr import open_clip model, _, transform = open_clip.create_model_and_transforms( "coca_ViT-L-14", pretrained="laion2B-s13B-b90k-mscoco-2014.pt" ) def output_generate(image): im = transform(image).unsqueeze(0) generated = model.generate(im) return open_clip.decode(generated[0]).split("")[0].replace("", "") iface = gr.Interface(fn=output_generate, inputs=gr.Ifimage(type="pil"), outputs="text") iface.launch()