Pages
<aside>
Home | Model Architechture | Model Training | Datasets | Data Preprocessing | Libraries | Training Analysis | Full Code Breakdown
</aside>
DATA PREPROCESSING USED
<aside>
There is a total of 500 images in train folder and 100 images in test folder. For this experiment, we have 5 different classes, which means each class will have 100 train images and 10 test images.
All the images have been resized to 128x128 to save time and resources.
Below is the processing for the train model:
transform = transforms.Compose([
transforms.RandomHorizontalFlip(),
transforms.RandomAffine(30, fill=0),
transforms.RandomVerticalFlip(),
transforms.RandomRotation(30),
transforms.ColorJitter(brightness=0.3, contrast=0.3, saturation=0.3, hue=0.2),
transforms.GaussianBlur(kernel_size=(5, 5), sigma=(0.1, 2.0)),
transforms.RandomGrayscale(p=0.2),
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
Below is the processing for the test model:
transform_test = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
])
</aside>
EXPLAINATION
<aside>
RandomHorizontalFlip()
- Flip the image on the horizontal axis randomly.
- Encourages the model to learn features invariant to horizontal orientation, enhancing robustness to mirrored inputs.
RandomAffine()
- Introduces variations like rotation and translation, helping the model generalize better to spatial transformations.
RandomVerticalFlip()
- Flip the image on the vertical axis randomly.
- Making the model robust to vertical orientation changes.
RandomRotation()
- Randomly rotate the image.
- Enabling the model to handle inputs with different orientations
ColorJitter()
- Randomly adjusts image brightness, contrast, saturation, and hue.
- Simulates varying lighting conditions, improving the model's ability to generalize to diverse real-world scenarios.
GaussianBlur()
- Randomly apply a blur on the image.
- Reduces sensitivity to noise and enhances robustness by simulating blurred images.
RandomGrayscale()
- Randomly apply a grayscale filter on the image.
- Trains the model to perform well even with limited color information, useful for tasks where color is less critical.
ToTensor()
- Converts the image from a PIL format (or NumPy array) to a PyTorch tensor.
- Enabling tensor operations for efficient processing.
Normalize()
- Normalize the tensor.
- Ensures faster convergence and numerical stability during training by standardizing pixel values.
</aside>