In the last commit, can we avoid enumerating all images in the dataset when…
- User
In the last commit, can we avoid enumerating all images in the dataset when
should_dedupeis False? Assistant
I've updated
library/config_util.pyto skip iterating through the dataset images whenshould_dedupeisFalse. This avoids the unnecessary overhead of enumerating all images when the deduplication feature is disabled for a dataset.Here is the change applied:
pythonshould_dedupe = getattr(dataset, "skip_duplicate_bucketed_images", False) and dataset.bucket_no_upscale if not should_dedupe: continue for image_key, info in list(dataset.image_data.items()):- User
Is it safe to replace
getattr(dataset, "skip_duplicate_bucketed_images", False)withdataset.skip_duplicate_bucketed_imagesfor all dataset types? Assistant
Yes, it is safe. I've verified that
DreamBoothDataset,FineTuningDataset, andControlNetDataset(the three dataset types used in this context) all initializeskip_duplicate_bucketed_imagesin their__init__methods inlibrary/train_util.py.I have updated
library/config_util.pyto use direct attribute access:pythonshould_dedupe = dataset.skip_duplicate_bucketed_images and dataset.bucket_no_upscale- User
Is it safe to replace things like
getattr(subset, "flip_aug", False)withsubset.flip_aug, all along tocaption_tag_dropout_rate, for all subset types? - User
I've did some cleanup and changed 'dupe' to 'dup' for more consistent naming. Now check the current implementation again.
Assistant
The current implementation in
library/config_util.pylooks correct and adheres to your cleanup instructions.Verification:
-
Safety of
subset.*access: It is safe to replacegetattr(subset, "flip_aug", False)withsubset.flip_aug(and others likecaption_tag_dropout_rate). All subset classes (DreamBoothSubset,FineTuningSubset,ControlNetSubset) inherit fromBaseSubset, which initializes these attributes in its__init__method. -
Naming consistency: The code correctly uses
dedup_key(instead ofdedupe_key) andduprelated naming, matching your cleanup. -
Logic check:
pythonif not (dataset.bucket_no_upscale and dataset.skip_duplicate_bucketed_images): continue
-