Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Rename 'text' to 'image' | |
| def do_action(image): | |
| # Use the blip model | |
| pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large") | |
| result = pipe(image) | |
| return result[0]['generated_text'] | |
| # input image, output text | |
| # can't use inputs="image" | |
| # instead use inputs=gr.Image(type='pil') | |
| iface = gr.Interface(fn=do_action, inputs=gr.Image(type='pil'), outputs="text") | |
| iface.launch() |