Skip to content

Commit feefcf2

Browse files
committed
Display name of error latent file
When trying to load stored latents, if an error occurs, this change will tell you what file failed to load Currently it will just tell you that something failed without telling you which file
1 parent 71e2c91 commit feefcf2

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

library/train_util.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -2123,18 +2123,21 @@ def is_disk_cached_latents_is_expected(reso, npz_path: str, flip_aug: bool):
21232123
if not os.path.exists(npz_path):
21242124
return False
21252125

2126-
npz = np.load(npz_path)
2127-
if "latents" not in npz or "original_size" not in npz or "crop_ltrb" not in npz: # old ver?
2128-
return False
2129-
if npz["latents"].shape[1:3] != expected_latents_size:
2130-
return False
2131-
2132-
if flip_aug:
2133-
if "latents_flipped" not in npz:
2126+
try:
2127+
npz = np.load(npz_path)
2128+
if "latents" not in npz or "original_size" not in npz or "crop_ltrb" not in npz: # old ver?
21342129
return False
2135-
if npz["latents_flipped"].shape[1:3] != expected_latents_size:
2130+
if npz["latents"].shape[1:3] != expected_latents_size:
21362131
return False
21372132

2133+
if flip_aug:
2134+
if "latents_flipped" not in npz:
2135+
return False
2136+
if npz["latents_flipped"].shape[1:3] != expected_latents_size:
2137+
return False
2138+
except:
2139+
raise RuntimeError(f"Error loading file: {npz_path}")
2140+
21382141
return True
21392142

21402143

0 commit comments

Comments
 (0)