Download test_handler.py from saisriteja/blip: direct link, hf CLI and curl.
- Browser
- Download file 770 Bytes
-
https://huggingface.co/saisriteja/blip/resolve/main/test_handler.py
- Command line
-
hf download hf://saisriteja/blip/test_handler.py
-
curl -L -o test_handler.py https://huggingface.co/saisriteja/blip/resolve/main/test_handler.py
770 Bytes
| # Import and initialize the handler | |
| from handler import EndpointHandler | |
| # Initialize the handler | |
| my_handler = EndpointHandler() | |
| # Sample payload for conditional captioning | |
| conditional_payload = { | |
| "image_url": "https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg", | |
| "prompt": "a photography of" | |
| } | |
| # Sample payload for unconditional captioning | |
| unconditional_payload = { | |
| "image_url": "https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg" | |
| } | |
| # Run the handler for both cases and print the outputs | |
| conditional_caption = my_handler(conditional_payload) | |
| unconditional_caption = my_handler(unconditional_payload) | |
| print("Conditional Caption:", conditional_caption) | |
| print("Unconditional Caption:", unconditional_caption) | |