BLIP Integrations Examples
problem statement and usage - https://www.kaggle.com/competitions/wikipedia-image-caption/overview
BLIP integrations examples offer an easy-to-follow guide to setting up and using BLIP models. Ensure you have the following software installed:
- Python (v3.10+ recommended)
- Poetry (A Python packaging and dependency management tool)
Setup
-
For the demo to work, you need to get HuggingFaceAPI Token:
- Visit HuggingFace.
- Sign up or log in.
- Navigate to
Profile -> Settings -> Access Tokens. - Copy an existing token or create a new one.
-
In the
integrations/blip-image-captioning-large/srcdirectory, create a.envfile and set your HuggingFaceAPI Token:export HUGGING_FACE_ACCESS_TOKEN="{Your HuggingFaceAPI Token}"*** I have added my .env in code by creating nano .env so you probably would be able to work on my API token too ***
-
To load the environment variables from
.envand install the dependencies:cd src source .env poetry install
Running The Main Script
To run the project, use the command:
poetry run python main.py
After running the command, a request is sent to the agent every 10 minutes. The results can be seen in the console. Look for the following output in the logs:
Adding agent to Bureau: {agent_address}
Copy the {agent_address} value and replace AI_MODEL_AGENT_ADDRESS with this value in blip_user.py.
In the src/blip_user.py file, there exists a variable named IMAGE_FILE. Modify this file path to point to the specific image you wish to caption.
The default image is located at "images/man_umbrella.jpg".
Feel free to utilize this feature to creatively generate captions for your images with BLIP, leveraging the model from "https://huggingface.co/Salesforce/blip-image-captioning-large". Enjoy experimenting with it!