MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / __getitem__

Method __getitem__

dataset_loaders/cambridge_scenes.py:227–255  ·  view source on GitHub ↗
(self, index)

Source from the content-addressed store, hash-verified

225 return len(self.rgb_files)
226
227 def __getitem__(self, index):
228 img = load_image(self.rgb_files[index])
229 pose = self.poses[index]
230 if self.df != 1.:
231 img_np = (np.array(img) / 255.).astype(np.float32)
232 dims = (self.W, self.H)
233 img_half_res = cv2.resize(img_np, dims, interpolation=cv2.INTER_AREA) # (H, W, 3)
234 img = img_half_res
235
236 if self.transform is not None:
237 img = self.transform(img)
238
239 if self.target_transform is not None:
240 pose = self.target_transform(pose)
241
242 if self.ret_idx:
243 if self.train and self.fix_idx==False:
244 return img, pose, index
245 else:
246 return img, pose, 0
247 if self.ret_hist:
248 yuv = rgb_to_yuv(img)
249 y_img = yuv[0] # extract y channel only
250 hist = torch.histc(y_img, bins=self.hist_bin, min=0., max=1.) # compute intensity histogram
251 hist = hist/(hist.sum())*100 # convert to histogram density, in terms of percentage per bin
252 hist = torch.round(hist)
253 return img, pose, hist
254
255 return img, pose
256
257def main():
258 """

Callers

nothing calls this directly

Calls 2

rgb_to_yuvFunction · 0.90
load_imageFunction · 0.70

Tested by

no test coverage detected