{"id":18009280,"url":"https://github.com/xlite-dev/scrfd-toolkit","last_synced_at":"2025-10-04T16:44:46.815Z","repository":{"id":103961975,"uuid":"445757338","full_name":"xlite-dev/scrfd-toolkit","owner":"xlite-dev","description":"Super fast accurate face detector ! SCRFD(CVPR 2021) with MNN/TNN/NCNN/ONNXRuntime C++.","archived":false,"fork":false,"pushed_at":"2022-01-12T16:30:54.000Z","size":34059,"stargazers_count":17,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-10T19:57:24.936Z","etag":null,"topics":["mnn","ncnn","onnxruntime","scrfd","tnn"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xlite-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-08T07:47:33.000Z","updated_at":"2025-04-11T09:11:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"afb987ca-e0bf-489f-bb7e-d50e1d4d3230","html_url":"https://github.com/xlite-dev/scrfd-toolkit","commit_stats":null,"previous_names":["xlite-dev/scrfd-toolkit"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xlite-dev/scrfd-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlite-dev%2Fscrfd-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlite-dev%2Fscrfd-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlite-dev%2Fscrfd-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlite-dev%2Fscrfd-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xlite-dev","download_url":"https://codeload.github.com/xlite-dev/scrfd-toolkit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xlite-dev%2Fscrfd-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278343068,"owners_count":25971399,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mnn","ncnn","onnxruntime","scrfd","tnn"],"created_at":"2024-10-30T02:08:59.201Z","updated_at":"2025-10-04T16:44:46.774Z","avatar_url":"https://github.com/xlite-dev.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scrfd.lite.ai.toolkit\n使用 🍅🍅 Lite.AI.ToolKit C++工具箱来跑SCRFD的一些案例(https://github.com/DefTruth/lite.ai.toolkit) , 包含ONNXRuntime C++、MNN、TNN和NCNN版本。\n\n![](resources/scrfd.png)\n\nStar⭐️🌟什么的，就随缘吧~ 🙃🤪🍀\n\n## 2. C++版本源码\n\nSCRFD C++ 版本的源码包含ONNXRuntime、MNN、TNN和NCNN四个版本，源码可以在 [lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) 工具箱中找到。本项目主要介绍如何基于 [lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) 工具箱，直接使用SCRFD来跑人脸检测。需要说明的是，本项目是基于MacOS下编译的 [liblite.ai.toolkit.v0.1.0.dylib](https://github.com/DefTruth/yolox.lite.ai.toolkit/blob/main/lite.ai.toolkit/lib) 来实现的，对于使用MacOS的用户，可以直接下载本项目包含的*liblite.ai.toolkit.v0.1.0*动态库和其他依赖库进行使用。而非MacOS用户，则需要从[lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) 中下载源码进行编译。[lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) c++工具箱目前包含70+流行的开源模型，就不多介绍了，只是平时顺手捏的，整合了自己学习过程中接触到的一些模型，感兴趣的同学可以去看看。\n* [scrfd.cpp](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/ort/cv/scrfd.cpp)\n* [scrfd.h](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/ort/cv/scrfd.h)\n* [mnn_scrfd.cpp](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/mnn/cv/mnn_scrfd.cpp)\n* [mnn_scrfd.h](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/mnn/cv/mnn_scrfd.h)\n* [tnn_scrfd.cpp](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/tnn/cv/tnn_scrfd.cpp)\n* [tnn_scrfd.h](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/tnn/cv/tnn_scrfd.h)\n* [ncnn_scrfd.cpp](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/ncnn/cv/ncnn_scrfd.cpp)\n* [ncnn_scrfd.h](https://github.com/DefTruth/lite.ai.toolkit/blob/main/lite/ncnn/cv/ncnn_scrfd.h)  \n\nONNXRuntime C++、MNN、TNN和NCNN版本的推理实现均已测试通过，欢迎白嫖~  \n\n\n## 3. 模型文件\n\n### 3.1 ONNX模型文件\n可以从我提供的链接下载 ([Baidu Drive](https://pan.baidu.com/s/1elUGcx7CZkkjEoYhTMwTRQ) code: 8gin) , 也可以从本直接仓库下载。\n\n\n|                 Class                 |      Pretrained ONNX Files      |              Rename or Converted From (Repo)              | Size  |\n| :-----------------------------------: | :-----------------------------: | :-------------------------------------------------------: | :---: |  \n| *lite::cv::face::detect::SCRFD* | scrfd_500m_shape160x160.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_500m_shape320x320.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_500m_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape160x160.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape320x320.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_1g_shape160x160.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_1g_shape320x320.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_1g_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_shape160x160.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_shape320x320.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape160x160.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape320x320.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_10g_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_10g_shape1280x1280.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape640x640.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n| *lite::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape1280x1280.onnx | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n\n\n### 3.2 MNN模型文件\nMNN模型文件下载地址，([Baidu Drive](https://pan.baidu.com/s/1KyO-bCYUv6qPq2M8BH_Okg) code: 9v63), 也可以从本直接仓库下载。\n\n|                 Class                 |      Pretrained MNN Files      |              Rename or Converted From (Repo)              | Size  |\n| :-----------------------------------: | :-----------------------------: | :-------------------------------------------------------: | :---: |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_shape160x160.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_shape320x320.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape160x160.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape320x320.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_1g_shape160x160.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_1g_shape320x320.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_1g_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape160x160.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape320x320.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape160x160.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape320x320.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_10g_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_10g_shape1280x1280.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape640x640.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n| *lite::mnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape1280x1280.mnn | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n\n\n### 3.3 TNN模型文件\nTNN模型文件下载地址，([Baidu Drive](https://pan.baidu.com/s/1lvM2YKyUbEc5HKVtqITpcw) code: 6o6k), 也可以从本直接仓库下载。\n\n|                 Class                 |      Pretrained TNN Files      |              Rename or Converted From (Repo)              | Size  |\n| :-----------------------------------: | :-----------------------------: | :-------------------------------------------------------: | :---: |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_shape160x160.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_shape320x320.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape160x160.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape320x320.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_1g_shape160x160.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_1g_shape320x320.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_1g_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape160x160.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape320x320.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape160x160.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape320x320.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_10g_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_10g_shape1280x1280.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape640x640.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n| *lite::tnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape1280x1280.opt.tnnproto\u0026tnnmodel | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n\n\n### 3.4 NCNN模型文件\nNCNN模型文件下载地址，([Baidu Drive](https://pan.baidu.com/s/1hlnqyNsFbMseGFWscgVhgQ) code: sc7f), 也可以从本直接仓库下载。\n\n|                 Class                 |      Pretrained NCNN Files      |              Rename or Converted From (Repo)              | Size  |\n| :-----------------------------------: | :-----------------------------: | :-------------------------------------------------------: | :---: |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_shape160x160.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_shape320x320.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape160x160.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape320x320.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_500m_bnkps_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.5Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_1g_shape160x160.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_1g_shape320x320.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_1g_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 2.7Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape160x160.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape320x320.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape160x160.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape320x320.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_2.5g_bnkps_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 3.3Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_10g_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_10g_shape1280x1280.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |\n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape640x640.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n| *lite::ncnn::cv::face::detect::SCRFD* | scrfd_10g_bnkps_shape1280x1280.opt.param\u0026bin | [SCRFD](https://github.com/deepinsight/insightface/blob/master/detection/scrfd)  | 16.9Mb |  \n\n\n\n## 4. 接口文档\n\n在[lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) 中，SCRFD的实现类为：\n\n```c++\nclass LITE_EXPORTS lite::cv::face::detect::SCRFD;\nclass LITE_EXPORTS lite::mnn::cv::face::detect::SCRFD;\nclass LITE_EXPORTS lite::tnn::cv::face::detect::SCRFD;\nclass LITE_EXPORTS lite::ncnn::cv::face::detect::SCRFD;\n```  \n\n该类型目前包含1公共接口`detect`用于进行目标检测。\n```c++\npublic:\n    /**\n     * @param mat cv::Mat BGR format\n     * @param detected_boxes_kps vector of BoxfWithLandmarks to catch detected boxes and landmarks.\n     * @param score_threshold default 0.25f, only keep the result which \u003e= score_threshold.\n     * @param iou_threshold default 0.45f, iou threshold for NMS.\n     * @param topk default 400, maximum output boxes after NMS.\n     */\n    void detect(const cv::Mat \u0026mat, std::vector\u003ctypes::BoxfWithLandmarks\u003e \u0026detected_boxes_kps,\n                float score_threshold = 0.25f, float iou_threshold = 0.45f,\n                unsigned int topk = 400);\n```\n`detect`接口的输入参数说明：\n* mat: cv::Mat类型，BGR格式。\n* detected_boxes_kps: BoxfWithLandmarks向量，包含被检测到的框box(Boxf)，box中包含x1,y1,x2,y2,label,score等成员; 以及landmarks(landmarks)人脸关键点(5个)，其中包含了points，代表关键点，是一个cv::point2f向量(vector); \n* score_threshold：分类得分（质量得分）阈值，默认0.25，小于该阈值的框将被丢弃。\n* iou_threshold：NMS中的iou阈值，默认0.3。\n* topk：默认400，只保留前k个检测到的结果。\n\n## 5. 使用案例\n这里测试使用的是scrfd_2.5g_bnkps_shape640x640.onnx版本的模型，你可以尝试使用其他版本的模型。\n\n### 5.1 ONNXRuntime版本\n```c++\n#include \"lite/lite.h\"\n\nstatic void test_default()\n{\n    std::string onnx_path = \"../hub/onnx/cv/scrfd_2.5g_bnkps_shape640x640.onnx\";\n    std::string test_img_path = \"../resources/4.jpg\";\n    std::string save_img_path = \"../logs/4.jpg\";\n    \n    auto *scrfd = new lite::cv::face::detect::SCRFD(onnx_path);\n    \n    std::vector\u003clite::types::BoxfWithLandmarks\u003e detected_boxes;\n    cv::Mat img_bgr = cv::imread(test_img_path);\n    scrfd-\u003edetect(img_bgr, detected_boxes, 0.3f);\n    \n    lite::utils::draw_boxes_with_landmarks_inplace(img_bgr, detected_boxes);\n    \n    cv::imwrite(save_img_path, img_bgr);\n    \n    std::cout \u003c\u003c \"Default Version Done! Detected Face Num: \" \u003c\u003c detected_boxes.size() \u003c\u003c std::endl;\n    \n    delete scrfd;\n}\n```  \n\n### 5.2 MNN版本\n```c++\n#include \"lite/lite.h\"\n\nstatic void test_mnn()\n{\n#ifdef ENABLE_MNN\n    std::string mnn_path = \"../hub/mnn/cv/scrfd_2.5g_bnkps_shape640x640.mnn\";\n    std::string test_img_path = \"../resources/12.jpg\";\n    std::string save_img_path = \"../logs/12.jpg\";\n    \n    auto *scrfd = new lite::mnn::cv::face::detect::SCRFD(mnn_path);\n    \n    std::vector\u003clite::types::BoxfWithLandmarks\u003e detected_boxes;\n    cv::Mat img_bgr = cv::imread(test_img_path);\n    scrfd-\u003edetect(img_bgr, detected_boxes, 0.3f);\n    \n    lite::utils::draw_boxes_with_landmarks_inplace(img_bgr, detected_boxes);\n    \n    cv::imwrite(save_img_path, img_bgr);\n    \n    std::cout \u003c\u003c \"MNN Version Done! Detected Face Num: \" \u003c\u003c detected_boxes.size() \u003c\u003c std::endl;\n    \n    delete scrfd;\n#endif\n}\n```  \n\n### 5.3 TNN版本\n```c++\n#include \"lite/lite.h\"\n\nstatic void test_tnn()\n{\n#ifdef ENABLE_TNN\n    std::string proto_path = \"../hub/tnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.tnnproto\";\n    std::string model_path = \"../hub/tnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.tnnmodel\";\n    std::string test_img_path = \"../resources/9.jpg\";\n    std::string save_img_path = \"../logs/9.jpg\";\n    \n    auto *scrfd = new lite::tnn::cv::face::detect::SCRFD(proto_path, model_path);\n    \n    std::vector\u003clite::types::BoxfWithLandmarks\u003e detected_boxes;\n    cv::Mat img_bgr = cv::imread(test_img_path);\n    scrfd-\u003edetect(img_bgr, detected_boxes, 0.3f);\n    \n    lite::utils::draw_boxes_with_landmarks_inplace(img_bgr, detected_boxes);\n    \n    cv::imwrite(save_img_path, img_bgr);\n    \n    std::cout \u003c\u003c \"TNN Version Done! Detected Face Num: \" \u003c\u003c detected_boxes.size() \u003c\u003c std::endl;\n    \n    delete scrfd;\n#endif\n}\n```  \n\n### 5.4 NCNN版本\n```c++\n#include \"lite/lite.h\"\n\nstatic void test_ncnn()\n{\n#ifdef ENABLE_NCNN\n    std::string param_path = \"../hub/ncnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.param\";\n    std::string bin_path = \"../hub/ncnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.bin\";\n    std::string test_img_path = \"../resources/1.jpg\";\n    std::string save_img_path = \"../logs/1.jpg\";\n    \n    auto *scrfd = new lite::ncnn::cv::face::detect::SCRFD(param_path, bin_path, 1, 640, 640);\n    \n    std::vector\u003clite::types::BoxfWithLandmarks\u003e detected_boxes;\n    cv::Mat img_bgr = cv::imread(test_img_path);\n    scrfd-\u003edetect(img_bgr, detected_boxes, 0.3f);\n    \n    lite::utils::draw_boxes_with_landmarks_inplace(img_bgr, detected_boxes);\n    \n    cv::imwrite(save_img_path, img_bgr);\n    \n    std::cout \u003c\u003c \"NCNN Version Done! Detected Face Num: \" \u003c\u003c detected_boxes.size() \u003c\u003c std::endl;\n    \n    delete scrfd;\n#endif\n}\n```  \n\n* 输出结果为:\n  \n![](resources/scrfd.png)\n\n\n## 6. 编译运行\n在MacOS下可以直接编译运行本项目，无需下载其他依赖库。其他系统则需要从[lite.ai.toolkit](https://github.com/DefTruth/lite.ai.toolkit) 中下载源码先编译*lite.ai.toolkit.v0.1.0*动态库。\n```shell\ngit clone --depth=1 https://github.com/DefTruth/scrfd.lite.ai.toolkit.git\ncd scrfd.lite.ai.toolkit \nsh ./build.sh\n```  \n\n* CMakeLists.txt设置\n\n```cmake\ncmake_minimum_required(VERSION 3.17)\nproject(scrfd.lite.ai.toolkit)\n\nset(CMAKE_CXX_STANDARD 11)\n\n# setting up lite.ai.toolkit\nset(LITE_AI_DIR ${CMAKE_SOURCE_DIR}/lite.ai.toolkit)\nset(LITE_AI_INCLUDE_DIR ${LITE_AI_DIR}/include)\nset(LITE_AI_LIBRARY_DIR ${LITE_AI_DIR}/lib)\ninclude_directories(${LITE_AI_INCLUDE_DIR})\nlink_directories(${LITE_AI_LIBRARY_DIR})\n\nset(OpenCV_LIBS\n        opencv_highgui\n        opencv_core\n        opencv_imgcodecs\n        opencv_imgproc\n        opencv_video\n        opencv_videoio\n        )\n# add your executable\nset(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/examples/build)\n\nadd_executable(lite_scrfd examples/test_lite_scrfd.cpp)\ntarget_link_libraries(lite_scrfd\n        lite.ai.toolkit\n        onnxruntime\n        MNN  # need, if built lite.ai.toolkit with ENABLE_MNN=ON,  default OFF\n        ncnn # need, if built lite.ai.toolkit with ENABLE_NCNN=ON, default OFF\n        TNN  # need, if built lite.ai.toolkit with ENABLE_TNN=ON,  default OFF\n        ${OpenCV_LIBS})  # link lite.ai.toolkit \u0026 other libs.\n```\n\n* building \u0026\u0026 testing information:\n```shell\n[ 50%] Building CXX object CMakeFiles/lite_scrfd.dir/examples/test_lite_scrfd.cpp.o\n[100%] Linking CXX executable lite_scrfd\n[100%] Built target lite_scrfd\nTesting Start ...\nLITEORT_DEBUG LogId: ../hub/onnx/cv/scrfd_2.5g_bnkps_shape640x640.onnx\n=============== Input-Dims ==============\ninput_node_dims: 1\ninput_node_dims: 3\ninput_node_dims: 640\ninput_node_dims: 640\n=============== Output-Dims ==============\nOutput: 0 Name: score_8 Dim: 0 :1\nOutput: 0 Name: score_8 Dim: 1 :12800\nOutput: 0 Name: score_8 Dim: 2 :1\nOutput: 1 Name: score_16 Dim: 0 :1\nOutput: 1 Name: score_16 Dim: 1 :3200\nOutput: 1 Name: score_16 Dim: 2 :1\nOutput: 2 Name: score_32 Dim: 0 :1\nOutput: 2 Name: score_32 Dim: 1 :800\nOutput: 2 Name: score_32 Dim: 2 :1\nOutput: 3 Name: bbox_8 Dim: 0 :1\nOutput: 3 Name: bbox_8 Dim: 1 :12800\nOutput: 3 Name: bbox_8 Dim: 2 :4\nOutput: 4 Name: bbox_16 Dim: 0 :1\nOutput: 4 Name: bbox_16 Dim: 1 :3200\nOutput: 4 Name: bbox_16 Dim: 2 :4\nOutput: 5 Name: bbox_32 Dim: 0 :1\nOutput: 5 Name: bbox_32 Dim: 1 :800\nOutput: 5 Name: bbox_32 Dim: 2 :4\nOutput: 6 Name: kps_8 Dim: 0 :1\nOutput: 6 Name: kps_8 Dim: 1 :12800\nOutput: 6 Name: kps_8 Dim: 2 :10\nOutput: 7 Name: kps_16 Dim: 0 :1\nOutput: 7 Name: kps_16 Dim: 1 :3200\nOutput: 7 Name: kps_16 Dim: 2 :10\nOutput: 8 Name: kps_32 Dim: 0 :1\nOutput: 8 Name: kps_32 Dim: 1 :800\nOutput: 8 Name: kps_32 Dim: 2 :10\n========================================\ngenerate_bboxes_kps num: 52\nDefault Version Done! Detected Face Num: 9\nLITEORT_DEBUG LogId: ../hub/onnx/cv/scrfd_2.5g_bnkps_shape640x640.onnx\n=============== Input-Dims ==============\ninput_node_dims: 1\ninput_node_dims: 3\ninput_node_dims: 640\ninput_node_dims: 640\n=============== Output-Dims ==============\nOutput: 0 Name: score_8 Dim: 0 :1\nOutput: 0 Name: score_8 Dim: 1 :12800\nOutput: 0 Name: score_8 Dim: 2 :1\nOutput: 1 Name: score_16 Dim: 0 :1\nOutput: 1 Name: score_16 Dim: 1 :3200\nOutput: 1 Name: score_16 Dim: 2 :1\nOutput: 2 Name: score_32 Dim: 0 :1\nOutput: 2 Name: score_32 Dim: 1 :800\nOutput: 2 Name: score_32 Dim: 2 :1\nOutput: 3 Name: bbox_8 Dim: 0 :1\nOutput: 3 Name: bbox_8 Dim: 1 :12800\nOutput: 3 Name: bbox_8 Dim: 2 :4\nOutput: 4 Name: bbox_16 Dim: 0 :1\nOutput: 4 Name: bbox_16 Dim: 1 :3200\nOutput: 4 Name: bbox_16 Dim: 2 :4\nOutput: 5 Name: bbox_32 Dim: 0 :1\nOutput: 5 Name: bbox_32 Dim: 1 :800\nOutput: 5 Name: bbox_32 Dim: 2 :4\nOutput: 6 Name: kps_8 Dim: 0 :1\nOutput: 6 Name: kps_8 Dim: 1 :12800\nOutput: 6 Name: kps_8 Dim: 2 :10\nOutput: 7 Name: kps_16 Dim: 0 :1\nOutput: 7 Name: kps_16 Dim: 1 :3200\nOutput: 7 Name: kps_16 Dim: 2 :10\nOutput: 8 Name: kps_32 Dim: 0 :1\nOutput: 8 Name: kps_32 Dim: 1 :800\nOutput: 8 Name: kps_32 Dim: 2 :10\n========================================\ngenerate_bboxes_kps num: 138\nONNXRuntime Version Done! Detected Face Num: 23\nLITEMNN_DEBUG LogId: ../hub/mnn/cv/scrfd_2.5g_bnkps_shape640x640.mnn\n=============== Input-Dims ==============\n        **Tensor shape**: 1, 3, 640, 640, \nDimension Type: (CAFFE/PyTorch/ONNX)NCHW\n=============== Output-Dims ==============\ngetSessionOutputAll done!\nOutput: bbox_16:        **Tensor shape**: 1, 3200, 4, \nOutput: bbox_32:        **Tensor shape**: 1, 800, 4, \nOutput: bbox_8:         **Tensor shape**: 1, 12800, 4, \nOutput: kps_16:         **Tensor shape**: 1, 3200, 10, \nOutput: kps_32:         **Tensor shape**: 1, 800, 10, \nOutput: kps_8:  **Tensor shape**: 1, 12800, 10, \nOutput: score_16:       **Tensor shape**: 1, 3200, 1, \nOutput: score_32:       **Tensor shape**: 1, 800, 1, \nOutput: score_8:        **Tensor shape**: 1, 12800, 1, \n========================================\ngenerate_bboxes_kps num: 34\nMNN Version Done! Detected Face Num: 5\nLITENCNN_DEBUG LogId: ../hub/ncnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.param\n=============== Output-Dims ==============\nscore_8: c=1,h=12800,w=1\nscore_16: c=1,h=3200,w=1\nscore_32: c=1,h=800,w=1\nbbox_8: c=1,h=12800,w=4\nbbox_16: c=1,h=3200,w=4\nbbox_32: c=1,h=800,w=4\nkps_8: c=1,h=12800,w=10\nkps_16: c=1,h=3200,w=10\nkps_32: c=1,h=800,w=10\ngenerate_bboxes_kps num: 16\nNCNN Version Done! Detected Face Num: 2\nLITETNN_DEBUG LogId: ../hub/tnn/cv/scrfd_2.5g_bnkps_shape640x640.opt.tnnproto\n=============== Input-Dims ==============\ninput.1: [1 3 640 640 ]\nInput Data Format: NCHW\n=============== Output-Dims ==============\nbbox_16: [1 3200 4 ]\nbbox_32: [1 800 4 ]\nbbox_8: [1 12800 4 ]\nkps_16: [1 3200 10 ]\nkps_32: [1 800 10 ]\nkps_8: [1 12800 10 ]\nscore_16: [1 3200 1 ]\nscore_32: [1 800 1 ]\nscore_8: [1 12800 1 ]\n========================================\ngenerate_bboxes_kps num: 49\nTNN Version Done! Detected Face Num: 7\nTesting Successful !\n```  \n\n![](resources/9.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlite-dev%2Fscrfd-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxlite-dev%2Fscrfd-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxlite-dev%2Fscrfd-toolkit/lists"}