From e323d793e76dec7576546068f9f4c7d8d8a1d34d Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 22 Mar 2026 10:48:50 +0100 Subject: fix(cnn_v3): resize target to albedo dims when sizes differ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- cnn_v3/training/cnn_v3_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'cnn_v3/training/cnn_v3_utils.py') 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): -- cgit v1.2.3