Skip to content

Commit 623052b

Browse files
renamed package
1 parent 64cf04a commit 623052b

29 files changed

+59
-176
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
2-
_data
32
.rpt2_cache

.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_modules
2+
.rpt2_cache
3+
4+
examples
5+
test
6+
proto
7+
weights

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# face-recognition.min.js
1+
# face-api.js
22

3-
**face recognition API for the browser with tensorflow.js**
3+
**JavaScript API for face detection and face recognition in the browser with tensorflow.js**
44

55
This project implements a ResNet-34 like architecture using the tensorflow.js core API ([@tensorflow/tfjs-core](https://github.com/tensorflow/tfjs-core)) for realtime face recognition in the browser. The neural net is equivalent to the **FaceRecognizerNet** used in [face-recognition.js](https://github.com/justadudewhohacks/face-recognition.js) and the net used in the [dlib](https://github.com/davisking/dlib/blob/master/examples/dnn_face_recognition_ex.cpp) face recognition example. The weights have been trained by [davisking](https://github.com/davisking) and the model achieves a prediction accuracy of 99.38% on the LFW (Labeled Faces in the Wild) benchmark for face recognition.
66

@@ -29,7 +29,7 @@ Download the weights file from your server and initialize the net (note, that yo
2929
``` javascript
3030
const res = await axios.get('face_recognition_model.weights', { responseType: 'arraybuffer' })
3131
const weights = new Float32Array(res.data)
32-
const net = facerecognition.faceRecognitionNet(weights)
32+
const net = faceapi.faceRecognitionNet(weights)
3333
```
3434

3535
Compute and compare two 150 x 150 sized face images:
@@ -43,7 +43,7 @@ const imgData2 = ...
4343

4444
const descriptor1 = await net.computeFaceDescriptor(imgData1)
4545
const descriptor2 = await net.computeFaceDescriptor(imgData2)
46-
const distance = facerecognition.euclidianDistance(descriptor1, descriptor2)
46+
const distance = faceapi.euclidianDistance(descriptor1, descriptor2)
4747

4848
if (distance < 0.6)
4949
console.log('match')

dist/face-recognition.js renamed to dist/face-api.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function (global, factory) {
22
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('crypto')) :
33
typeof define === 'function' && define.amd ? define(['exports', 'crypto'], factory) :
4-
(factory((global.facerecognition = global.facerecognition || {}),global.crypto));
4+
(factory((global.faceapi = global.faceapi || {}),global.crypto));
55
}(this, (function (exports,crypto) { 'use strict';
66

77
crypto = crypto && crypto.hasOwnProperty('default') ? crypto['default'] : crypto;
@@ -1650,11 +1650,11 @@
16501650
seedrandom.xor4096 = xor4096;
16511651
seedrandom.tychei = tychei;
16521652

1653-
var C__Users_user_dev_faceRecognition_min_js_node_modules_seedrandom = seedrandom;
1653+
var C__Users_user_dev_faceApi_js_node_modules_seedrandom = seedrandom;
16541654

16551655
var seedrandom$1 = /*#__PURE__*/Object.freeze({
1656-
default: C__Users_user_dev_faceRecognition_min_js_node_modules_seedrandom,
1657-
__moduleExports: C__Users_user_dev_faceRecognition_min_js_node_modules_seedrandom
1656+
default: C__Users_user_dev_faceApi_js_node_modules_seedrandom,
1657+
__moduleExports: C__Users_user_dev_faceApi_js_node_modules_seedrandom
16581658
});
16591659

16601660
var MPRandGauss = (function () {

dist/face-api.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/face-recognition.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/transformInputs.d.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

dist/transformInputs.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

dist/transformInputs.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/public/commons.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ async function fetchImage(uri) {
1515
async function initFaceDetectionNet() {
1616
const res = await axios.get('face_detection_model.weights', { responseType: 'arraybuffer' })
1717
const weights = new Float32Array(res.data)
18-
return facerecognition.faceDetectionNet(weights)
18+
return faceapi.faceDetectionNet(weights)
1919
}
2020

2121
async function initFaceRecognitionNet() {
2222
const res = await axios.get('face_recognition_model.weights', { responseType: 'arraybuffer' })
2323
const weights = new Float32Array(res.data)
24-
return facerecognition.faceRecognitionNet(weights)
24+
return faceapi.faceRecognitionNet(weights)
2525
}
2626

2727
// fetch first image of each class and compute their descriptors
@@ -32,7 +32,7 @@ async function initTrainDescriptorsByClass(net, numImagesForTraining = 1) {
3232
async className => {
3333
const descriptors = []
3434
for (let i = 1; i < (numImagesForTraining + 1); i++) {
35-
const img = await facerecognition.bufferToImage(
35+
const img = await faceapi.bufferToImage(
3636
await fetchImage(getFaceImageUri(className, i))
3737
)
3838
descriptors.push(await net.computeFaceDescriptor(img))
@@ -47,9 +47,9 @@ async function initTrainDescriptorsByClass(net, numImagesForTraining = 1) {
4747

4848
function getBestMatch(descriptorsByClass, queryDescriptor) {
4949
function computeMeanDistance(descriptorsOfClass) {
50-
return facerecognition.round(
50+
return faceapi.round(
5151
descriptorsOfClass
52-
.map(d => facerecognition.euclideanDistance(d, queryDescriptor))
52+
.map(d => faceapi.euclideanDistance(d, queryDescriptor))
5353
.reduce((d1, d2) => d1 + d2, 0)
5454
/ (descriptorsOfClass.length || 1)
5555
)

0 commit comments

Comments
 (0)