Prepare image datasets for Flux LoRA training with easy AI captioning, PNG conversion, and flexible output options.
- Convert JPG/JPEG images to PNG format
- AI-powered captioning (using BLIP or filename)
- Save captions in
.txtand/or.jsonformats - Simple CLI (prepare_flux_lora_dataset.py)
- Modern GUI (flux_lora_dataset_gui.pyw) — with Pause, Resume, and Stop!
Install the required dependencies:
pip install -r requirements.txtProcess all images in a directory using BLIP captioning:
python prepare_flux_lora_dataset.py input_directory output_directory--tagger {blip,simple}: Choose caption generatorblip: Uses BLIP (AI; recommended)simple: Uses filenames (fast, no AI)
--format {txt,json,both}: Caption output formattxt:.txtfiles (default for most trainers)json:.jsonfilesboth: Both
--no-convert: Skip PNG conversion (keep originals)--device {auto,cuda,cpu}: Device for BLIPauto(default): Use GPU if available, else CPUcuda: Force GPUcpu: Force CPU
Basic BLIP (both formats):
python prepare_flux_lora_dataset.py ./images ./processed --tagger blip --format bothTXT only:
python prepare_flux_lora_dataset.py ./images ./processed --format txtNo AI (filename tags):
python prepare_flux_lora_dataset.py ./images ./processed --tagger simpleDon't convert PNGs:
python prepare_flux_lora_dataset.py ./images ./processed --no-convertThe GUI makes dataset preparation easy and interactive. You can pause, resume, or stop processing — ideal for big folders!
python flux_lora_dataset_gui.pyw- Folder selection with file browser
- Choose tagger and output format
- Optional PNG conversion
- Live log and visual progress bar
- Pause/Resume/Stop controls
- Error reporting and summaries when done
Each image gets a .txt file with the caption:
image001.png
image001.txt (contains: "a beautiful landscape with mountains and trees")
Each image gets a .json file with:
{
"image": "image001.png",
"caption": "a beautiful landscape with mountains and trees",
"source": "image001.jpg"
}- Supports
.jpg,.jpeg, and.pngfiles. - BLIP model downloads automatically (~990MB, first run).
- Use GPU (
cuda) for much faster BLIP processing. - Large datasets may take time; use the GUI for easier management.
Out of memory?
- Use
--device cpuor select CPU in the GUI. - Split your dataset into smaller batches.
BLIP doesn't work?
- Ensure you have
transformersandtorch:
pip install transformers torch - Check for enough disk space for the model.
Image conversion errors?
- Make sure your images are valid (not corrupted).
- Check permissions for the input/output folders.
Both CLI and GUI work cross-platform. For best results, use the GUI for large or complex batches!