src/vision/data_process.py
def loadCIFAR(root='../..', split='train'):
    """
    Loads and preprocesses the CIFAR-10 dataset.
    Params:
        - root (str): root directory where the data directory is located.
        - split (str): takes values 'train' and 'val'.
    """
    data_path = os.path.join(root, 'data')
    if split == 'train':
        transform = T.Compose([
            T.RandomCrop(32, padding=4),
            T.RandomHorizontalFlip(),
            T.ToTensor(),
            T.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
        ])
        train = True
    elif split == 'val':
        transform = T.Compose([
            T.ToTensor(),
            T.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
        ])
        train = False
    else:
        msg = f"Split must be train or val, not {split}."
        raise RuntimeError(msg)

    dataset = datasets.CIFAR10(data_path, train=train, transform=transform, download=True)
    print(f"Loaded CIFAR-10 {split} set from {data_path}")
    return dataset

    Loads and preprocesses the CIFAR-10 dataset.
    Params:
        - root (str): root directory where the data directory is located.
        - split (str): takes values 'train' and 'val'.
    
Loads and preprocesses the CIFAR-10 dataset.
Loads and preprocesses the CIFAR - 10 dataset .
def loadCIFAR(root='../..', split='train'):
    data_path = os.path.join(root, 'data')
    if split == 'train':
        transform = T.Compose([
            T.RandomCrop(32, padding=4),
            T.RandomHorizontalFlip(),
            T.ToTensor(),
            T.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
        ])
        train = True
    elif split == 'val':
        transform = T.Compose([
            T.ToTensor(),
            T.Normalize((0.4914, 0.4822, 0.4465), (0.2023, 0.1994, 0.2010)),
        ])
        train = False
    else:
        msg = f"Split must be train or val, not {split}."
        raise RuntimeError(msg)
    dataset = datasets.CIFAR10(data_path, train=train, transform=transform, download=True)
    print(f"Loaded CIFAR-10 {split} set from {data_path}")
    return dataset
def loadCIFAR ( root = '../..' , split = 'train' ) : data_path = os . path . join ( root , 'data' ) if split == 'train' : transform = T . Compose ( [ T . RandomCrop ( 32 , padding = 4 ) , T . RandomHorizontalFlip ( ) , T . ToTensor ( ) , T . Normalize ( ( 0.4914 , 0.4822 , 0.4465 ) , ( 0.2023 , 0.1994 , 0.2010 ) ) , ] ) train = True elif split == 'val' : transform = T . Compose ( [ T . ToTensor ( ) , T . Normalize ( ( 0.4914 , 0.4822 , 0.4465 ) , ( 0.2023 , 0.1994 , 0.2010 ) ) , ] ) train = False else : msg = f"Split must be train or val, not {split}." raise RuntimeError ( msg ) dataset = datasets . CIFAR10 ( data_path , train = train , transform = transform , download = True ) print ( f"Loaded CIFAR-10 {split} set from {data_path}" ) return dataset
Loads and preprocesses the CIFAR-10 dataset.
Loads and preprocesses the CIFAR - 10 dataset .
"""
    Loads and preprocesses the CIFAR-10 dataset.
    Params:
        - root (str): root directory where the data directory is located.
        - split (str): takes values 'train' and 'val'.
    """
root
split
- root
root directory where the data directory is located.
root directory where the data directory is located .
- split
takes values 'train' and 'val'.
takes values ' train ' and ' val ' .