Spaces:
Build error
Build error
Download app.py from Sunder34/imagegeneration: direct link, hf CLI and curl.
- Browser
- Download file 619 Bytes
-
https://huggingface.co/spaces/Sunder34/imagegeneration/resolve/main/app.py
- Command line
-
hf download hf://spaces/Sunder34/imagegeneration/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Sunder34/imagegeneration/resolve/main/app.py
619 Bytes
| from transformers import pipeline | |
| import gradio as gr | |
| from PIL import Image | |
| pipe = pipeline("image-to-text", model="Salesforce/blip-image-captioning-large") | |
| def generate_caption(image): | |
| # Generate a caption for the image | |
| captions = pipe(image) | |
| return captions[0]['generated_text'] | |
| demo = gr.Interface( | |
| fn=generate_caption, | |
| inputs=gr.Image(type="pil", label="Upload an Image"), | |
| outputs=gr.Textbox(label="Generated Caption"), | |
| title="Image Caption Generator", | |
| description="Upload an image to generate a caption using the BLIP model." | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch(share=True) |