import gradio as gr from transformers import BlipForConditionalGeneration from transformers import AutoProcessor model = BlipForConditionalGeneration.from_pretrained( "Salesforce/blip-image-captioning-base") processor = AutoProcessor.from_pretrained( "Salesforce/blip-image-captioning-base") def image_caption(input): inputs = processor(input, return_tensors="pt") out = model.generate(**inputs) return processor.decode(out[0], skip_special_tokens = True) iface = gr.Interface(fn = image_caption, inputs = gr.Image(type='pil'), outputs = "text") iface.launch()