Unverified Commit 2696218e authored by narugo1992's avatar narugo1992 Committed by GitHub
Browse files

Merge pull request #25 from deepghs/dev/face

dev(narugo): use face detect v1.4
parents ca7127d5 27b493b7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@ class FaceDetectBenchmark(BaseBenchmark):
if __name__ == '__main__':
    create_plot_cli(
        [
            ('face v1.4 (yolov8s)', FaceDetectBenchmark('s', 'v1.4')),
            ('face v1.4 (yolov8n)', FaceDetectBenchmark('n', 'v1.4')),
            ('face v1.3 (yolov8s)', FaceDetectBenchmark('s', 'v1.3')),
            ('face v1.3 (yolov8n)', FaceDetectBenchmark('n', 'v1.3')),
            ('face v1 (yolov8s)', FaceDetectBenchmark('s', 'v1')),
+596 −459

File changed.

Preview size limit exceeded, changes collapsed.

+13 −13

File changed.

Preview size limit exceeded, changes collapsed.

+4 −3
Original line number Diff line number Diff line
@@ -28,14 +28,14 @@ from ..utils import open_onnx_model


@lru_cache()
def _open_face_detect_model(level: str = 's', version: str = 'v1.3'):
def _open_face_detect_model(level: str = 's', version: str = 'v1.4'):
    return open_onnx_model(hf_hub_download(
        f'deepghs/anime_face_detection',
        f'face_detect_{version}_{level}/model.onnx'
    ))


def detect_faces(image: ImageTyping, level: str = 's', version: str = 'v1.3', max_infer_size=640,
def detect_faces(image: ImageTyping, level: str = 's', version: str = 'v1.4', max_infer_size=640,
                 conf_threshold: float = 0.25, iou_threshold: float = 0.7) \
        -> List[Tuple[Tuple[int, int, int, int], str, float]]:
    """
@@ -46,7 +46,8 @@ def detect_faces(image: ImageTyping, level: str = 's', version: str = 'v1.3', ma
    :param level: The model level being used can be either `s` or `n`.
        The `n` model runs faster with smaller system overface, while the `s` model achieves higher accuracy.
        The default value is `s`.
    :param version: Version of model, default is ``v1.3``. Available versions are ``v0``, ``v1`` and ``v1.3``.
    :param version: Version of model, default is ``v1.4``.
        Available versions are ``v0``, ``v1``, ``v1.3`` and ``v1.4``.
    :param max_infer_size: The maximum image size used for model inference, if the image size exceeds this limit,
        the image will be resized and used for inference. The default value is `640` pixels.
    :param conf_threshold: The confidence threshold, only detection results with confidence scores above
+4 −4
Original line number Diff line number Diff line
@@ -24,10 +24,10 @@ class TestDetectHead:
            values.append((bbox, int(score * 1000) / 1000))

        assert values == pytest.approx([
            ((966, 141, 1084, 261), 0.852),
            ((247, 206, 330, 287), 0.799),
            ((479, 282, 523, 327), 0.689),
            ((662, 465, 705, 513), 0.681),
            ((967, 143, 1084, 261), 0.851),
            ((246, 208, 331, 287), 0.81),
            ((662, 466, 705, 514), 0.733),
            ((479, 283, 523, 326), 0.72),
        ])

    def test_detect_faces_none(self):