This is a simple tag editor for stable diffusion datasets. It can be used to edit datasets generated by automatic labeling tools. This tool is inspired by BooruDatasetTagManager.
- Support display and management of all image tags
- Support undo/redo
- Intelligent prompt for tag input (support fuzzy matching)
- Support drag and drop for tags
- Tags can be inserted/deleted in batches, and the insertion position can be specified
- Datasets can be filtered by tags
- Customized tag highlighting
- Automatic translation (translation to Chinese is now hard-coded, and may require magic to surf the Internet)
- Quick response
sd-tagtool supports Windows, macOS, and Linux. The installation steps are as follows:
- Find the latest version on the Release page;
- Download the installation package file from the Assets list according to the OS, for example, the suffix of the Windows installation file is .msi or .exe;
- Run the installation file.
Note: sd-tagtool may require newer Windows 10 or Windows 11. Also, I don't often test for compatibility with Linux and macOS.
You can try the basic usage by yourself, only a few details are added here.
When you select a picture, drag the tag of the image to sort it, or click the ×
icon on the tag to delete. But the tags cannot be sorted when multiple images are selected.
You can also turn on the edit all tags switch, which will:
- Delete tags in the entire data set (all tags are displayed at the bottom of the window). For example, deleting "1girl" in all tags will cause the "1girl" tag in all images to be deleted;
- When inserting or replacing tags, all images in the dataset will be operated, not just the selected images.
You can choose a highlight color for the tag in Pick color of the tag's context menu (click the right mouse button), so that you can find it quickly. When you don't need the tag highlighting anymore, you can clear it by Clear picked color in the context menu.
Click a tag with the left mouse button in the tag list to select it. Hold down the Ctrl
key to select multiple tags, and hold down Shift
to select multiple tags by range. The selected tags can be copied or added to the filter through the content menu.
Enter the tags to be filtered in the tags filter input at the top, and then click the Filter button to filter the dataset. Two filtering modes can be selected via the exclude checkbox:
- Include mode: when the image has all the tags in the filter, it will be displayed in the filtered list;
- Exclude mode: Images that do not have all the tags in the filter will be shown in the filtered list.
After editing the dataset, you need to click the Filter button again to update the filtered dataset. You can enter tags manually, or right-click in the tags list and add selected tags to the filter via the Add filter menu.
Enter a tag in the tags input box and click the Insert button to insert a new tag into the selected dataset (you can select multiple images). As you can see tags input box can fill in multiple tags.
The insertion position is specified by the position box. These modes are currently supported:
- auto: Insert tags to tail if there is no label to be inserted in the image, otherwise do nothing;
- Positive number: Insert tags into the position counting from the head, if the tag already exists in the image, it will be moved to the specified position;
- Negative number: Similar to positive numbers, but counting from the tail to the front.
The insertion position can exceed the actual number of tags in the image, and the tags will be inserted at the head or tail position at this time.
Double-clicking a tag directly in the list of all labels will also insert it into the tag set of the selected images. The insertion position at this time is also determined by the position.
Click the >
button on the left side of the tag editing bar to open the tag replacement bar. Enter the tags for replacement in the replace with input box, and click the Replace button to replace the tags. Tag replacement is one-to-one correspondence, for example:
- Replace
a,b,c
withd,e,f
means:a
is replaced byd
,b
is replaced bye
,c
is replaced byf
; - Replace
a,b,c
withd,e
means:a
is replaced withd
,b
is replaced withe
,f
is deleted; - Replace
a,b
withd,e,f
means:a
replaced withd
andb
replaced withe,f
.
The specific replacement process for each tag is:
- The replaced tag will appear in the position of the original tag;
- If the replaced tag already exists in the image tag list, subsequent duplicates will be removed;
- If the image does not have the original tag, the corresponding replacement will not be performed;
- You can also delete tags by replacing them with nothing.
Click Undo and Redo in the Edit menu to undo and redo, and you can also use the shortcut keys to do it.
There is no step limit for undo and redo, but there is currently no reasonable interactive feedback (this will lead to you may not know what happened). Also, the undo history is cleared after opening a new directory.
Click the Translate tags menu of View to enable automatic translation.
After delete the image files in the dataset folder, you can delete the remaining *.txt files using Delete isolated txt in the Tools menu. The command will pop up a dialog to confirm the files that need to be deleted.
This project is based on Tauri and Vue.js. To build this project, you need to install Nojde.js and pnpm. Use these commands to install to Windows:
winget install nodejs # install Node.js
winget install pnpm # install pnpm
Then follow this document to configure the Rust toolchain and WebView2. You can also install rustup with winget, if you use Windows:
winget install rustup
Use the following commands to build when everything is in place:
pnpm install # install all dependencies
pnpm tauri dev # build the debug program and start
According to my test, pnpm tauri dev
is abnormal under Linux desktop, and can only be debugged with Windows or macOS.
Build the release version with the these command:
pnpm tauri build
The user-facing installation package is automatically built by GitHub Action, and the specific configuration is here.