diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-22 10:48:50 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-22 10:48:50 +0100 |
| commit | e323d793e76dec7576546068f9f4c7d8d8a1d34d (patch) | |
| tree | aa84934a39bcf7d65b642e5460048edd52bec83c /cnn_v3/training | |
| parent | 4c7ca0f06eb180f4a83641466014865c334e8987 (diff) | |
fix(cnn_v3): resize target to albedo dims when sizes differ
target.png can have a different resolution than albedo.png in simple
samples; patch slicing into the smaller target produced 0×0 tensors,
crashing torch.stack in the DataLoader collate.
handoff(Gemini): target resized in _load_sample (LANCZOS) + note in HOW_TO_CNN §1c.
Diffstat (limited to 'cnn_v3/training')
| -rw-r--r-- | cnn_v3/training/cnn_v3_utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cnn_v3/training/cnn_v3_utils.py b/cnn_v3/training/cnn_v3_utils.py index 8da276e..5b43a4d 100644 --- a/cnn_v3/training/cnn_v3_utils.py +++ b/cnn_v3/training/cnn_v3_utils.py @@ -273,9 +273,11 @@ class CNNv3Dataset(Dataset): matid = load_gray(sd / 'matid.png') shadow = load_gray(sd / 'shadow.png') transp = load_gray(sd / 'transp.png') - target = np.asarray( - Image.open(sd / 'target.png').convert('RGBA'), - dtype=np.float32) / 255.0 + h, w = albedo.shape[:2] + target_img = Image.open(sd / 'target.png').convert('RGBA') + if target_img.size != (w, h): + target_img = target_img.resize((w, h), Image.LANCZOS) + target = np.asarray(target_img, dtype=np.float32) / 255.0 return albedo, normal, depth, matid, shadow, transp, target def __getitem__(self, idx): |
