MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / DIODE

Class DIODE

dzoedepth/data/diode.py:82–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82class DIODE(Dataset):
83 def __init__(self, data_dir_root):
84 import glob
85
86 # image paths are of the form <data_dir_root>/scene_#/scan_#/*.png
87 self.image_files = glob.glob(
88 os.path.join(data_dir_root, '*', '*', '*.png'))
89 self.depth_files = [r.replace(".png", "_depth.npy")
90 for r in self.image_files]
91 self.depth_mask_files = [
92 r.replace(".png", "_depth_mask.npy") for r in self.image_files]
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)
119
120
121def get_diode_loader(data_dir_root, batch_size=1, **kwargs):

Callers 1

get_diode_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected