CharacterGen is a tool designed to generate series of identity-consistent images based on an initial description, using the Black Forest Labs or Replicate APIs.
Original character description
Generated consistent character images
Under the hood, CharacterGen uses both Flux 1.1 Pro Ultra and Flux.1 Kontext to create several images keeping the same identity. This allows for quick data generation for character LoRA training or other purposes.
First, you need to set up your API keys for Black Forest Labs or Replicate. You can do this by copying + renaming the .env.example file to .env and filling in your API keys.
After setting up your API keys, you can run the script to generate images. You can change the default generation provider at any time from the Settings menu of the application.
Recommended: double click the CharacterGen.bat file to run the script. This will automatically set up the environment and run the script.
Note
Sometimes, Windows Defender may flag the script as a potential threat. If this happens, you can safely ignore the warning and allow the script to run.
Manual:If you prefer to run the script manually, follow these steps:
- Create a virtual environment (optional but recommended):
Activate the virtual environment:
python -m venv venv
- On Windows:
venv\Scripts\activate
- On macOS/Linux:
source venv/bin/activate
- On Windows:
- Install the required dependencies:
pip install -r requirements.txt
- Run the script:
python main.py
You can customize the generation process by changing the prompts and variables of the script.
The script uses three different prompts.
- Base Prompt: This is the prompt fed to the model to generate the base image. You can add anything you want to include in the character description.
Template:
prompts/base.md
Note
If you add new variables to the base prompt, make sure to add a .txt file with the variable name in the prompts/selectable directory. This is necessary for the script to recognize the new variable.
- Instruct Prompt: This is the prompt used to generate the secondary images following the base image identity. It is designed to keep the identity of the character while changing the context. Template:
prompts/instruct.md
Note
If you add new variables to the instruct prompt, make sure to add a .txt file with the variable name in the prompts/random directory. This is necessary for the script to recognize the new variable.
- Random Prompt: The same as the instruct prompt, but in a different tone. This is used to "pre-caption" the images, making them more suitable for training. Template:
prompts/random.md
Each variable file has the same structure, with each line representing a different value for the variable. The script will randomly select one of these values when generating the images.
If you want to contribute to CharacterGen, feel free to open a pull request or issue. Contributions are welcome!