COVID-19: Face Mask Detection using YOLOv5
Step №3: Prepare and import your custom dataset

For this project I am using a dataset that I found on Kaggle, unfortunatly the annotations must be in a YOLO file .txt format which isn’t the case in this dataset.

If your annotations are written in the Pascal VOC file .xml format as seen below, it needs to be changed to the YOLO annotation format.

<annotation>

<folder>images</folder>

<filename>maksssksksss4.png</filename>

<size>

<width>301</width>

<height>400</height>

<depth>3</depth>

</size>

<segmented>0</segmented>

<object>

<name>with_mask</name>

<pose>Unspecified</pose>

<truncated>0</truncated>

<occluded>0</occluded>

<difficult>0</difficult>

<bndbox>

<xmin>70</xmin>

<ymin>185</ymin>

<xmax>176</xmax>

<ymax>321</ymax>

</bndbox>

</object>

</annotation>

In order to fix this problem, a simple python script does the trick

If you are using your own dataset, clone my Github repository, move your labels .xml and images to the xml folder and images folder. Make sure to delete the train.txt , validate.txt and test.txt files and process the data by running this command on your terminal:

python data_processing.py

The YOLO annotation format:

<class-name> <center-x> <center-y> <width> <height>

Sample label:

1 0.4053156146179402 0.63 0.35215946843853824 0.34

We then need to import our dataset to the notebook, if you are using my dataset you can just clone the Github repository:

!git clone https://github.com/iAmEthanMai/mask-detection-dataset.git

If you are using your own data, upload your local folder in the Colab file system.
['Ethan Mai']
['Machine Learning', 'Object Detection', 'Data Science', 'Covid 19', 'AI']