I use Dataset Tag Editor (Standalone) for managing the captions used to train LoRAs. This article is how I've installed it on my computer that runs macOS. The tool is also an extension for Automatic1111. According to the developer, the standalone version is more stable than the extension version.
To set it up, I cloned the latest tag (v0.2.4) from the repository and installed the required dependencies in a Python virtual environment using pip. However, I encountered a few issues along the way, which I’ll explain along with their solutions.
Step 1 - Install Python 3.12
To start, I used Python 3.12 because PyTorch support for Python 3.13 is still under development (tracked here). You can install Python 3.12 on macOS using Homebrew with the following command:
brew install [email protected]
Step 2 - Create and Activate a Virtual Environment
Next, create a virtual environment using Python 3.12. Replace <environment_name> with a name of your choice:
python3.12 -m venv <environment_name>
source ./<environment_name>/bin/activate
You can verify the Python version in your virtual environment by running:
python --version
Step 3 - Install PyTorch
Installing PyTorch on macOS requires you to consider whether you want CPU-only support or GPU acceleration via Apple’s Metal Performance Shaders (MPS) framework.
CPU Support:
PyTorch fully supports CPU-based computation on macOS. This setup is suitable for general development, experimentation, and smaller-scale projects.
pip install torch torchvision torchaudio
GPU Support with Metal Acceleration
Starting with PyTorch 1.12, macOS supports GPU acceleration using Metal Performance Shaders (MPS). This is ideal for devices with Apple GPUs (e.g., M1, M1 Pro, M1 Max, M2).
To install PyTorch with MPS support:
pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
For more details, refer to Apple’s documentation, which also includes a test to verify your installation.
Step 3 - Update requirements.txt
Add fastapi==0.112.2
to the requirements.txt
file on its own line to avoid an issue with pydantic
. You can reference this PR for more information.
Step 4 - Install Application Dependencies
Once PyTorch is installed, install the application’s dependencies listed in requirements.txt:
pip install -r requirements.txt
Step 5 - Fix GPU Backend Selection (optional)
If you’re using the MPS backend for GPU acceleration, the dataset-tag-editor-standalone code has a bug that prevents it from selecting the MPS backend automatically, even if it’s available.
Fixing the Bug
Open the file devices.py
Update the
if has_mps()
condition within the function get_optimal_device() with the following code:
if has_mps():
return torch.device("mps")
Windows-Specific Code on macOS
You can safely ignore the code between lines 57–61, as it throws a ModuleNotFoundError: No module named 'torch_directml'
on macOS. This is because torch_directml
is a Windows-specific feature.
Step 6- Launch the app
Finally, launch the application with the following command:
python scripts/launch.py
Step 7 - Update whitelist and Load Images
Add the path to your images in the whitelist setting within the "Settings" tab and click on "Save Settings". Then navigate to "Main" and load your images.
