Face Detection(人脸检测)#

fastdeploy.vision.facedet.RetinaFace#

class fastdeploy.vision.facedet.RetinaFace(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#

Load a RetinaFace model exported by RetinaFace.

Parameters
  • model_file – (str)Path of model file, e.g ./retinaface.onnx

  • params_file – (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string

  • runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU

  • model_format – (fastdeploy.ModelForamt)Model format of the loaded model

property downsample_strides#

Argument for image postprocessing step, downsample strides (namely, steps) for RetinaFace to generate anchors, will take (8,16,32) as default values

get_profile_time()#

Get profile time of Runtime after the profile process is done.

property landmarks_per_face#

Argument for image postprocessing step, landmarks_per_face, default 5 in RetinaFace

property min_sizes#

Argument for image postprocessing step, min sizes, width and height for each anchor, default min_sizes = [[16, 32], [64, 128], [256, 512]]

predict(input_image, conf_threshold=0.7, nms_iou_threshold=0.3)[source]#

Detect the location and key points of human faces from an input image

Parameters
  • input_image – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format

  • conf_threshold – confidence threashold for postprocessing, default is 0.7

  • nms_iou_threshold – iou threashold for NMS, default is 0.3

Returns

FaceDetectionResult

property size#

Argument for image preprocessing step, the preprocess image size, tuple of (width, height), default (640, 640)

property variance#

Argument for image postprocessing step, variance in RetinaFace’s prior-box(anchor) generate process, default (0.1, 0.2)

fastdeploy.vision.facedet.SCRFD#

class fastdeploy.vision.facedet.SCRFD(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#

Load a SCRFD model exported by SCRFD.

Parameters
  • model_file – (str)Path of model file, e.g ./scrfd.onnx

  • params_file – (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string

  • runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU

  • model_format – (fastdeploy.ModelForamt)Model format of the loaded model

disable_normalize()[source]#

This function will disable normalize in preprocessing step.

disable_permute()[source]#

This function will disable hwc2chw in preprocessing step.

property downsample_strides#

Argument for image postprocessing step, downsample strides (namely, steps) for SCRFD to generate anchors, will take (8,16,32) as default values

get_profile_time()#

Get profile time of Runtime after the profile process is done.

property landmarks_per_face#

Argument for image postprocessing step, landmarks_per_face, default 5 in SCRFD

property max_nms#

Argument for image postprocessing step, the upperbond number of boxes processed by nms, default 30000

property num_anchors#

Argument for image postprocessing step, anchor number of each stride, default 2

predict(input_image, conf_threshold=0.7, nms_iou_threshold=0.3)[source]#

Detect the location and key points of human faces from an input image

Parameters
  • input_image – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format

  • conf_threshold – confidence threashold for postprocessing, default is 0.7

  • nms_iou_threshold – iou threashold for NMS, default is 0.3

Returns

FaceDetectionResult

property size#

Argument for image preprocessing step, the preprocess image size, tuple of (width, height), default (640, 640)

property use_kps#

Argument for image postprocessing step, the outputs of onnx file with key points features or not, default true

fastdeploy.vision.facedet.UltraFace#

class fastdeploy.vision.facedet.UltraFace(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#

Load a UltraFace model exported by UltraFace.

Parameters
  • model_file – (str)Path of model file, e.g ./ultraface.onnx

  • params_file – (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string

  • runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU

  • model_format – (fastdeploy.ModelForamt)Model format of the loaded model

get_profile_time()#

Get profile time of Runtime after the profile process is done.

predict(input_image, conf_threshold=0.7, nms_iou_threshold=0.3)[source]#

Detect the location and key points of human faces from an input image

Parameters
  • input_image – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format

  • conf_threshold – confidence threashold for postprocessing, default is 0.7

  • nms_iou_threshold – iou threashold for NMS, default is 0.3

Returns

FaceDetectionResult

property size#

Argument for image preprocessing step, the preprocess image size, tuple of (width, height), default (320, 240)

fastdeploy.vision.facedet.YOLOv5Face#

class fastdeploy.vision.facedet.YOLOv5Face(model_file, params_file='', runtime_option=None, model_format=<ModelFormat.ONNX: 2>)[source]#

Load a YOLOv5Face model exported by YOLOv5Face.

Parameters
  • model_file – (str)Path of model file, e.g ./yolov5face.onnx

  • params_file – (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string

  • runtime_option – (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it’s None, will use the default backend on CPU

  • model_format – (fastdeploy.ModelForamt)Model format of the loaded model

get_profile_time()#

Get profile time of Runtime after the profile process is done.

property landmarks_per_face#

Argument for image postprocessing step, landmarks_per_face, default 5 in YOLOv5Face

predict(input_image, conf_threshold=0.25, nms_iou_threshold=0.5)[source]#

Detect the location and key points of human faces from an input image

Parameters
  • input_image – (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format

  • conf_threshold – confidence threashold for postprocessing, default is 0.25

  • nms_iou_threshold – iou threashold for NMS, default is 0.5

Returns

FaceDetectionResult

property size#

Argument for image preprocessing step, the preprocess image size, tuple of (width, height), default size = [640,640]