Yuantao Feng commited on
Commit
a524e9b
·
1 Parent(s): fb84dfb

Update ONNX opset version of YuNet to 11 for quantization (#34)

Browse files

* update ONNX opset version of YuNet to 11 for quantization

* fix corruption when face detection results is none

Files changed (1) hide show
  1. demo.py +2 -2
demo.py CHANGED
@@ -21,7 +21,7 @@ def str2bool(v):
21
 
22
  parser = argparse.ArgumentParser(description='YuNet: A Fast and Accurate CNN-based Face Detector (https://github.com/ShiqiYu/libfacedetection).')
23
  parser.add_argument('--input', '-i', type=str, help='Path to the input image. Omit for using default camera.')
24
- parser.add_argument('--model', '-m', type=str, default='face_detection_yunet_2021sep.onnx', help='Path to the model.')
25
  parser.add_argument('--conf_threshold', type=float, default=0.9, help='Filter out faces of confidence < conf_threshold.')
26
  parser.add_argument('--nms_threshold', type=float, default=0.3, help='Suppress bounding boxes of iou >= nms_threshold.')
27
  parser.add_argument('--top_k', type=int, default=5000, help='Keep top_k bounding boxes before NMS.')
@@ -42,7 +42,7 @@ def visualize(image, results, box_color=(0, 255, 0), text_color=(0, 0, 255), fps
42
  if fps is not None:
43
  cv.putText(output, 'FPS: {:.2f}'.format(fps), (0, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, text_color)
44
 
45
- for det in results:
46
  bbox = det[0:4].astype(np.int32)
47
  cv.rectangle(output, (bbox[0], bbox[1]), (bbox[0]+bbox[2], bbox[1]+bbox[3]), box_color, 2)
48
 
 
21
 
22
  parser = argparse.ArgumentParser(description='YuNet: A Fast and Accurate CNN-based Face Detector (https://github.com/ShiqiYu/libfacedetection).')
23
  parser.add_argument('--input', '-i', type=str, help='Path to the input image. Omit for using default camera.')
24
+ parser.add_argument('--model', '-m', type=str, default='face_detection_yunet_2021dec.onnx', help='Path to the model.')
25
  parser.add_argument('--conf_threshold', type=float, default=0.9, help='Filter out faces of confidence < conf_threshold.')
26
  parser.add_argument('--nms_threshold', type=float, default=0.3, help='Suppress bounding boxes of iou >= nms_threshold.')
27
  parser.add_argument('--top_k', type=int, default=5000, help='Keep top_k bounding boxes before NMS.')
 
42
  if fps is not None:
43
  cv.putText(output, 'FPS: {:.2f}'.format(fps), (0, 15), cv.FONT_HERSHEY_SIMPLEX, 0.5, text_color)
44
 
45
+ for det in (results if results is not None else []):
46
  bbox = det[0:4].astype(np.int32)
47
  cv.rectangle(output, (bbox[0], bbox[1]), (bbox[0]+bbox[2], bbox[1]+bbox[3]), box_color, 2)
48