You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -130,6 +160,55 @@ The neural net is equivalent to the **FaceRecognizerNet** used in [face-recognit
130
160
131
161
The size of the quantized model is roughly 6.2 MB (**face_recognition_model**).
132
162
163
+
<aname="getting-started"></a>
164
+
165
+
# Getting Started
166
+
167
+
<aname="getting-started-browser"></a>
168
+
169
+
## face-api.js for the Browser
170
+
171
+
Simply include the latest script from [dist/face-api.js](https://github.com/justadudewhohacks/face-api.js/tree/master/dist).
172
+
173
+
Or install it via npm:
174
+
175
+
```bash
176
+
npm i face-api.js
177
+
```
178
+
179
+
<aname="getting-started-nodejs"></a>
180
+
181
+
## face-api.js for Nodejs
182
+
183
+
We can use the equivalent API in a nodejs environment by polyfilling some browser specifics, such as HTMLImageElement, HTMLCanvasElement and ImageData. The easiest way to do so is by installing the node-canvas package.
184
+
185
+
Alternatively you can simply construct your own tensors from image data and pass tensors as inputs to the API.
186
+
187
+
Furthermore you want to install @tensorflow/tfjs-node (not required, but highly recommended), which speeds things up drastically by compiling and binding to the native Tensorflow C++ library:
188
+
189
+
```bash
190
+
npm i face-api.js canvas @tensorflow/tfjs-node
191
+
```
192
+
193
+
Now we simply monkey patch the environment to use the polyfills:
194
+
195
+
```javascript
196
+
// import nodejs bindings to native tensorflow,
197
+
// not required, but will speed up things drastically (python required)
198
+
import'@tensorflow/tfjs-node';
199
+
200
+
// implements nodejs wrappers for HTMLCanvasElement, HTMLImageElement, ImageData
201
+
import*ascanvasfrom'canvas';
202
+
203
+
import*asfaceapifrom'face-api.js';
204
+
205
+
// patch nodejs environment, we need to provide an implementation of
206
+
// HTMLCanvasElement and HTMLImageElement, additionally an implementation
207
+
// of ImageData is required, in case you want to use the MTCNN
0 commit comments