updated docs

pull/13/head
Vladimir Mandic 2020-10-11 12:50:50 -04:00
parent 253601e061
commit 205de4831a
2 changed files with 49 additions and 48 deletions

View File

@ -34,67 +34,68 @@ Due to reduced code and changed build process, resulting bundle is about **>5x s
There are several ways to use Face-API: There are several ways to use Face-API:
### IIFE script **Important**: This version of Face-Api does NOT pre-package `TFJS` to allow for faster downloads (it's much smaller) as well as to allow user to choose version of TFJS to use (it's compatible with any `TFJS 2.0+`).
*Size: 936KB minified*
This is simplest way for usage within Browser as it includes full version of TensorFlow/JS prepackaged with no external dependencies. ### 1. IIFE script
Simply download `dist/face-api.js`, include it in your `HTML` file & it's ready to use. *Size: 936KB minified*
```html This is simplest way for usage within Browser
<script src="dist/face-api.js"><script> Simply download `dist/face-api.js`, include it in your `HTML` file & it's ready to use.
```
For a quick test, you can access the script directly from `gitpages` ```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js"></script>
<script src="dist/face-api.js"><script>
```
```html For a quick test, you can access the script directly from `gitpages`
<script src="https://vladmandic.github.io/face-api/dist/face-api.js"></script>
```
IIFE script auto-registers global namespace `faceapi` within Window object. ```html
And if you want to access `TensorFlow/JS` classes directly, they are exported as `faceapi.tf` <script src="https://vladmandic.github.io/face-api/dist/face-api.js"></script>
```
Pre-packaged version of `TFJS` is **2.6.0** IIFE script auto-registers global namespace `faceapi` within Window object.
And if you want to access `TensorFlow/JS` classes directly, they are exported as `faceapi.tf`
### ESM module ### 2. ESM module
*Size: 164KB non-minified* *Size: 164KB non-minified*
If you're using bundler *(such as rollup, webpack, esbuild)* to package your client application, you can import ESM version of FaceAPI which supports full tree shaking If you're using bundler *(such as rollup, webpack, esbuild)* to package your client application, you can import ESM version of FaceAPI which supports full tree shaking
Note that this version does NOT pre-package `TFJS`, so you'll need to include it before you import `FaceAPI` Note that this version does NOT pre-package `TFJS`, so you'll need to include it before you import `FaceAPI`
You can use any version of `TFJS` 2.0+ You can use any version of `TFJS` 2.0+
```js ```js
import * as tf from 'https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js'; // load directly from CDN import * as tf from 'https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js'; // load directly from CDN
import * as faceapi from 'dist/face-api.esm.js'; import * as faceapi from 'dist/face-api.esm.js';
``` ```
*Experimental*: *Experimental*:
You could use same syntax within your main `JS` file if it's imported with `<script type="module">` You could use same syntax within your main `JS` file if it's imported with `<script type="module">`
```html ```html
<script src="tf.min.js"> <script src="tf.min.js">
<script src="./index.js" type="module"> <script src="./index.js" type="module">
``` ```
and then in `index.js` and then in `index.js`
```js ```js
import * as tf from 'https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js'; // load directly from CDN import * as tf from 'https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js'; // load directly from CDN
import * as faceapi from 'dist/face-api.esm.js'; import * as faceapi from 'dist/face-api.esm.js';
``` ```
### NPM module ### 3. NPM module
*Size: 45,104KB unpacked (including sources and pre-trained model weights)* *Size: 45,104KB unpacked (including sources and pre-trained model weights)*
Simmilar to ESM module, but with full sources as it points to `build/src/index.js` instead Simmilar to ESM module, but with full sources as it points to `build/src/index.js` instead
Recommended for NodeJS projects Recommended for NodeJS projects
Install with: Install with:
```shell ```shell
npm install @tensorflow/tfjs @vladmandic/face-api npm install @tensorflow/tfjs @vladmandic/face-api
``` ```
And then use with: And then use with:
```js ```js
import * as tf from '@tensorflow/tfjs'; import * as tf from '@tensorflow/tfjs';
import * as faceapi from '@vladmandic/face-api'; import * as faceapi from '@vladmandic/face-api';
``` ```
## Weights ## Weights

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type"> <meta http-equiv="content-type">
<meta content="text/html"> <meta content="text/html">
<meta charset="UTF-8"> <meta charset="UTF-8">
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js"></script> --> <script src="https://cdnjs.cloudflare.com/ajax/libs/tensorflow/2.6.0/tf.min.js"></script>
<script src="https://vladmandic.github.io/face-api/dist/face-api.js"></script> <script src="https://vladmandic.github.io/face-api/dist/face-api.js"></script>
<style> <style>
body { font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0; } body { font-family: monospace; background: black; color: white; font-size: 16px; line-height: 22px; margin: 0; }