Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 1.4 KB

README.md

File metadata and controls

54 lines (36 loc) · 1.4 KB

mtcnn-tfjs

Implement mtcnn with Tensorflow.js

CodeFactor

What is this?

A face detection framework with MTCNN and Tensorflow.js

Give me a ⭐️, if you like it ❤️

(Currently, framework is only accepted to detect one face, i'll update soon)

Installation

Run:

npm install whoisltd/mtcnn-tfjs

Use:

const mtcnn = require('@whoisltd/mtcnn-tfjs');

const pnet_url = 'https://storage.googleapis.com/my-mtcnn-models/final_model/pnet/model.json'

const rnet_url = 'https://storage.googleapis.com/my-mtcnn-models/final_model/rnet/model.json'

const onet_url = 'https://storage.googleapis.com/my-mtcnn-models/final_model/onet/model.json'

let model = null
if(model == null){
   model = new mtcnn.MTCNN(pnet_url, rnet_url, onet_url)
   model.mtcnn.pnet = await model.mtcnn.pnet
   model.mtcnn.rnet = await model.mtcnn.rnet
   model.mtcnn.onet = await model.mtcnn.onet
}

//Draw bounding boxes on image:
model.draw_img(url_img, url_output);

//Crop face from image:
model.crop_face(url_img, url_output, true);

//Get bounding boxes, landmarks, score:
model.detect(url_img);

Demo

Contribution

Pull request is welcome!