def run_from_file(self): if self.args.KITTI == '2015': from dataloader import KITTI_submission_loader as DA else: from dataloader import KITTI_submission_loader2012 as DA test_left_img, test_right_img = DA.dataloader(self.args.datapath) if not os.path.isdir(self.args.save_path): os.makedirs(self.args.save_path) for inx in range(len(test_left_img)): imgL_o = (skimage.io.imread(test_left_img[inx]).astype('float32')) imgR_o = (skimage.io.imread(test_right_img[inx]).astype('float32')) img = self.disp_pred_net.run(imgL_o, imgR_o) # file output print(test_left_img[inx].split('/')[-1]) if self.args.save_figure: skimage.io.imsave( self.args.save_path + '/' + test_left_img[inx].split('/')[-1], (img * 256).astype('uint16')) else: np.save( self.args.save_path + '/' + test_left_img[inx].split('/')[-1][:-4], img)
def run_from_file(self): if self.args_disp.KITTI == '2015': from dataloader import KITTI_submission_loader as DA else: from dataloader import KITTI_submission_loader2012 as DA test_left_img, test_right_img = DA.dataloader(self.args_disp.datapath) if not os.path.isdir(self.args_disp.save_path): os.makedirs(self.args_disp.save_path) for inx in range(len(test_left_img)): imgL_o = (skimage.io.imread(test_left_img[inx]).astype('float32')) imgR_o = (skimage.io.imread(test_right_img[inx]).astype('float32')) img = self.disp_pred_net.run(imgL_o, imgR_o) # # file output # print(test_left_img[inx].split('/')[-1]) # if self.args.save_figure: # skimage.io.imsave(self.args.save_path+'/'+test_left_img[inx].split('/')[-1],(img*256).astype('uint16')) # else: # np.save(self.args.save_path+'/'+test_left_img[inx].split('/')[-1][:-4], img) predix = test_left_img[inx].split('/')[-1][:-4] calib_file = '{}/{}.txt'.format(self.args_gen_lidar.calib_dir, predix) calib = kitti_util.Calibration(calib_file) img = (img * 256).astype(np.uint16) / 256. lidar = self.pcl_generator.run(calib, img) # pad 1 in the indensity dimension lidar = np.concatenate([lidar, np.ones((lidar.shape[0], 1))], 1) lidar = lidar.astype(np.float32) lidar.tofile('{}/{}.bin'.format(self.args_gen_lidar.save_dir, predix)) print('Finish Depth {}'.format(predix))
default=1, metavar='S', help='random seed (default: 1)') args = parser.parse_args() args.cuda = not args.no_cuda and torch.cuda.is_available() torch.manual_seed(args.seed) if args.cuda: torch.cuda.manual_seed(args.seed) if args.KITTI == '2015': from dataloader import KITTI_submission_loader as DA else: from dataloader import KITTI_submission_loader2012 as DA test_left_img, test_right_img = DA.dataloader(args.datapath) if args.model == 'stackhourglass': model = stackhourglass(args.maxdisp) elif args.model == 'basic': model = basic(args.maxdisp) else: print('no model') model = nn.DataParallel(model, device_ids=[0]) model.cuda() if args.loadmodel is not None: state_dict = torch.load(args.loadmodel) model.load_state_dict(state_dict['state_dict'])
args = parser.parse_args() args.cuda = not args.no_cuda and torch.cuda.is_available() torch.manual_seed(args.seed) if args.cuda: torch.cuda.manual_seed(args.seed) kitti2015 = False kitti2012 = False kitti_vkt2 = False if args.KITTI == '2015': print("processing KT15!") data_type_str = "kt15" from dataloader import KITTI_submission_loader as DA test_left_img, test_right_img = DA.dataloader(args.datapath, args.file_txt_path) test_left_disp = None kitti2015 = True elif args.KITTI == '2012': print("processing KT12!") data_type_str = "kt12" from dataloader import KITTI_submission_loader2012 as DA test_left_img, test_right_img = DA.dataloader(args.datapath, args.file_txt_path) test_left_disp = None kitti2012 = True # added by CCJ on 2020/05/22: elif args.KITTI == 'virtual_kt_2': print("processing Virtual KT 2!") data_type_str = "virtual_kt2"
args = parser.parse_args() args.cuda = not args.no_cuda and torch.cuda.is_available() torch.manual_seed(args.seed) if args.cuda: torch.cuda.manual_seed(args.seed) if args.KITTI == '2015': from dataloader import KITTI_submission_loader as DA else: from dataloader import KITTI_submission_loader2012 as DA import sintel_loader as DA test_left_img, test_right_img = DA.dataloader(args.datapath, args.left_dir, args.right_dir) device = torch.device("cuda:1" if torch.cuda.is_available() else "cpu") if args.model == 'stackhourglass': model = stackhourglass(args.maxdisp, device=device, dfd_net=args.dfd, dfd_at_end=args.dfd_at_end, right_head=args.right_head) elif args.model == 'basic': model = basic(args.maxdisp) else: print('no model') model = nn.DataParallel(model, device_ids=[0]) model.cuda()