- Arising it when there is a significant difference between the number of positive samples (foreground objects) and negative samples (background) in the dataset
- This can lead to the model being biased towards the majority class and perform poorly on the minority class
- Class imbalance problem in one-stage detector is more severe than in two-stage detector because it performs dense sampling method that densely traverses and samples the entire image without region proposal process
- Loss function to deal with class imbalance problem in one-stage
- The form of adding a dynamic scaling factor that changes according to the class to the cross entropy loss
- Automatically down-weight the contribution of easy examples during learning, and increase the weight on hard examples
- Modify RetinaNet code in pytorch-retinanet official repository to build RetinaNet object detector optimized to human detection (fine-tuning the model using CrowdHuman dataset)
- Inference results of CrowdHuman (left: gt, right: predicted)
${ROOT}
| |-- train.py
| |-- csv_validation.py
| |-- build_annotations_file.py
| |-- ...
| |-- class_names
| | | |-- coco_names_with_head.txt
| | | |-- coco_names_with_head.csv (Build csv files of class mappings by running python build_class_mapping_file.py)
| |-- weights
| | | |-- coco_resnet_50_map_0_335_state_dict.pt
| |-- data
| | | |-- CrowdHuman
| | | | | |-- CrowdHuman_train01
| | | | | |-- CrowdHuman_train02
| | | | | |-- CrowdHuman_train03
| | | | | |-- CrowdHuman_val
| | | | | |-- CrowdHuman_test
| | | | | |-- annotation_train.odgt
| | | | | |-- annotation_val.odgt
| | | | | |-- train_annotations.csv (Build csv files of annotations by running python build_annotations_file.py)
| | | | | |-- valid_annotations.csv (Build csv files of annotations by running python build_annotations_file.py)
| | | |-- COCO2017
| | | | | |-- images
| | | | | |-- labels
| | | | | |-- train2017.txt
| | | | | |-- val2017.txt
| | | | | |-- test-dev2017.txt
https://www.crowdhuman.org/download.html
python build_class_mapping_file.py --class_names_txt ./class_names/coco_names_with_head.txt --class_names_csv ./class_names/coco_names_with_head.csv
python build_annotations_file.py --dataset crowd_human
docker pull qbxlvnf11docker/retinanet_env
nvidia-docker run -it --gpus all --name retinanet_env --shm-size=64G -p 8844:8844 -e GRANT_SUDO=yes --user root -v {retinanet_folder}:/workspace/retinanet -w /workspace/retinanet qbxlvnf11docker/retinanet_env bash
- Train COCO
python train.py \
--dataset coco \
--coco_path ./data/COCO2017 \
--depth {18, 34, 50, 101, 152}
- Train CrowdHuman
python train.py \
--dataset csv \
--csv_classes ./class_names/coco_names_with_head.csv \
--csv_train ./data/CrowdHuman/train_annotations.csv \
--csv_val ./data/CrowdHuman/valid_annotations.csv \
--depth {18, 34, 50, 101, 152}
- Fine-tune CrowdHuman
python train.py \
--dataset csv \
--csv_classes ./class_names/coco_names_with_head.csv \
--csv_train ./data/CrowdHuman/train_annotations.csv \
--csv_val ./data/CrowdHuman/valid_annotations.csv \
--start_epoch 0 \
--depth 50 \
--model_path ./weights/coco_resnet_50_map_0_335_state_dict.pt
- Valid COCO
python coco_validation.py \
--coco_path ./data/COCO2017 \
--model_path ./weights/coco_resnet_50_map_0_335_state_dict.pt
- Valid CrowdHuman
python csv_validation.py \
--csv_classes ./class_names/coco_names_with_head.csv \
--csv_val ./data/CrowdHuman/valid_annotations.csv \
--model_path {pretrained_weights_path}
- Visualization COCO
python visualize.py \
--dataset coco \
--coco_path ./data/COCO2017 \
--model ./weights/coco_resnet_50_map_0_335_state_dict.pt
- Visualization CrowdHuman
python visualize.py \
--dataset csv \
--csv_classes ./class_names/coco_names_with_head.csv \
--csv_val ./data/CrowdHuman/valid_annotations.csv \
--model_path {pretrained_weights_path}
https://github.com/yhenon/pytorch-retinanet