- Notifications
You must be signed in to change notification settings - Fork42
Tag manager and captioner for image datasets
License
jhc13/taggui
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Cross-platform desktop application for quickly adding and editing image tagsand captions, aimed towards creators of image datasets for generative AI modelslike Stable Diffusion.
- Keyboard-friendly interface for fast tagging
- Tag autocomplete based on your own most-used tags
- Integrated Stable Diffusion token counter
- Automatic caption and tag generation with models including CogVLM, LLaVA, WDTagger, and many more
- Batch tag operations for renaming, deleting, and sorting tags
- Advanced image list filtering
The easiest way to use the application is to download the latest release fromthereleases page.Choose the appropriate file for your operating system, extract it wherever youwant, and run the executable file inside.You may have to install7-Zip toextract the files if you don't have it on your system.
- macOS users: There is no macOS release because it requires a device runningthe OS, and I do not have one. You can still install and run the programmanually (see below).
- Linux users: You may need to install
libxcb-cursor0
.(Seethis Stack Overflow answer.) Youmay also have to installpython3.12-dev
orpython3.11-dev
(depending onyour Python version) if you get an error while trying to use a CogVLM2model. (Seethis issue.)
Alternatively, you can install manually by cloning this repository andinstalling the dependencies inrequirements.txt
.Runtaggui/run_gui.py
to start the program.Python 3.12 is recommended, but Python 3.11 should also work.
Load the directory containing your images by clicking theLoad Directory
button in the center of the window (orFile
->Load Directory
).Tags are loaded from.txt
files in the directory with the same names as theimages.Any changes you make to the tags are also automatically saved to these.txt
files.
In addition to manual tagging, you can automatically generate captions or tagsfor your images inside TagGUI.GPU generation requires a compatible NVIDIA GPU, and CPU generation is alsosupported.
To use the feature, select the images you want to caption in the image list,then select the captioning model you want to use in the Auto-Captioner pane.If you have a local directory containing previously downloaded models, you canset it inFile
->Settings
to include the models in the model list.Click theStart Auto-Captioning
button to start captioning.You can select multiple images to batch generate captions for all of them.It can take up to several minutes to download and load a model when you firstuse it, but subsequent generations will be much faster.
Prompt
: Instructions given to the captioning model.Prompt formats are handled automatically based on the selected model.You can use the following template variables to dynamically insert informationabout each image into the prompt:
{tags}
: The tags of the image, separated by commas.{name}
: The file name of the image without the extension.{directory}
or{folder}
: The name of the directory containing the image.
An example prompt using a template variable could beDescribe the image using the following tags as context: {tags}
.With this prompt,{tags}
would be replaced with the existing tags of eachimage before the prompt is sent to the model.
Start caption with
: Generated captions will start with this text.
Remove tag separators in caption
: If checked, tag separators (commas bydefault) will be removed from the generated captions.
Discourage from caption
: Words or phrases that should not be present in thegenerated captions.You can separate multiple words or phrases with commas (,
).For example, you can putappears,seems,possibly
to prevent the model fromusing an uncertain tone in the captions.The words may still be generated due to limitations related to tokenization.
Include in caption
: Words or phrases that should be present somewhere in thegenerated captions.You can separate multiple words or phrases with commas (,
).You can also allow the captioning model to choose from a group of words orphrases by separating them with|
.For example, if you putcat,orange|white|black
, the model will attempt togenerate captions that contain the wordcat
and eitherorange
,white
,orblack
.It is not guaranteed that all of your specifications will be met.
Tags to exclude
(WD Tagger models): Tags that should not be generated,separated by commas.
Many of the other generation parameters are described in theHugging Face documentation.
The basic functionality of filtering for images that contain a certain tag isavailable by clicking on the tag in theAll Tags
pane.In addition to this, you can construct more complex filters intheFilter Images
box at the top of theImages
pane.
Click here to see the full documentation for the filter syntax.
These are the prefixes you can use to specify the filter criteria you want toapply:
tag:
: Images that have the filter term as a tagtag:cat
will match images with the tagcat
.
caption
: Images that contain the filter term in the caption- The caption is the list of tags as a single string, as it appears in the
.txt
file. caption:cat
will match images that havecat
anywhere in thecaption. For example, images with the tagorange cat
or thetagcatastrophe
.
- The caption is the list of tags as a single string, as it appears in the
name
: Images that contain the filter term in the file namename:cat
will match images such ascat-1.jpg
orlarge_cat.png
.
path
: Images that contain the filter term in the full file pathpath:cat
will match images such asC:\Users\cats\dog.jpg
or/home/dogs/cat.jpg
.
- You can also use a filter term with no prefix to filter for images thatcontain the term in either the caption or the file path.
cat
will match images containingcat
in the caption or file path.
The following are prefixes for numeric filters. The operators=
(==
alsoworks),!=
,<
,>
,<=
, and>=
are used to specify the type ofcomparison.
tags
: Images that have the specified number of tagstags:=13
will match images that have exactly 13 tags.tags:!=7
will match images that do not have exactly 7 tags (images withless than 7 tags or more than 7 tags).
chars
: Images that have the specified number of characters in the captionchars:<100
will match images that have less than 100 characters in thecaption.chars:>=30
will match images that have 30 or more characters in thecaption.
tokens
: Images that have the specified number of tokens in the captiontokens:>75
will match images that have more than 75 tokens in thecaption.tokens:<=50
will match images that have 50 or fewer tokens in thecaption.
If the filter term contains spaces, you must enclose it in quotes (eithersingle or double quotes).For example, to find images with the tagorange cat
, you mustusetag:"orange cat"
ortag:'orange cat'
.If you have both spaces and quotes in the filter term, you can escape thequotes with backslashes.For example, you can usetag:"orange \"cat\""
for the tagorange "cat"
.An alternative is to use different types of quotes for the outer and innerquotes, like so:tag:'orange "cat"'
.
You can use the*
character as a wildcard to match any number of anycharacters, and the?
character to match any single character.For example,tag:*cat
will match images with tags likeorange cat
,large cat
, andcat
.
Logical operators can be used to combine multiple filters:
NOT
: Images that do not match the filterNOT tag:cat
will match images that do not have the tagcat
.
AND
: Images that match both filters before and after the operatortag:cat AND tag:orange
will match images that have both the tagcat
and the tagorange
.
OR
: Images that match either filter before or after the operatortag:cat OR tag:dog
will match images that have either the tagcat
orthe tagdog
, or both.
The lowercase versions of these operators will also work:not
,and
,andor
.
The operator precedence isNOT
>AND
>OR
, so by default,NOT
will beevaluated first, thenAND
, thenOR
.You can use parentheses to change this order.For example, intag:cat AND (tag:orange OR tag:white)
, theOR
will beevaluated first, matching images that have the tagcat
and either thetagorange
or the tagwhite
.You can nest parentheses and operators to create arbitrarily complex filters.
- ⭐ Previous / next image:
Ctrl
+Up
/Down
(justUp
/Down
also worksin some cases) - Jump to the first untagged image:
Ctrl
+J
- Focus the
Filter Images
box:Alt
+F
- Focus the
Add Tag
box:Alt
+A
- Focus the
Image Tags
list:Alt
+I
- Focus the
Search Tags
box:Alt
+S
- Focus the
Start Auto-Captioning
button:Alt
+C
- First / last image:
Home
/End
- Select multiple images: Hold
Ctrl
orShift
and click the images - Select all images:
Ctrl
+A
- Invert selection:
Ctrl
+I
- Right-clicking on an image will bring up the context menu, which includesactions such as copying and pasting tags and moving or copying selectedimages to another directory.
- Add a tag: Type the tag into the
Add Tag
box and pressEnter
- ⭐ Add the first tag suggested by autocomplete:
Ctrl
+Enter
- Add a tag to multiple images: Select the images in the image list addthe tag
- Delete a tag: Select the tag and press
Delete
- Rename a tag: Double-click the tag, or select the tag and press
F2
- Reorder tags: Drag and drop the tags
- Select multiple tags: Hold
Ctrl
orShift
and click the tags
- Show all images containing a tag: Select the tag (When
Tag click action
isset toFilter images for tag
) - Add a tag to selected images: Click the tag (When
Tag click action
is settoAdd tag to selected images
) - Delete all instances of a tag: Select the tag and press
Delete
- Rename all instances of a tag: Double-click the tag, or select the tag andpress
F2
TheEdit
menu contains additional features for batch tag operations, such asFind and Replace
(Ctrl
+R
) andBatch Reorder Tags
(Ctrl
+B
).
About
Tag manager and captioner for image datasets