Skip to content

Commit 4b9d9af

Browse files
init nodejs examples
1 parent 9af582a commit 4b9d9af

File tree

5 files changed

+695
-0
lines changed

5 files changed

+695
-0
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ node_modules
22
.rpt2_cache
33

44
examples
5+
examples-nodejs
56
proto
67
weights
78
weights_uncompressed

examples-nodejs/bbt1.jpg

251 KB
Loading

examples-nodejs/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as faceapi from '../src'
2+
import '@tensorflow/tfjs-node'
3+
import * as canvas from 'canvas';
4+
import * as path from 'path';
5+
6+
const { Canvas, Image } = canvas
7+
faceapi.env.monkeyPatch({ Canvas, Image })
8+
9+
async function run() {
10+
11+
await faceapi.nets.ssdMobilenetv1.loadFromDisk(path.resolve(__dirname, '../weights'))
12+
13+
const img = await canvas.loadImage('./bbt1.jpg')
14+
const detections = await faceapi.detectAllFaces(img)
15+
console.log(detections)
16+
}
17+
18+
run()

0 commit comments

Comments
 (0)