This Python script allows users to download images and associated prompts from the CivitAI API for a specified model, with both a command-line interface (CLI) and a graphical user interface (GUI).
- Download images and prompts for any model hosted on CivitAI.
- CLI for advanced users who prefer terminal-based operations.
- GUI for ease of use, with a progress bar and real-time logging.
- Images are saved in
.jpg
format and prompts in.txt
. - Multi-threading support for faster downloads, configurable in the script.
- Python 3.x
- Required libraries:
requests
argparse
(for CLI)tkinter
(for GUI)concurrent.futures
(for multi-threading)
-
Create and activate a virtual environment:
python3 -m venv ./venv source ./venv/bin/activate
-
Install dependencies:
pip install requests argparse
-
(Optional) GUI To install tinker that is used for interface
Tkinter is pre-installed with Python on Windows. Verify by importing in Python:
import tkinter
If not installed, run:
pip install tk
Tkinter is generally pre-installed. If needed, install via Homebrew:
brew install python-tk
Or use pip:
pip install tk
Install Tkinter using:
sudo apt-get install python3-tk
For Fedora:
sudo dnf install python3-tkinter
For Arch Linux:
sudo pacman -S tk
Before running the script, you need:
- A valid API key from CivitAI.
- The model ID of the model whose images you want to download.
These values are passed as command-line arguments in the CLI or entered directly in the GUI.
--api_key
: (Required) Your CivitAI API key.--model_id
: (Required) The model ID for the images you wish to download.
To download images and prompts from a specific model:
python3 main.py --api_key <your_civitai_api_key> --model_id <your_model_id>
This command will:
- Download the images and associated prompts.
- Save them in the default directory:
./civitai_images/
.
For users who prefer a more interactive experience, the GUI provides a simple form to input the API key and model ID. It also includes:
- Progress bar: Displays real-time download progress.
- Log area: Shows a detailed log of downloads and errors.
python3 GUI.py
Once the window opens:
- Enter your CivitAI API key.
- Enter the model ID.
- Click Download Images.
The images and prompts will be saved in the same ./civitai_images/
directory.
- Download Directory: By default, the images and prompts are saved in the
./civitai_images
directory. You can modify theDOWNLOAD_DIR
variable in the script to change the save location. - Multi-threading: The script uses 10 concurrent threads by default for faster downloads. You can adjust the number of threads by modifying the
MAX_WORKERS
variable in the script.
- NSFW Images: The script downloads NSFW images by default. You can control this by modifying the API request parameters in the script.
- Ensure that your API key is valid and you are adhering to CivitAI's terms of service.
This project is licensed under the MIT License.