Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2323.
Problem
BaseDataset.set_tag_frequency()splits captions on a hard-coded",". Whenshuffle_caption,caption_tag_dropout_rateortoken_warmup_stepis active, training splits them differently: it first splits on the subset'skeep_tokens_separator, then oncaption_separator(library/dataset.py, the shuffle/keep-tokens block). As a result, thess_tag_frequencymetadata in the saved model does not match the tags that were trained, which is the case described in the issue. For example, withkeep_tokens_separator="|||":(Output of calling
BaseDataset.set_tag_frequencydirectly on dev d02db9a, before and after this change.)Change
set_tag_frequency()accepts optionalcaption_separator=","andkeep_tokens_separator=None. Whenkeep_tokens_separatoris set, it is replaced withcaption_separatorbefore splitting. The defaults keep the current behavior for any other caller.DreamBoothDatasetandFineTuningDatasetpass their subset'scaption_separatorandkeep_tokens_separator.tests/library/test_tag_frequency.py: the default comma case is unchanged,keep_tokens_separatorsplits tags, and a customcaption_separatoris honored.Scope
The issue mentions that other caption modifiers may be affected as well. This PR only aligns the two separators, which is where the mismatch is unambiguous.
secondary_separator, wildcards and multi-line captions are left as they are. I'm happy to follow up on those if you want the metadata to track them too.Validation
python -m pytest tests/library/test_tag_frequency.py: 3 passed on CPU (Windows, Python 3.12). Before the fix, 2 of the 3 tests failed.This patch was prepared with the help of an AI coding assistant (Claude Code).