mirror of https://github.com/vladmandic/human
added docker notes
parent
3cc1daff22
commit
89065def60
|
@ -0,0 +1,141 @@
|
||||||
|
# Running Human in a Docker container
|
||||||
|
|
||||||
|
This guide covers multiple scenarios:
|
||||||
|
|
||||||
|
1. Run app using Human as a full environment inside container
|
||||||
|
2. Run app using Human as NodeJS worker inside container
|
||||||
|
3. Run Human for web inside container
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Install Docker
|
||||||
|
For details see [Docker Docs: Installation Guide](https://docs.docker.com/engine/install/)
|
||||||
|
|
||||||
|
Example: Install Docker using official convenience script:
|
||||||
|
> curl https://get.docker.com | sudo sh
|
||||||
|
|
||||||
|
Check Docker status installation:
|
||||||
|
> sudo docker version
|
||||||
|
> sudo docker info
|
||||||
|
> sudo systemctl status containerd docker
|
||||||
|
|
||||||
|
Get list of running containers
|
||||||
|
> docker ps
|
||||||
|
|
||||||
|
Get logs from a running container
|
||||||
|
> docker logs `containerID`
|
||||||
|
|
||||||
|
Stop container
|
||||||
|
> docker stop `containerID`
|
||||||
|
|
||||||
|
Go to shell inside container
|
||||||
|
> docker exec -it `containerID` /bin/bash
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## 1. Run Human full environment
|
||||||
|
|
||||||
|
- To run `human` inside docker container,
|
||||||
|
simply *dockerize* your application as usual
|
||||||
|
- Note that if your app has a dependency on `@vladmandic/human`,
|
||||||
|
all of `human` components will be installed by default and not just the library
|
||||||
|
(for example, this includes copies of in `/models` and sources in `/src`)
|
||||||
|
- It is strongly recommended to dockerize prodution mode only apps (`npm install --production`)
|
||||||
|
to avoid installing all of `human` dev dependencies inside the container
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## 2. Run Human as NodeJS worker
|
||||||
|
|
||||||
|
### Minimize Dependnecies
|
||||||
|
|
||||||
|
To minimize size of a container dont install `human` as your app dependency
|
||||||
|
And avoid importing entire `@vladmandic/human` as usual:
|
||||||
|
|
||||||
|
```js
|
||||||
|
// const Human = require('@vladmandic/human').default;
|
||||||
|
```
|
||||||
|
|
||||||
|
Instead import `human` library directly as only library is required inside docker container:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const Human = require('./human-dist/human.node.js').default;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configure Docker
|
||||||
|
|
||||||
|
Create Docker recipe `myapp.docker` in your `human` project folder
|
||||||
|
|
||||||
|
- Can use `NodeJS` 14 or 16
|
||||||
|
- Minimal footprint as only `/dist` is actually required
|
||||||
|
- Assumes user has NodeJS app `myapp` with its `package.json`
|
||||||
|
- Modify workdir path as needed
|
||||||
|
- Modify entry point as needed
|
||||||
|
|
||||||
|
```text
|
||||||
|
FROM node:16
|
||||||
|
WORKDIR <path-to-myapp>
|
||||||
|
COPY package.json .
|
||||||
|
copy <myapp> .
|
||||||
|
RUN npm install
|
||||||
|
COPY node_modules/@vladmandic/human/dist ./human-dist
|
||||||
|
ENTRYPOINT node myapp/index.js
|
||||||
|
USER node
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build image
|
||||||
|
|
||||||
|
> sudo docker build . --file myapp.docker --tag myapp
|
||||||
|
|
||||||
|
### Run container
|
||||||
|
|
||||||
|
- Maps `models` from host to a docker container so there is no need to copy it into each container
|
||||||
|
- Modify path as needed
|
||||||
|
|
||||||
|
> docker run -docker run -it --init --detach \
|
||||||
|
--volume node_modules/@vladmandic/human/models:$PWD/models \
|
||||||
|
myapp
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## 3. Run Human for Web
|
||||||
|
|
||||||
|
### Configure Docker
|
||||||
|
|
||||||
|
Create Docker recipe `human-web.docker` in your `human` project folder
|
||||||
|
|
||||||
|
- Can use `NodeJS` 14 or 16
|
||||||
|
- Default package is empty as `human` has no external dependencies
|
||||||
|
- Minimal footprint as only `/dist` is actually required
|
||||||
|
- As an example, copies default `/demo` web app to serve
|
||||||
|
- Uses `@vladmandic/build` as web server
|
||||||
|
- Modify workdir path as needed
|
||||||
|
|
||||||
|
```text
|
||||||
|
FROM node:16
|
||||||
|
WORKDIR <path-to-myapp>
|
||||||
|
RUN npm init --yes
|
||||||
|
COPY build.json .
|
||||||
|
RUN npm install @vladmandic/build --no-fund
|
||||||
|
COPY dist ./dist
|
||||||
|
COPY demo ./demo
|
||||||
|
EXPOSE 10031
|
||||||
|
ENTRYPOINT node node_modules/@vladmandic/build/dist/build.js --profile serve
|
||||||
|
USER node
|
||||||
|
```
|
||||||
|
|
||||||
|
### Build image
|
||||||
|
|
||||||
|
> sudo docker build . --file human-web.docker --tag human-web
|
||||||
|
|
||||||
|
### Run container
|
||||||
|
|
||||||
|
- Maps `models` from host to a docker container so there is no need to copy it into each container
|
||||||
|
- Maps human internal web server to external port 8001 so app can be accessed externally
|
||||||
|
|
||||||
|
> docker run -docker run -it --init --detach --name human-web-instance \
|
||||||
|
--publish 8001:10031 \
|
||||||
|
--volume node_modules/@vladmandic/human/models:$PWD/models \
|
||||||
|
human-web
|
||||||
|
|
||||||
|
<br>
|
79
Home.md
79
Home.md
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
**AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition,**
|
**AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition,**
|
||||||
**Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis,**
|
**Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis,**
|
||||||
**Age & Gender & Emotion Prediction, Gesture Recognition**
|
**Age & Gender & Emotion Prediction, Gaze Tracking, Gesture Recognition, Body Segmentation**
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -16,25 +16,26 @@ JavaScript module using TensorFlow/JS Machine Learning library
|
||||||
Compatible with both software *tfjs-node* and
|
Compatible with both software *tfjs-node* and
|
||||||
GPU accelerated backends *tfjs-node-gpu* using CUDA libraries
|
GPU accelerated backends *tfjs-node-gpu* using CUDA libraries
|
||||||
|
|
||||||
Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) for processing of live WebCam video or static images
|
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
## Demos
|
## Demos
|
||||||
|
|
||||||
- [**Main Application**](https://vladmandic.github.io/human/demo/index.html)
|
- [**List of all Demo applications**](https://github.com/vladmandic/human/wiki/Demos)
|
||||||
- [**Face Extraction, Description, Identification and Matching**](https://vladmandic.github.io/human/demo/facematch/index.html)
|
- [*Live:* **Main Application**](https://vladmandic.github.io/human/demo/index.html)
|
||||||
- [**Face Extraction and 3D Rendering**](https://vladmandic.github.io/human/demo/face3d/index.html)
|
- [*Live:* **Face Extraction, Description, Identification and Matching**](https://vladmandic.github.io/human/demo/facematch/index.html)
|
||||||
- [**Details on Demo Applications**](https://github.com/vladmandic/human/wiki/Demos)
|
- [*Live:* **Face Extraction and 3D Rendering**](https://vladmandic.github.io/human/demo/face3d/index.html)
|
||||||
|
- [*Live:* **Multithreaded Detection Showcasing Maximum Performance**](https://vladmandic.github.io/human/demo/multithread/index.html)
|
||||||
|
- [*Live:* **VR Model with Head, Face, Eye, Body and Hand tracking**](https://vladmandic.github.io/human-vrm/src/human-vrm.html)
|
||||||
|
- [Examples galery](https://vladmandic.github.io/human/samples/samples.html)
|
||||||
|
|
||||||
## Project pages
|
## Project pages
|
||||||
|
|
||||||
- [**Code Repository**](https://github.com/vladmandic/human)
|
- [**Code Repository**](https://github.com/vladmandic/human)
|
||||||
- [**NPM Package**](https://www.npmjs.com/package/@vladmandic/human)
|
- [**NPM Package**](https://www.npmjs.com/package/@vladmandic/human)
|
||||||
- [**Issues Tracker**](https://github.com/vladmandic/human/issues)
|
- [**Issues Tracker**](https://github.com/vladmandic/human/issues)
|
||||||
- [**TypeDoc API Specification: Human**](https://vladmandic.github.io/human/typedoc/classes/Human.html)
|
- [**TypeDoc API Specification**](https://vladmandic.github.io/human/typedoc/classes/Human.html)
|
||||||
- [**TypeDoc API Specification: Root**](https://vladmandic.github.io/human/typedoc/)
|
|
||||||
- [**Change Log**](https://github.com/vladmandic/human/blob/main/CHANGELOG.md)
|
- [**Change Log**](https://github.com/vladmandic/human/blob/main/CHANGELOG.md)
|
||||||
|
- [**Current To-do List**](https://github.com/vladmandic/human/blob/main/TODO.md)
|
||||||
|
|
||||||
## Wiki pages
|
## Wiki pages
|
||||||
|
|
||||||
|
@ -50,14 +51,19 @@ Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) fo
|
||||||
|
|
||||||
## Additional notes
|
## Additional notes
|
||||||
|
|
||||||
- [**Notes on Backends**](https://github.com/vladmandic/human/wiki/Backends)
|
- [**Comparing Backends**](https://github.com/vladmandic/human/wiki/Backends)
|
||||||
- [**Development Server**](https://github.com/vladmandic/human/wiki/Development-Server)
|
- [**Development Server**](https://github.com/vladmandic/human/wiki/Development-Server)
|
||||||
- [**Build Process**](https://github.com/vladmandic/human/wiki/Build-Process)
|
- [**Build Process**](https://github.com/vladmandic/human/wiki/Build-Process)
|
||||||
- [**Adding Custom Modules**](https://github.com/vladmandic/human/wiki/Module)
|
- [**Adding Custom Modules**](https://github.com/vladmandic/human/wiki/Module)
|
||||||
- [**Performance Notes**](https://github.com/vladmandic/human/wiki/Performance)
|
- [**Performance Notes**](https://github.com/vladmandic/human/wiki/Performance)
|
||||||
- [**Performance Profiling**](https://github.com/vladmandic/human/wiki/Profiling)
|
- [**Performance Profiling**](https://github.com/vladmandic/human/wiki/Profiling)
|
||||||
- [**Platform Support**](https://github.com/vladmandic/human/wiki/Platforms)
|
- [**Platform Support**](https://github.com/vladmandic/human/wiki/Platforms)
|
||||||
|
- [**Diagnostic and Performance trace information**](https://github.com/vladmandic/human/wiki/Diag)
|
||||||
|
- [**Dockerize Human applications**](https://github.com/vladmandic/human/wiki/Docker)
|
||||||
- [**List of Models & Credits**](https://github.com/vladmandic/human/wiki/Models)
|
- [**List of Models & Credits**](https://github.com/vladmandic/human/wiki/Models)
|
||||||
|
- [**Models Download Repository**](https://github.com/vladmandic/human-models)
|
||||||
|
- [**Security & Privacy Policy**](https://github.com/vladmandic/human/blob/main/SECURITY.md)
|
||||||
|
- [**License & Usage Restrictions**](https://github.com/vladmandic/human/blob/main/LICENSE)
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
@ -65,57 +71,8 @@ Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) fo
|
||||||
|
|
||||||
*Suggestions are welcome!*
|
*Suggestions are welcome!*
|
||||||
|
|
||||||
<hr><br>
|
|
||||||
|
|
||||||
## Inputs
|
|
||||||
|
|
||||||
`Human` library can process all known input types:
|
|
||||||
|
|
||||||
- `Image`, `ImageData`, `ImageBitmap`, `Canvas`, `OffscreenCanvas`, `Tensor`,
|
|
||||||
- `HTMLImageElement`, `HTMLCanvasElement`, `HTMLVideoElement`, `HTMLMediaElement`
|
|
||||||
|
|
||||||
Additionally, `HTMLVideoElement`, `HTMLMediaElement` can be a standard `<video>` tag that links to:
|
|
||||||
|
|
||||||
- WebCam on user's system
|
|
||||||
- Any supported video type
|
|
||||||
For example: `.mp4`, `.avi`, etc.
|
|
||||||
- Additional video types supported via *HTML5 Media Source Extensions*
|
|
||||||
Live streaming examples:
|
|
||||||
- **HLS** (*HTTP Live Streaming*) using `hls.js`
|
|
||||||
- **DASH** (Dynamic Adaptive Streaming over HTTP) using `dash.js`
|
|
||||||
- **WebRTC** media track
|
|
||||||
|
|
||||||
<br><hr><br>
|
<br><hr><br>
|
||||||
|
|
||||||
## Default models
|
`Human` library is written in `TypeScript` [4.4](https://www.typescriptlang.org/docs/handbook/intro.html)
|
||||||
|
|
||||||
Default models in Human library are:
|
|
||||||
|
|
||||||
- **Face Detection**: MediaPipe BlazeFace - Back variation
|
|
||||||
- **Face Mesh**: MediaPipe FaceMesh
|
|
||||||
- **Face Iris Analysis**: MediaPipe Iris
|
|
||||||
- **Face Description**: HSE FaceRes
|
|
||||||
- **Emotion Detection**: Oarriaga Emotion
|
|
||||||
- **Body Analysis**: MoveNet - Lightning variation
|
|
||||||
- **Hand Analysis**: MediaPipe Hands
|
|
||||||
- **Body Segmentation**: Google Selfie
|
|
||||||
- **Object Detection**: CenterNet
|
|
||||||
- **Body Segmentation**: Google Selfie
|
|
||||||
|
|
||||||
Note that alternative models are provided and can be enabled via configuration
|
|
||||||
For example, `PoseNet` model can be switched for `BlazePose` model depending on the use case
|
|
||||||
|
|
||||||
For more info, see [**Configuration Details**](https://github.com/vladmandic/human/wiki/Configuration) and [**List of Models**](https://github.com/vladmandic/human/wiki/Models)
|
|
||||||
|
|
||||||
<br><hr><br>
|
|
||||||
|
|
||||||
`Human` library is written in `TypeScript` [4.2](https://www.typescriptlang.org/docs/handbook/intro.html)
|
|
||||||
Conforming to `JavaScript` [ECMAScript version 2020](https://www.ecma-international.org/ecma-262/11.0/index.html) standard
|
Conforming to `JavaScript` [ECMAScript version 2020](https://www.ecma-international.org/ecma-262/11.0/index.html) standard
|
||||||
Build target is `JavaScript` **EMCAScript version 2018**
|
Build target is `JavaScript` [EMCAScript version 2018](https://262.ecma-international.org/9.0/)
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
||||||
For details see [**Wiki Pages**](https://github.com/vladmandic/human/wiki)
|
|
||||||
and [**API Specification**](https://vladmandic.github.io/human/typedoc/classes/Human.html)
|
|
||||||
|
|
||||||
<br>
|
|
||||||
|
|
Loading…
Reference in New Issue