Skip to content

Commit

Permalink
Merge pull request kohya-ss#1278 from Cauldrath/catch_latent_error_file
Browse files Browse the repository at this point in the history
Display name of error latent file
  • Loading branch information
kohya-ss authored May 12, 2024
2 parents 9ddb4d7 + 040e26f commit 7802093
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions library/train_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2123,18 +2123,23 @@ def is_disk_cached_latents_is_expected(reso, npz_path: str, flip_aug: bool):
if not os.path.exists(npz_path):
return False

npz = np.load(npz_path)
if "latents" not in npz or "original_size" not in npz or "crop_ltrb" not in npz: # old ver?
return False
if npz["latents"].shape[1:3] != expected_latents_size:
return False

if flip_aug:
if "latents_flipped" not in npz:
try:
npz = np.load(npz_path)
if "latents" not in npz or "original_size" not in npz or "crop_ltrb" not in npz: # old ver?
return False
if npz["latents_flipped"].shape[1:3] != expected_latents_size:
if npz["latents"].shape[1:3] != expected_latents_size:
return False

if flip_aug:
if "latents_flipped" not in npz:
return False
if npz["latents_flipped"].shape[1:3] != expected_latents_size:
return False
except Exception as e:
print(npz_path)
print(e)
return False

return True


Expand Down

0 comments on commit 7802093

Please sign in to comment.