https://github.com/shirasawasama/retinaface-wasm
可在浏览器和微信小程序中使用的人脸识别算法. This is a WASM implementation of the Retinaface face detection algorithm.
https://github.com/shirasawasama/retinaface-wasm
face-detection face-recognition ncnn retinaface simd wasm wechat wechat-mini-program
Last synced: 6 months ago
JSON representation
可在浏览器和微信小程序中使用的人脸识别算法. This is a WASM implementation of the Retinaface face detection algorithm.
- Host: GitHub
- URL: https://github.com/shirasawasama/retinaface-wasm
- Owner: ShirasawaSama
- License: mit
- Created: 2024-03-10T10:32:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-05T08:33:28.000Z (9 months ago)
- Last Synced: 2025-03-24T09:44:14.241Z (7 months ago)
- Topics: face-detection, face-recognition, ncnn, retinaface, simd, wasm, wechat, wechat-mini-program
- Language: C++
- Homepage:
- Size: 7.69 MB
- Stars: 42
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Retinaface-WASM [](https://www.npmjs.com/package/retinaface-wasm) [](LICENSE)
This is a WASM implementation of the Retinaface face detection algorithm. It is based on the [Retinaface](https://arxiv.org/abs/1905.00641) paper.
> 本模块支持微信小程序且不依赖任何第三方库, 可直接使用! (手动 brotli 压缩 wasm 文件和拷贝 index.ts 代码即可)
## Screenshots

## Usage
### Installation
```bash
npm install retinaface-wasm
```### Example
```typescript
import Retinaface, { getWasmFile, env } from 'retinaface-wasm'
import imagePath from './R.jpg'const wasm = await WebAssembly.instantiateStreaming(fetch('https://cdn.jsdelivr.net/npm/retinaface-wasm/wasm/' + getWasmFile()), env)
const retinaface = new Retinaface(wasm.instance)const image = new Image()
image.src = imagePath
await new Promise((resolve, reject) => {
image.onload = resolve
image.onerror = reject
})const [data, scale] = retinaface.processImage(image)
const result = retinaface.detect(data, scale)console.log(result)
retinaface.close()
```## Brotli Compress WASM
```bash
node -e "fs.writeFileSync('retinaface-basic.wasm.br', zlib.brotliCompressSync(fs.readFileSync('retinaface-basic.wasm')))"
```## Examples
### WeChat Mini Program
[WeChat Mini Program Example](examples/wechat.ts)
### 478 Landmarks
[478 Landmarks Example](examples/landmarks.ts)
[Landmark Indexes](https://storage.googleapis.com/mediapipe-assets/documentation/mediapipe_face_landmark_fullsize.png)

## Author
Shirasawa
## License
[MIT](LICENSE)