Skip to content

imgcaption

Simple Python script to generate descriptive texts (captions) for images, using the Hugging Face Transformers library with the Salesforce/blip-image-captioning-base model. It is basically just a wrapper around such library.

Inspired by:

Usage

Important: this has been tested with Python 3.12.4 on Windows 10.

Set up a Python venv (virtual environment) and install some packages inside it:

Bash
python3 -mvenv venv
venv/bin/python3 -mpip install -r requirements.txt

Then you can use the script like this:

Bash
time printf '%s\n' *.jpg | venv/bin/python3 main.py