Dataset analysis ¶
dataset_analysis.py
analyzes the distribution of the classes and labels of a dataset in YOLO Darknet format. Use it before creating the
.tfs
files, to choose the maximum number of faces per image. It is located in
face_detection/datasets/dataset_analysis.
Configure the analysis ¶
Edit dataset_config.yaml:
dataset:
dataset_name: wider_face # Used in the names of the histogram files
dataset_path: <dataset-directory> # Folder of .jpg images and .txt labels
settings:
max_detections: 40
max_percentage_filtered: 1.5
dataset_pathis a folder that contains the.jpgimages and the YOLO Darknet.txtlabel files, without sub-folders.max_detectionsis optional. The tool outputs the percentage of the images that have more than this number of faces.max_percentage_filteredis optional. The tool outputs the smallest maximum number of faces per image for which at most this percentage of the images would be discarded.
Run the analysis ¶
Run the script from its folder:
python dataset_analysis.py
To use a configuration file located elsewhere, for example from
face_detection/datasets:
python dataset_analysis/dataset_analysis.py --config-path ./dataset_analysis/ --config-name dataset_config.yaml
The tool prints the number of images and label files, the statistics of the number of labels per image, the number of classes, and the number of occurrences of each class. It then displays two histograms and saves them in a
histograms
folder of the current directory, as
classes_stats_<dataset_name>.png
and
labels_stats_<dataset_name>.png. Close each histogram window to continue.
Use the values reported for
max_detections
and
max_percentage_filtered
as the
max_detections
setting of the
dataset create TFS
tool, to discard the images that contain too many faces.