(self, index)
| 14 | self.bg = np.array([1,1,1]) if white_background else np.array([0, 0, 0]) |
| 15 | |
| 16 | def __getitem__(self, index): |
| 17 | viewpoint_cam = self.viewpoint_stack[index] |
| 18 | if viewpoint_cam.meta_only: |
| 19 | with Image.open(viewpoint_cam.image_path) as image_load: |
| 20 | im_data = np.array(image_load.convert("RGBA")) |
| 21 | norm_data = im_data / 255.0 |
| 22 | arr = norm_data[:,:,:3] * norm_data[:, :, 3:4] + self.bg * (1 - norm_data[:, :, 3:4]) |
| 23 | image_load = Image.fromarray(np.array(arr*255.0, dtype=np.byte), "RGB") |
| 24 | resized_image_rgb = PILtoTorch(image_load, viewpoint_cam.resolution) |
| 25 | viewpoint_image = resized_image_rgb[:3, ...].clamp(0.0, 1.0) |
| 26 | if resized_image_rgb.shape[1] == 4: |
| 27 | gt_alpha_mask = resized_image_rgb[3:4, ...] |
| 28 | viewpoint_image *= gt_alpha_mask |
| 29 | else: |
| 30 | viewpoint_image *= torch.ones((1, viewpoint_cam.image_height, viewpoint_cam.image_width)) |
| 31 | else: |
| 32 | viewpoint_image = viewpoint_cam.image |
| 33 | |
| 34 | return viewpoint_image, viewpoint_cam |
| 35 | |
| 36 | def __len__(self): |
| 37 | return len(self.viewpoint_stack) |
nothing calls this directly
no test coverage detected