def __init__(self, data_dir, transformation, device, num_bin): args.data_dir = data_dir args.filename_list = data_dir args.dataset = 'AFLW2000' self.transformations = transformation self.device = device self.num_bin = num_bin idx_tensor = [idx for idx in xrange(67)] self.idx_tensor = torch.FloatTensor(idx_tensor).to(self.device) if args.dataset == 'Pose_300W_LP': pose_dataset = datasets.Pose_300W_LP(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'Pose_300W_LP_random_ds': pose_dataset = datasets.Pose_300W_LP_random_ds( args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'AFLW2000': pose_dataset = datasets.AFLW2000(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'AFLW2000_ds': pose_dataset = datasets.AFLW2000_ds(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'BIWI': pose_dataset = datasets.BIWI(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'AFLW': pose_dataset = datasets.AFLW(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'AFLW_aug': pose_dataset = datasets.AFLW_aug(args.data_dir, args.filename_list, self.transformations) elif args.dataset == 'AFW': pose_dataset = datasets.AFW(args.data_dir, args.filename_list, self.transformations) else: print 'Error: not a valid dataset name' sys.exit() self.test_loader = torch.utils.data.DataLoader( dataset=pose_dataset, batch_size=args.batch_size, num_workers=2)
if args.dataset == 'Pose_300W_LP': pose_dataset = datasets.Pose_300W_LP(args.data_dir, args.filename_list, transformations) elif args.dataset == 'Pose_300W_LP_random_ds': pose_dataset = datasets.Pose_300W_LP_random_ds(args.data_dir, args.filename_list, transformations) elif args.dataset == 'AFLW2000': pose_dataset = datasets.AFLW2000(args.data_dir, args.filename_list, transformations) elif args.dataset == 'AFLW2000_ds': pose_dataset = datasets.AFLW2000_ds(args.data_dir, args.filename_list, transformations) elif args.dataset == 'BIWI': pose_dataset = datasets.BIWI(args.data_dir, args.filename_list, transformations) elif args.dataset == 'AFLW': pose_dataset = datasets.AFLW(args.data_dir, args.filename_list, transformations) elif args.dataset == 'AFLW_aug': pose_dataset = datasets.AFLW_aug(args.data_dir, args.filename_list, transformations) elif args.dataset == 'AFW': pose_dataset = datasets.AFW(args.data_dir, args.filename_list, transformations) else: print('Error: not a valid dataset name') sys.exit() test_loader = torch.utils.data.DataLoader(dataset=pose_dataset, batch_size=args.batch_size, num_workers=2)
print 'Loading data.' transformations = transforms.Compose([transforms.Scale(240), transforms.RandomCrop(224), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])]) if args.dataset == 'Pose_300W_LP': pose_dataset = datasets.Pose_300W_LP(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'Pose_300W_LP_random_ds': pose_dataset = datasets.Pose_300W_LP_random_ds(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'Synhead': pose_dataset = datasets.Synhead(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'AFLW2000': pose_dataset = datasets.AFLW2000(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'BIWI': pose_dataset = datasets.BIWI(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'AFLW': pose_dataset = datasets.AFLW(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'AFLW_aug': pose_dataset = datasets.AFLW_aug(args.data_dir, args.filename_list, transformations, bin_width_degrees) elif args.dataset == 'AFW': pose_dataset = datasets.AFW(args.data_dir, args.filename_list, transformations, bin_width_degrees) else: print 'Error: not a valid dataset name' sys.exit() train_loader = torch.utils.data.DataLoader(dataset=pose_dataset, batch_size=batch_size, shuffle=True, num_workers=2)