Spaces:
Sleeping
Sleeping
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("<end_of_text>")[0].replace("<start_of_text>", "") | |
iface = gr.Interface(fn=output_generate, inputs=gr.Ifimage(type="pil"), outputs="text") | |
iface.launch() |