medusa.detect.scrfd
#
SCRFD face detection model adapted from the insightface implementation. All numpy code has been converted to torch, speeding it up considerably (especially with GPU and large batch size). Please cite the corresponding paper [1] from the people at insightface if you use this implementation.
Also, lease see the LICENSE file in the current directory for the license that is applicable to this implementation.
Module Contents#
- class medusa.detect.scrfd.SCRFDetector(det_size=(224, 224), det_threshold=0.3, nms_threshold=0.3, device=DEVICE)[source]#
Face detection model based on the
insightface
package.- Parameters:
det_size (tuple) – Size to which the input image(s) will be resized before passing it to the detection model; should be a tuple with two of the same integers (indicating a square image); higher values are more accurate but slower; default is (224, 224)
det_threshold (float) – Detection threshold (higher = more conservative); detections with confidence values lower than
det_threshold
are discardednms_threshold (float) – Non-maximum suppression threshold for predicted bounding boxes
device (str) – Either ‘cuda’ (GPU) or ‘cpu’
Examples
To crop an image to be used for MICA reconstruction:
>>> from medusa.data import get_example_image >>> det_model = SCRFDetector() >>> img = get_example_image() # path to jpg image >>> det_results = det_model(img) >>> list(det_results.keys()) ['img_idx', 'conf', 'lms', 'bbox', 'n_img']