How I built a Face Mask Detector for COVID-19 using PyTorch Lightning
Our dataset is imbalanced (5,000 masked faces VS 90,000 non-masked faces). Therefore, when splitting the dataset into train/validation, we need to keep the same proportions of the samples in train/validation as the whole dataset. We do that by using the train_test_split function of sklearn and we pass the dataset's labels to its stratisfy parameter, and it will do the rest for us. We're going to use 70% of the dataset for training and 30% for validation: When dealing with unbalanced data, we need to pass this information to the loss function to avoid unproportioned step sizes of the optimizer. We do this by assigning a weight to each class, according to its representability in the dataset.
Nov-25-2020, 14:51:04 GMT
- Industry:
- Technology: