-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.spec.js
50 lines (47 loc) · 1.16 KB
/
index.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import * as R from 'ramda';
import ArcFace from '../index';
const waitAll = promises => Promise.all(promises);
/*
1. Given photoUrl, parse into asvl format for face detection.
2. Given asvl format data, do face detection and return an array of detected faces.
3. Given asvl, detected face position, do feature extraction and return extracted features/
*/
test('ArcFace', () => {
const data = require('./photos.json');
const arcface = new ArcFace(process.env);
return Promise.resolve(data)
.then(
R.pipe(
R.map(
R.pipe(
R.path(['source', 'url']),
photoUrl => arcface.parseImage(photoUrl),
),
),
waitAll,
),
)
.then(
R.pipe(
R.map(asvl => arcface.detect(asvl)),
waitAll,
),
)
.then(
R.pipe(
R.map(
R.pipe(
R.map(({ asvl, rcFace, lfaceOrient }) =>
arcface.extractFeature(asvl, rcFace, lfaceOrient),
),
waitAll,
),
),
waitAll,
),
)
.then(([r1, r2]) => {
expect(r1.length).toEqual(1);
expect(r2.length).toEqual(3);
});
});