Satyam Goyal commited on
Commit
84680ed
·
1 Parent(s): 874f143

Merge pull request #95 from Satgoy152:adding-doc

Browse files

Improved help messages for demo programs (#95)
- Added Demo Documentation
- Updated help messages
- Changed exception link

Files changed (2) hide show
  1. README.md +7 -2
  2. demo.py +9 -9
README.md CHANGED
@@ -3,14 +3,15 @@
3
  YuNet is a light-weight, fast and accurate face detection model, which achieves 0.834(AP_easy), 0.824(AP_medium), 0.708(AP_hard) on the WIDER Face validation set.
4
 
5
  Notes:
 
6
  - Model source: [here](https://github.com/ShiqiYu/libfacedetection.train/blob/a61a428929148171b488f024b5d6774f93cdbc13/tasks/task1/onnx/yunet.onnx).
7
  - For details on training this model, please visit https://github.com/ShiqiYu/libfacedetection.train.
8
  - This ONNX model has fixed input shape, but OpenCV DNN infers on the exact shape of input image. See https://github.com/opencv/opencv_zoo/issues/44 for more information.
9
 
10
  Results of accuracy evaluation with [tools/eval](../../tools/eval).
11
 
12
- | Models | Easy AP | Medium AP | Hard AP |
13
- |-------------|---------|-----------|---------|
14
  | YuNet | 0.8498 | 0.8384 | 0.7357 |
15
  | YuNet quant | 0.7751 | 0.8145 | 0.7312 |
16
 
@@ -19,11 +20,15 @@ Results of accuracy evaluation with [tools/eval](../../tools/eval).
19
  ## Demo
20
 
21
  Run the following command to try the demo:
 
22
  ```shell
23
  # detect on camera input
24
  python demo.py
25
  # detect on an image
26
  python demo.py --input /path/to/image
 
 
 
27
  ```
28
 
29
  ### Example outputs
 
3
  YuNet is a light-weight, fast and accurate face detection model, which achieves 0.834(AP_easy), 0.824(AP_medium), 0.708(AP_hard) on the WIDER Face validation set.
4
 
5
  Notes:
6
+
7
  - Model source: [here](https://github.com/ShiqiYu/libfacedetection.train/blob/a61a428929148171b488f024b5d6774f93cdbc13/tasks/task1/onnx/yunet.onnx).
8
  - For details on training this model, please visit https://github.com/ShiqiYu/libfacedetection.train.
9
  - This ONNX model has fixed input shape, but OpenCV DNN infers on the exact shape of input image. See https://github.com/opencv/opencv_zoo/issues/44 for more information.
10
 
11
  Results of accuracy evaluation with [tools/eval](../../tools/eval).
12
 
13
+ | Models | Easy AP | Medium AP | Hard AP |
14
+ | ----------- | ------- | --------- | ------- |
15
  | YuNet | 0.8498 | 0.8384 | 0.7357 |
16
  | YuNet quant | 0.7751 | 0.8145 | 0.7312 |
17
 
 
20
  ## Demo
21
 
22
  Run the following command to try the demo:
23
+
24
  ```shell
25
  # detect on camera input
26
  python demo.py
27
  # detect on an image
28
  python demo.py --input /path/to/image
29
+
30
+ # get help regarding various parameters
31
+ python demo.py --help
32
  ```
33
 
34
  ### Example outputs
demo.py CHANGED
@@ -22,25 +22,25 @@ def str2bool(v):
22
  backends = [cv.dnn.DNN_BACKEND_OPENCV, cv.dnn.DNN_BACKEND_CUDA]
23
  targets = [cv.dnn.DNN_TARGET_CPU, cv.dnn.DNN_TARGET_CUDA, cv.dnn.DNN_TARGET_CUDA_FP16]
24
  help_msg_backends = "Choose one of the computation backends: {:d}: OpenCV implementation (default); {:d}: CUDA"
25
- help_msg_targets = "Chose one of the target computation devices: {:d}: CPU (default); {:d}: CUDA; {:d}: CUDA fp16"
26
  try:
27
  backends += [cv.dnn.DNN_BACKEND_TIMVX]
28
  targets += [cv.dnn.DNN_TARGET_NPU]
29
  help_msg_backends += "; {:d}: TIMVX"
30
  help_msg_targets += "; {:d}: NPU"
31
  except:
32
- print('This version of OpenCV does not support TIM-VX and NPU. Visit https://gist.github.com/fengyuentau/5a7a5ba36328f2b763aea026c43fa45f for more information.')
33
 
34
  parser = argparse.ArgumentParser(description='YuNet: A Fast and Accurate CNN-based Face Detector (https://github.com/ShiqiYu/libfacedetection).')
35
- parser.add_argument('--input', '-i', type=str, help='Path to the input image. Omit for using default camera.')
36
- parser.add_argument('--model', '-m', type=str, default='face_detection_yunet_2022mar.onnx', help='Path to the model.')
37
  parser.add_argument('--backend', '-b', type=int, default=backends[0], help=help_msg_backends.format(*backends))
38
  parser.add_argument('--target', '-t', type=int, default=targets[0], help=help_msg_targets.format(*targets))
39
- parser.add_argument('--conf_threshold', type=float, default=0.9, help='Filter out faces of confidence < conf_threshold.')
40
- parser.add_argument('--nms_threshold', type=float, default=0.3, help='Suppress bounding boxes of iou >= nms_threshold.')
41
- parser.add_argument('--top_k', type=int, default=5000, help='Keep top_k bounding boxes before NMS.')
42
- parser.add_argument('--save', '-s', type=str, default=False, help='Set true to save results. This flag is invalid when using camera.')
43
- parser.add_argument('--vis', '-v', type=str2bool, default=True, help='Set true to open a window for result visualization. This flag is invalid when using camera.')
44
  args = parser.parse_args()
45
 
46
  def visualize(image, results, box_color=(0, 255, 0), text_color=(0, 0, 255), fps=None):
 
22
  backends = [cv.dnn.DNN_BACKEND_OPENCV, cv.dnn.DNN_BACKEND_CUDA]
23
  targets = [cv.dnn.DNN_TARGET_CPU, cv.dnn.DNN_TARGET_CUDA, cv.dnn.DNN_TARGET_CUDA_FP16]
24
  help_msg_backends = "Choose one of the computation backends: {:d}: OpenCV implementation (default); {:d}: CUDA"
25
+ help_msg_targets = "Choose one of the target computation devices: {:d}: CPU (default); {:d}: CUDA; {:d}: CUDA fp16"
26
  try:
27
  backends += [cv.dnn.DNN_BACKEND_TIMVX]
28
  targets += [cv.dnn.DNN_TARGET_NPU]
29
  help_msg_backends += "; {:d}: TIMVX"
30
  help_msg_targets += "; {:d}: NPU"
31
  except:
32
+ print('This version of OpenCV does not support TIM-VX and NPU. Visit https://github.com/opencv/opencv/wiki/TIM-VX-Backend-For-Running-OpenCV-On-NPU for more information.')
33
 
34
  parser = argparse.ArgumentParser(description='YuNet: A Fast and Accurate CNN-based Face Detector (https://github.com/ShiqiYu/libfacedetection).')
35
+ parser.add_argument('--input', '-i', type=str, help='Usage: Set input to a certain image, omit if using camera.')
36
+ parser.add_argument('--model', '-m', type=str, default='face_detection_yunet_2022mar.onnx', help="Usage: Set model type, defaults to 'face_detection_yunet_2022mar.onnx'.")
37
  parser.add_argument('--backend', '-b', type=int, default=backends[0], help=help_msg_backends.format(*backends))
38
  parser.add_argument('--target', '-t', type=int, default=targets[0], help=help_msg_targets.format(*targets))
39
+ parser.add_argument('--conf_threshold', type=float, default=0.9, help='Usage: Set the minimum needed confidence for the model to identify a face, defauts to 0.9. Smaller values may result in faster detection, but will limit accuracy. Filter out faces of confidence < conf_threshold.')
40
+ parser.add_argument('--nms_threshold', type=float, default=0.3, help='Usage: Suppress bounding boxes of iou >= nms_threshold. Default = 0.3.')
41
+ parser.add_argument('--top_k', type=int, default=5000, help='Usage: Keep top_k bounding boxes before NMS.')
42
+ parser.add_argument('--save', '-s', type=str, default=False, help='Usage: Set “True” to save file with results (i.e. bounding box, confidence level). Invalid in case of camera input. Default will be set to “False”.')
43
+ parser.add_argument('--vis', '-v', type=str2bool, default=True, help='Usage: Default will be set to “True” and will open a new window to show results. Set to “False” to stop visualizations from being shown. Invalid in case of camera input.')
44
  args = parser.parse_args()
45
 
46
  def visualize(image, results, box_color=(0, 255, 0), text_color=(0, 0, 255), fps=None):