MCPcopy
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / __getitem__

Method __getitem__

dzoedepth/data/diode.py:95–115  ·  view source on GitHub ↗
(self, idx)

Source from the content-addressed store, hash-verified

93 self.transform = ToTensor()
94
95 def __getitem__(self, idx):
96 image_path = self.image_files[idx]
97 depth_path = self.depth_files[idx]
98 depth_mask_path = self.depth_mask_files[idx]
99
100 image = np.asarray(Image.open(image_path), dtype=np.float32) / 255.0
101 depth = np.load(depth_path) # in meters
102 valid = np.load(depth_mask_path) # binary
103
104 # depth[depth > 8] = -1
105 # depth = depth[..., None]
106
107 sample = dict(image=image, depth=depth, valid=valid)
108
109 # return sample
110 sample = self.transform(sample)
111
112 if idx == 0:
113 print(sample["image"].shape)
114
115 return sample
116
117 def __len__(self):
118 return len(self.image_files)

Callers

nothing calls this directly

Calls 2

loadMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected