Need to generate alt-text for a bulk set of images? This sample provides a basic alt-text generator that iterates over images in a specified folder, converts each image to base64 data URL, generates alt-text for each converted image, and then organizes everything into a markdown file - providing both the file name and alt-text!
Note: If you only need to generate alt-text for a single image, check out the Single Generator.
- OpenAI API access
- Code editor (Visual Studio Code is always a fabulous choice!)
- Make sure your .env file is set up with your
OPENAI_API_KEY
. - Open a terminal in the project directory.
- Run
pip install -r requirements.txt
to install dependencies. - Run the script by providing the path to the folder with your images:
python bulk-generator.py ./images
(You can replace ./images with any folder path you want.)
Have a question or issue trying the sample? Submit an issue to the repo!