Lightweight human detection models generated on high-quality human data sets. It can detect objects with high accuracy.
output_human_with_wheelchair.mp4
-
Python 3.10
-
onnx 1.14.1+
-
onnxruntime-gpu v1.16.1 (TensorRT Execution Provider Enabled Binary. See: onnxruntime-gpu v1.16.1 + CUDA 11.8 + TensorRT 8.5.3 build (RTX3070))
-
opencv-contrib-python 4.9.0.80
-
numpy 1.24.3
-
TensorRT 8.5.3-1+cuda11.8
# Common ############################################ pip install opencv-contrib-python numpy onnx # For ONNX ########################################## pip uninstall onnxruntime onnxruntime-gpu pip install onnxruntime or pip install onnxruntime-gpu
-
Demonstration of models with built-in post-processing (Float32/Float16)
usage: demo_yolox_onnx_humanwithwheelchair.py \ [-h] \ [-m MODEL] \ (-v VIDEO | -i IMAGES_DIR) \ [-ep {cpu,cuda,tensorrt}] \ [-dvw] \ [-dwk] options: -h, --help show this help message and exit -m MODEL, --model MODEL ONNX/TFLite file path for YOLOX. -v VIDEO, --video VIDEO Video file path or camera index. -i IMAGES_DIR, --images_dir IMAGES_DIR jpg, png images folder path. -ep {cpu,cuda,tensorrt}, \ --execution_provider {cpu,cuda,tensorrt} Execution provider for ONNXRuntime. -dvw, --disable_video_writer Disable video writer. Eliminates the file I/O load associated with automatic recording to MP4. Devices that use a MicroSD card or similar for main storage can speed up overall processing. -dwk, --disable_waitKey Disable cv2.waitKey(). When you want to process a batch of still images, disable key-input wait and process them continuously.
-
YOLOX-Body-With-Wheelchair - Nano
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.763 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.983 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.934 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.344 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.768 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.634 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.794 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.794 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.700 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.795 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 76.334 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 79.375 |
-
YOLOX-Body-With-Wheelchair - Tiny
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.763 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.971 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.931 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.600 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.769 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.647 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.809 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.809 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.600 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.813 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 76.307 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 80.938 |
-
YOLOX-Body-With-Wheelchair - S
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.822 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.991 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.972 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.250 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.828 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.694 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.853 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.853 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.500 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.859 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 82.183 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 85.312 |
-
YOLOX-Body-With-Wheelchair - M
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.877 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.995 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.956 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.700 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.879 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.706 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.900 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.900 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.700 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.903 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 87.668 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 90.000 |
-
YOLOX-Body-With-Wheelchair - L
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.882 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.997 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.978 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.600 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.885 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.731 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.898 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.898 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.600 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.903 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 88.160 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 89.844 |
-
YOLOX-Body-With-Wheelchair - X
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.924 Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.997 Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.997 Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.700 Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.928 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.750 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.934 Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.934 Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = -1.000 Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.700 Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.938 per class AP: | class | AP | |:---------------------|:-------| | body-with-wheelchair | 92.407 | per class AR: | class | AR | |:---------------------|:-------| | body-with-wheelchair | 93.438 |
-
Post-Process
Because I add my own post-processing to the end of the model, which can be inferred by TensorRT, CUDA, and CPU, the benchmarked inference speed is the end-to-end processing speed including all pre-processing and post-processing. EfficientNMS in TensorRT is very slow and should be offloaded to the CPU.
-
NMS default parameter
param value note max_output_boxes_per_class 20 Maximum number of outputs per class of one type. 20
indicates that the maximum number of people detected is20
, the maximum number of heads detected is20
, and the maximum number of hands detected is20
. The larger the number, the more people can be detected, but the inference speed slows down slightly due to the larger overhead of NMS processing by the CPU. In addition, as the number of elements in the final output tensor increases, the amount of information transferred between hardware increases, resulting in higher transfer costs on the hardware circuit. Therefore, it would be desirable to set the numerical size to the minimum necessary.iou_threshold 0.40 A value indicating the percentage of occlusion allowed for multiple bounding boxes of the same class. 0.40
is excluded from the detection results if, for example, two bounding boxes overlap in more than 41% of the area. The smaller the value, the more occlusion is tolerated, but over-detection may increase.score_threshold 0.25 Bounding box confidence threshold. Specify in the range of 0.00
to1.00
. The larger the value, the stricter the filtering and the lower the NMS processing load, but in exchange, all but bounding boxes with high confidence values are excluded from detection. This is a parameter that has a very large percentage impact on NMS overhead. -
Change NMS parameters
Use PINTO0309/sam4onnx to rewrite the
NonMaxSuppression
parameter in the ONNX file.For example,
pip install onnxsim==0.4.33 \ && pip install -U simple-onnx-processing-tools \ && pip install -U onnx \ && python -m pip install -U onnx_graphsurgeon \ --index-url https://pypi.ngc.nvidia.com ### max_output_boxes_per_class ### Example of changing the maximum number of detections per class to 100. sam4onnx \ --op_name main01_nonmaxsuppression11 \ --input_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --output_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --input_constants main01_max_output_boxes_per_class int64 [100] ### iou_threshold ### Example of changing the allowable area of occlusion to 20%. sam4onnx \ --op_name main01_nonmaxsuppression11 \ --input_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --output_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --input_constants main01_iou_threshold float32 [0.20] ### score_threshold ### Example of changing the bounding box score threshold to 15%. sam4onnx \ --op_name main01_nonmaxsuppression11 \ --input_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --output_onnx_file_path yolox_s_body_head_hand_post_0299_0.4983_1x3x256x320.onnx \ --input_constants main01_score_threshold float32 [0.15]
-
Post-processing structure
PyTorch alone cannot generate this post-processing.
-
-
INT8 quantization (TexasInstruments/YOLOX-ti-lite)
In my experience, YOLOX has a very large accuracy degradation during quantization due to its structure. The reasons for this and the workaround are examined in detail by TexasInstruments. I have summarized the main points below on how to minimize accuracy degradation during quantization through my own practice. I just put into practice what TexasInstruments suggested, but the degrade in accuracy during quantization was extremely small. Note, however, that the results of the Float16 mixed-precision training before quantization are significantly degraded in accuracy due to the change in activation function to
ReLU
and many other workarounds, as well as the completely different data sets being benchmarked.
If this work has contributed in any way to your research or business, I would be happy to be cited in your literature.
@software{YOLOX-Body-With-Wheelchair,
author={Katsuya Hyodo},
title={Lightweight human detection models generated on high-quality human data sets. It can detect objects with high accuracy.},
url={https://github.com/PINTO0309/PINTO_model_zoo/tree/main/446_YOLOX-Body-With-Wheelchair},
year={2024},
month={2},
doi={10.5281/zenodo.10229410}
}
I am very grateful for their excellent work.
-
COCO-Hand
https://vision.cs.stonybrook.edu/~supreeth/
@article{Hand-CNN, title={Contextual Attention for Hand Detection in the Wild}, author={Supreeth Narasimhaswamy and Zhengwei Wei and Yang Wang and Justin Zhang and Minh Hoai}, booktitle={International Conference on Computer Vision (ICCV)}, year={2019}, url={https://arxiv.org/pdf/1904.04882.pdf} }
-
CD-COCO: Complex Distorted COCO database for Scene-Context-Aware computer vision
@INPROCEEDINGS{10323035, author={Beghdadi, Ayman and Beghdadi, Azeddine and Mallem, Malik and Beji, Lotfi and Cheikh, Faouzi Alaya}, booktitle={2023 11th European Workshop on Visual Information Processing (EUVIP)}, title={CD-COCO: A Versatile Complex Distorted COCO Database for Scene-Context-Aware Computer Vision}, year={2023}, volume={}, number={}, pages={1-6}, doi={10.1109/EUVIP58404.2023.10323035} }
-
YOLOX
https://github.com/Megvii-BaseDetection/YOLOX
@article{yolox2021, title={YOLOX: Exceeding YOLO Series in 2021}, author={Ge, Zheng and Liu, Songtao and Wang, Feng and Li, Zeming and Sun, Jian}, journal={arXiv preprint arXiv:2107.08430}, year={2021} }
-
YOLOX-ti-lite
-
yolox-ti-lite_tflite
-
YOLOX-Colaboratory-Training-Sample
高橋かずひと https://github.com/Kazuhito00
https://github.com/Kazuhito00/YOLOX-Colaboratory-Training-Sample