def get_Data(is_train, dataset_name, batch_size): val_transform = transforms.Compose([ transforms.Resize((224,224)), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) voc_helen = ['bird', 'cat', 'cow', 'dog', 'horse', 'sheep', 'helen', 'voc_multi'] ##cub dataset### label = None if is_train else 0 if not is_train: batch_size = 1 if dataset_name == 'cub': trainset = CUB_VOC(cub_file, dataset_name, 'iccnn', train=True, transform=val_transform, is_frac=label) testset = CUB_VOC(cub_file, dataset_name, 'iccnn', train=False, transform=val_transform, is_frac=label) ###cropped voc dataset### elif dataset_name in voc_helen: trainset = CUB_VOC(voc_file, dataset_name, 'iccnn', train=True, transform=val_transform, is_frac=label) testset = CUB_VOC(voc_file, dataset_name, 'iccnn', train=False, transform=val_transform, is_frac=label) ###celeb dataset### #elif dataset_name == 'celeb': # trainset = Celeb(training = True, transform=None) # testset = Celeb(training = False, transform=None) train_loader = DataLoader(trainset, batch_size=batch_size, shuffle=True) test_loader = DataLoader(testset, batch_size=batch_size, shuffle=False) return train_loader, test_loader
def get_Data(is_train, dataset_name, batch_size): transform = transforms.Compose([ transforms.RandomResizedCrop((224, 224), scale=(0.5, 1.0)), transforms.RandomHorizontalFlip(), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) val_transform = transforms.Compose([ transforms.Resize((224, 224)), transforms.ToTensor(), transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]) ]) voc_helen_name = [ 'bird', 'cat', 'cow', 'dog', 'horse', 'sheep', 'helen', 'voc_multi' ] ##cub dataset### label = None if is_train else 0 if dataset_name == 'cub': trainset = CUB_VOC(cub_file, dataset_name, 'ori', train=True, transform=transform, is_frac=label) testset = CUB_VOC(cub_file, dataset_name, 'ori', train=False, transform=val_transform, is_frac=label) ###cropped voc dataset### elif dataset_name in voc_helen_name: trainset = CUB_VOC(voc_file, dataset_name, 'ori', train=True, transform=transform, is_frac=label) testset = CUB_VOC(voc_file, dataset_name, 'ori', train=False, transform=val_transform, is_frac=label) ###celeb dataset### elif dataset_name == 'celeb': trainset = Celeb(celeb_file, training=True, transform=None, train_num=162770) testset = Celeb(celeb_file, training=False, transform=None, train_num=19962) train_loader = DataLoader(trainset, batch_size=batch_size, shuffle=True) test_loader = DataLoader(testset, batch_size=batch_size, shuffle=False, drop_last=False) return train_loader, test_loader