Socket
Socket
Sign inDemoInstall

retinaface

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

retinaface - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

mnet.25_v2.onnx

3

dist/index.d.ts

@@ -13,3 +13,4 @@ import type { InferenceSession, Tensor } from 'onnxruntime-web';

readonly height: number;
constructor(session: InferenceSession, tensorClass: typeof Tensor, width?: number, height?: number);
private readonly landmarksScale;
constructor(session: InferenceSession, tensorClass: typeof Tensor, width?: number, height?: number, landmarksScale?: number);
detect: (imageData: ImageData, scale?: number, probThreshold?: number, nmsThreshold?: number) => Promise<FaceObject[]>;

@@ -16,0 +17,0 @@ processImage(image: HTMLImageElement, rect?: {

@@ -20,3 +20,3 @@ const generateAnchors = (baseSize, ratios, scales) => {

};
const generateProposals = async (anchors, featStride, scoreT, bboxT, landmarkT, probThreshold) => {
const generateProposals = async (anchors, featStride, scoreT, bboxT, landmarkT, probThreshold, scale) => {
const bboxDims = bboxT.dims;

@@ -59,10 +59,12 @@ const w = bboxDims[3];

const y1 = pbCy + pbH * 0.5;
const w2 = anchorW * scale + 1;
const h2 = anchorH * scale + 1;
const obj = {
rect: [x0, y0, x1, y1],
landmarks: [
[cx + (anchorW + 1) * landmark[landmarkOffset + index + offset * 0], cy + (anchorH + 1) * landmark[landmarkOffset + index + offset * 1]],
[cx + (anchorW + 1) * landmark[landmarkOffset + index + offset * 2], cy + (anchorH + 1) * landmark[landmarkOffset + index + offset * 3]],
[cx + (anchorW + 1) * landmark[landmarkOffset + index + offset * 4], cy + (anchorH + 1) * landmark[landmarkOffset + index + offset * 5]],
[cx + (anchorW + 1) * landmark[landmarkOffset + index + offset * 6], cy + (anchorH + 1) * landmark[landmarkOffset + index + offset * 7]],
[cx + (anchorW + 1) * landmark[landmarkOffset + index + offset * 8], cy + (anchorH + 1) * landmark[landmarkOffset + index + offset * 9]]
[cx + w2 * landmark[landmarkOffset + index + offset * 0], cy + h2 * landmark[landmarkOffset + index + offset * 1]],
[cx + w2 * landmark[landmarkOffset + index + offset * 2], cy + h2 * landmark[landmarkOffset + index + offset * 3]],
[cx + w2 * landmark[landmarkOffset + index + offset * 4], cy + h2 * landmark[landmarkOffset + index + offset * 5]],
[cx + w2 * landmark[landmarkOffset + index + offset * 6], cy + h2 * landmark[landmarkOffset + index + offset * 7]],
[cx + w2 * landmark[landmarkOffset + index + offset * 8], cy + h2 * landmark[landmarkOffset + index + offset * 9]]
],

@@ -80,3 +82,3 @@ prob

};
const processStride = async (results, faceProposals, probThreshold, stride, scales) => {
const processStride = async (results, faceProposals, probThreshold, stride, scales, scale) => {
const score = results['face_rpn_cls_prob_reshape_stride' + stride];

@@ -88,3 +90,3 @@ const bbox = results['face_rpn_bbox_pred_stride' + stride];

const anchors = generateAnchors(baseSize, [1], scales);
faceProposals.push(...(await generateProposals(anchors, featStride, score, bbox, landmark, probThreshold)));
faceProposals.push(...(await generateProposals(anchors, featStride, score, bbox, landmark, probThreshold, scale)));
};

@@ -126,3 +128,4 @@ const nmsSortedBboxes = (faceObjects, nmsThreshold) => {

height;
constructor(session, tensorClass, width = 512, height = 512) {
landmarksScale;
constructor(session, tensorClass, width = 640, height = 640, landmarksScale = 0.18181818) {
this.session = session;

@@ -132,2 +135,3 @@ this.tensorClass = tensorClass;

this.height = height;
this.landmarksScale = landmarksScale;
}

@@ -149,5 +153,5 @@ detect = async (imageData, scale = 1, probThreshold = 0.75, nmsThreshold = 0.5) => {

const faceProposals = [];
await processStride(results, faceProposals, probThreshold, 32, [32, 16]);
await processStride(results, faceProposals, probThreshold, 16, [8, 4]);
await processStride(results, faceProposals, probThreshold, 8, [2, 1]);
await processStride(results, faceProposals, probThreshold, 32, [32, 16], this.landmarksScale);
await processStride(results, faceProposals, probThreshold, 16, [8, 4], this.landmarksScale);
await processStride(results, faceProposals, probThreshold, 8, [2, 1], this.landmarksScale);
faceProposals.sort((a, b) => b.prob - a.prob);

@@ -154,0 +158,0 @@ const picked = nmsSortedBboxes(faceProposals, nmsThreshold);

{
"name": "retinaface",
"version": "0.0.3",
"version": "0.0.4",
"description": "Running the Retinaface face recognition algorithm in browser.",

@@ -16,3 +16,4 @@ "main": "dist/index.js",

"dist",
"mnet.25_v1.onnx"
"mnet.25_v1.onnx",
"mnet.25_v2.onnx"
],

@@ -19,0 +20,0 @@ "repository": {

@@ -1,2 +0,2 @@

# Retinaface-JS [![npm](https://img.shields.io/npm/v/retinaface)](https://www.npmjs.com/package/retinaface) [![GitHub](https://img.shields.io/github/license/shirasawa/retinaface-js)](LICENSE)
# Retinaface-JS [![npm](https://img.shields.io/npm/v/retinaface)](https://www.npmjs.com/package/retinaface) [![GitHub](https://img.shields.io/github/license/ShirasawaSama/retinaface-js)](LICENSE)

@@ -23,3 +23,3 @@ This is a JavaScript implementation of the Retinaface face detection algorithm. It is based on the [Retinaface](https://arxiv.org/abs/1905.00641) paper.

import modelPath from 'retinaface/mnet.25_v1.onnx?url'
import modelPath from 'retinaface/mnet.25_v2.onnx?url'
import imagePath from './R.jpg'

@@ -26,0 +26,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc