diff --git a/consts.py b/consts.py index d138792..d4fe743 100644 --- a/consts.py +++ b/consts.py @@ -4,7 +4,7 @@ import torchvision.transforms as transforms CIFAR_DIR = Path('Data/CIFAR10') CIFAR_DIR.mkdir(exist_ok = True) - +#you can add more and bump the numbers even more up normalize = transforms.Compose([ transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)) diff --git a/dataset.py b/dataset.py index 552aedb..8c4fdb4 100644 --- a/dataset.py +++ b/dataset.py @@ -1,20 +1,26 @@ import torchvision -from consts import CIFAR_DIR +from consts import TRAIN_DATA +import torchvision.transforms as transforms +from dogs_cats_ds import DogCatDataset +import random #optional transformations: # https://pytorch.org/vision/0.11/transforms.html #training data using torchvision cifar. -cifar_data_train = torchvision.datasets.CIFAR10(root = CIFAR_DIR, train = True, transform = None, download = True) - #example of cifar data sample. It is an image, class example. -# here, the image is the image (PIL, or pillow) and the corresponding label, frog. I've chopped the dataset to only include cats -# and dogs, so we can apply a different form of classification so it's easier to perform -example_data = cifar_data_train[0] -print(f'items in an instance of cifar10: {len(example_data)}') -example_data[0].show() +# here, the image is the image (PIL, or pillow) and the corresponding label. I've chopped the dataset to only include cats +# and dogs, so we can apply a different form of classification so +r = random.randint(1, len(DogCatDataset(TRAIN_DATA))) +# print(r) +example_data = DogCatDataset(TRAIN_DATA)[r] + +print(f'items in an instance of the dataset: {len(example_data)}') print(f'class corresponding to image: {example_data[1]}') +sample_img = torchvision.transforms.functional.to_pil_image(example_data[0]) +sample_img = sample_img.resize((224,224)) +sample_img.show()