{"id":16569711,"url":"https://github.com/hermitsun/insightface-lite-service","last_synced_at":"2026-06-17T23:31:25.496Z","repository":{"id":100354297,"uuid":"293030142","full_name":"HermitSun/insightface-lite-service","owner":"HermitSun","description":"A lightweight face recognition web service based on fastapi and insightface.","archived":false,"fork":false,"pushed_at":"2020-09-06T06:29:05.000Z","size":10532,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-13T20:09:46.945Z","etag":null,"topics":["face-recognition","fastapi","insightface"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HermitSun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-09-05T07:55:26.000Z","updated_at":"2023-09-15T15:50:32.000Z","dependencies_parsed_at":"2023-05-14T02:15:44.472Z","dependency_job_id":null,"html_url":"https://github.com/HermitSun/insightface-lite-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/HermitSun/insightface-lite-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HermitSun%2Finsightface-lite-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HermitSun%2Finsightface-lite-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HermitSun%2Finsightface-lite-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HermitSun%2Finsightface-lite-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HermitSun","download_url":"https://codeload.github.com/HermitSun/insightface-lite-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HermitSun%2Finsightface-lite-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34470322,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"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":["face-recognition","fastapi","insightface"],"created_at":"2024-10-11T21:14:31.550Z","updated_at":"2026-06-17T23:31:25.479Z","avatar_url":"https://github.com/HermitSun.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# insightface-lite-service\n\n基于 [fastapi](https://github.com/tiangolo/fastapi) 和 [insightface](https://github.com/deepinsight/insightface) 的轻量级人脸识别服务。\n\n## 使用\n\n首先 `clone` 本项目，并进入项目根目录。\n\n### docker\n\n#### 构建镜像\n\n```shell\ndocker build -t \u003cyour-image-name\u003e .\n```\n\n如果构建镜像存在困难，可以使用预构建的镜像。\n提示，镜像大小为1.95GB。\n\n```shell\ndocker pull wensun/insightface-lite-service:latest\n```\n\n#### 启动容器\n\n```shell\ndocker run -p \u003cyour-port\u003e:80 -d \u003cyour-image-name\u003e\n```\n\n### 本机\n\n由于人脸识别的依赖限制，需要使用 **Python 3.6** 环境。\n\n然后，按照 `requirements.txt` 安装依赖（该依赖是在 Ubuntu 环境下抽取的），并使用以下命令在本机 8000 端口启动开发服务：\n\n```shell\nuvicorn main:app --reload\n```\n\n如果按照 `requirements.txt` 安装后无法运行，也可以手动安装依赖：\n\n```shell\npip install fastapi \\\n    uvicorn \\\n    python-multipart \\\n    numpy \\\n    scikit-image \\\n    scikit-learn \\\n    opencv-python \\\n    mxnet\n```\n\n## 现有接口\n\n1. 检查健康状态\n\n   ```ts\n   GET /health\n   request: null\n   response: {\n     status: string\n   }\n   ```\n\n2. 比较两张图片中人脸的相似度（人脸比对）\n\n   ```ts\n   POST /compare\n   request: {\n     face1: multipart-formdata\n     face2: multipart-formdata\n   },\n   response: {\n     sim: number;    // similarity\n     dist: number;   // distance\n   }\n   ```\n\n## 常见问题\n\n1. 报错 `ImportError: libGL.so.1: cannot open shared object file: No such file or directory`\n\n   原因是缺少 `libgl1-mesa-glx`。使用以下命令进行安装即可（Ubuntu）：\n\n   ```shell\n   sudo apt-get update\n   sudo apt-get install libgl1-mesa-glx\n   ```\n\n2. 报错 `RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.`\n\n   编码问题。按照指示设置环境变量即可：\n\n   ```shell\n   export LC_ALL=C.UTF-8\n   export LANG=C.UTF-8\n   ```\n\n3. 图片识别失败 / 明明有人脸却无法识别 / 相似度过低\n\n   因为依赖的库似乎对背景噪声敏感，所以需要确保图片中的人脸占一定比例，这样才能正确识别。目前计划是对这种错误进行更友好的封装，如果有需要可以自行训练模型。\n\n## TODO\n\n- [ ] 增加CI / CD\n- [ ] 减小镜像大小\n- [ ] 提高接口健壮性\n  - [ ] 更友好的错误处理\n  - [ ] 并发处理\n- [ ] 增加识别功能\n- [ ] 增加跨域配置","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhermitsun%2Finsightface-lite-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhermitsun%2Finsightface-lite-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhermitsun%2Finsightface-lite-service/lists"}