| import gradio as gr | |
| from transformers import pipeline | |
| model = pipeline(task="image-to-text", | |
| model="Salesforce/blip-image-captioning-base") | |
| def launch(input): | |
| output = model(input) | |
| return output[0]['generated_text'] | |
| def main(): | |
| iface = gr.Interface(launch, | |
| inputs=gr.Image(type='pil'), | |
| outputs="text") | |
| iface.launch() | |
| if __name__=="__main__": | |
| main() |