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

Class DDAD

dzoedepth/data/ddad.py:82–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80
81
82class DDAD(Dataset):
83 def __init__(self, data_dir_root, resize_shape):
84 import glob
85
86 # image paths are of the form <data_dir_root>/{outleft, depthmap}/*.png
87 self.image_files = glob.glob(os.path.join(data_dir_root, '*.png'))
88 self.depth_files = [r.replace("_rgb.png", "_depth.npy")
89 for r in self.image_files]
90 self.transform = ToTensor(resize_shape)
91
92 def __getitem__(self, idx):
93
94 image_path = self.image_files[idx]
95 depth_path = self.depth_files[idx]
96
97 image = np.asarray(Image.open(image_path), dtype=np.float32) / 255.0
98 depth = np.load(depth_path) # meters
99
100 # depth[depth > 8] = -1
101 depth = depth[..., None]
102
103 sample = dict(image=image, depth=depth)
104 sample = self.transform(sample)
105
106 if idx == 0:
107 print(sample["image"].shape)
108
109 return sample
110
111 def __len__(self):
112 return len(self.image_files)
113
114
115def get_ddad_loader(data_dir_root, resize_shape, batch_size=1, **kwargs):

Callers 1

get_ddad_loaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected