-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix import and make npz for alpha_mask #1632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2207,7 +2207,11 @@ def is_disk_cached_latents_is_expected(reso, npz_path: str, flip_aug: bool, alph | |
| if alpha_mask: | ||
| if "alpha_mask" not in npz: | ||
| return False | ||
| if (npz["alpha_mask"].shape[1], npz["alpha_mask"].shape[0]) != reso: # HxW => WxH != reso | ||
| alpha_mask_size = npz["alpha_mask"].shape[0:2] | ||
| if alpha_mask_size[0] != alpha_mask_size[0] // 8 * 8 or alpha_mask_size[1] != alpha_mask_size[1] // 8 * 8: # ...is legacy caching scheme without rounding to divisible by 8 | ||
| return False | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. まず、npzチェック行程において、後方互換性を確保するため、 この変更を行わずに、古いキャッシュを削除するよう口頭で周知する方法もありますが、 |
||
| alpha_mask_size = (alpha_mask_size[0] // 8, alpha_mask_size[1] // 8) # Resize alpha_mask to 1/8 scale, the same as latents | ||
| if alpha_mask_size != expected_latents_size: # HxW | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更では、新しいalpha_mask_sizeの判定式と比較するように補正しました。 |
||
| return False | ||
| else: | ||
| if "alpha_mask" in npz: | ||
|
|
@@ -2514,6 +2518,7 @@ def cache_batch_latents( | |
| if image.shape[2] == 4: | ||
| alpha_mask = image[:, :, 3] # [H,W] | ||
| alpha_mask = alpha_mask.astype(np.float32) / 255.0 | ||
| alpha_mask = alpha_mask[:image.shape[0] // 8 * 8, :image.shape[1] // 8 * 8] # Without rounding down [H, W], Tensor sizes may not match, so stack the tensors. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. この変更では、alpha_maskの解像度を8の倍数にround downします。 |
||
| alpha_mask = torch.FloatTensor(alpha_mask) # [H,W] | ||
| else: | ||
| alpha_mask = torch.ones_like(image[:, :, 0], dtype=torch.float32) # [H,W] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking validityにおいて、
前述の変更により、alpha_maskが8の倍数になるため、このチェック判定式は使えません。
そのため、後述の変更を加えました。