[Bug] TypeError in prepare_buckets_latents.py with --skip_existing due to missing alpha_mask argument
Hello! I've identified a bug in finetune/prepare_buckets_latents.py that causes a crash when using the --skip_existing flag. Bug Description When running prepare_buckets_latents.py, if the --skip_existing argument is used, the script fails with a TypeError. This happens because the call to train_util.is_disk_cached_latents_is_expected is missing the required alpha_mask argument. The script works correctly if --skip_existing is not used, as the problematic line of code is not executed in that case. To Reproduce Run the prepare_buckets_latents.py script. Include the --skip_existing flag in the arguments. The script will crash when it checks for an existing .npz file. Actual Behavior (Error Log)
Generated code
Traceback (most recent call last):
File "I:\SDtrain\sd-scripts\ceshi\buckets_latents.py", line 67, in
Root Cause Analysis The function signature for is_disk_cached_latents_is_expected in library/train_util.py was updated in a previous commit to require a new alpha_mask parameter: def is_disk_cached_latents_is_expected(reso, npz_path: str, flip_aug: bool, alpha_mask: bool): # ...
However, the corresponding function call in finetune/prepare_buckets_latents.py was not updated to include this new argument. Proposed Fix The fix is straightforward: pass the args.alpha_mask to the function call. File: finetune/prepare_buckets_latents.py Line: around 178 Change from:
if train_util.is_disk_cached_latents_is_expected(reso, npz_file_name, args.flip_aug):
Change to:
if train_util.is_disk_cached_latents_is_expected(reso, npz_file_name, args.flip_aug, args.alpha_mask):
his small change resolves the crash and aligns the script with the current library's function signature. Thanks for your great work on this project! Hope this helps.