Skip to content

Converts all images in a folder to .jpeg and automatically captions them with e.g. gpt-4o or Florence2

License

Notifications You must be signed in to change notification settings

WismutHansen/CAPTN

Repository files navigation

CAPTN

The python scripts in this repository automatically convert images files in a specified folder to .jpeg and generate captions as individual .txt files for each image using eiter the Open AI API with e.g. gpt4o or the Florence2 model downloaded to your machine. Use this script to quickly prepare an image set to be used for FLUX finetuning e.g. with ai-toolkit.

The images and captions are saved to a new subfolder named "JPEGs"

Using the Open AI API

Just rename OAI_CONFIG_LIST.example to OAI_CONFIG_LIST, enter your OpenAI API key and run

pip install -r requirements.txt

and then

python -m image_captioning

you'll be prompted for the folder path and everything else runs automatically.

Using the Florence2 Model locally

Tested with python 3.10

pip install -r requirements_florence.txt

and then

python -m image_captioning_florence

you'll be prompted for the folder path and can optionally provide information on the contents of the images, everything else runs automatically.

About

Converts all images in a folder to .jpeg and automatically captions them with e.g. gpt-4o or Florence2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages