Loading LSUN dataset outputs zero test/val labels


(MinkyuChoi) #1

I am loading LSUN and and using it for classification task for all 10 classes. The training is going well. But the problem is, when I load test or valid dataset, its labels are all zeros. The training dataset’s labels are all fine but test and valid sets are outputing zero labels. I use the function as below. I use functions pytorch provides. The documentations are found here. Do I understand something wrong? It seems the image and labels of train datasets are all good. And test and valid sets’ image is good but labels are all zoros. Could you give me some hints?

def load_lsun(batch_size, img_size=256):
    normalize = transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
    train_loader = torch.utils.data.DataLoader(
            datasets.LSUN(root=os.path.expanduser('~/DATASETS/IMAGE/LSUN'), classes='train', transform=transforms.Compose([
                transforms.RandomHorizontalFlip(), 
                transforms.RandomResizedCrop(img_size, scale=(0.8, 1.0), ratio=(1,1.3)),
                transforms.ToTensor(),
                normalize]), target_transform=None), 
            batch_size=batch_size, shuffle=True,
            num_workers=4, pin_memory=False, drop_last=True)
    test_loader = torch.utils.data.DataLoader(
            datasets.LSUN(root=os.path.expanduser('~/DATASETS/IMAGE/LSUN'), classes='test', transform=transforms.Compose([
                #transforms.RandomHorizontalFlip(), 
                transforms.RandomResizedCrop(img_size, scale=(0.8, 1.0), ratio=(1,1.3)),
                transforms.ToTensor(),
                normalize]), target_transform=None), 
            batch_size=batch_size, shuffle=False,
            num_workers=4, pin_memory=False, drop_last=True)

    return train_loader, test_loader, 10

And when I type ls in the directory where I downloaded dataset, it shows as below. I unzipped all zip files and the list below represents the name of folders.

bedroom_train_lmdb         conference_room_train_lmdb  restaurant_train_lmdb
bedroom_val_lmdb           conference_room_val_lmdb    restaurant_val_lmdb
bridge_train_lmdb          dining_room_train_lmdb      test_lmdb
bridge_val_lmdb            dining_room_val_lmdb        tower_train_lmdb
church_outdoor_train_lmdb  kitchen_train_lmdb          tower_val_lmdb
church_outdoor_val_lmdb    kitchen_val_lmdb            
classroom_train_lmdb       living_room_train_lmdb
classroom_val_lmdb         living_room_val_lmdb