From 89065def6080803129c020a2c824f6bdb0db9851 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sat, 2 Oct 2021 11:41:42 -0400 Subject: [PATCH] added docker notes --- Docker.md | 141 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Home.md | 79 +++++++----------------------- 2 files changed, 159 insertions(+), 61 deletions(-) create mode 100644 Docker.md diff --git a/Docker.md b/Docker.md new file mode 100644 index 0000000..7c765f6 --- /dev/null +++ b/Docker.md @@ -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 + +
+ +## 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 + +
+ +## 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 + +
+ +## 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 +COPY package.json . +copy . +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 + +
+ +## 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 +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 + +
diff --git a/Home.md b/Home.md index 515323e..edc9d20 100644 --- a/Home.md +++ b/Home.md @@ -2,7 +2,7 @@ **AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition,** **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**
@@ -16,25 +16,26 @@ JavaScript module using TensorFlow/JS Machine Learning library Compatible with both software *tfjs-node* and 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 -
## Demos -- [**Main Application**](https://vladmandic.github.io/human/demo/index.html) -- [**Face Extraction, Description, Identification and Matching**](https://vladmandic.github.io/human/demo/facematch/index.html) -- [**Face Extraction and 3D Rendering**](https://vladmandic.github.io/human/demo/face3d/index.html) -- [**Details on Demo Applications**](https://github.com/vladmandic/human/wiki/Demos) +- [**List of all Demo applications**](https://github.com/vladmandic/human/wiki/Demos) +- [*Live:* **Main Application**](https://vladmandic.github.io/human/demo/index.html) +- [*Live:* **Face Extraction, Description, Identification and Matching**](https://vladmandic.github.io/human/demo/facematch/index.html) +- [*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 - [**Code Repository**](https://github.com/vladmandic/human) - [**NPM Package**](https://www.npmjs.com/package/@vladmandic/human) - [**Issues Tracker**](https://github.com/vladmandic/human/issues) -- [**TypeDoc API Specification: Human**](https://vladmandic.github.io/human/typedoc/classes/Human.html) -- [**TypeDoc API Specification: Root**](https://vladmandic.github.io/human/typedoc/) +- [**TypeDoc API Specification**](https://vladmandic.github.io/human/typedoc/classes/Human.html) - [**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 @@ -50,14 +51,19 @@ Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) fo ## 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) - [**Build Process**](https://github.com/vladmandic/human/wiki/Build-Process) - [**Adding Custom Modules**](https://github.com/vladmandic/human/wiki/Module) - [**Performance Notes**](https://github.com/vladmandic/human/wiki/Performance) - [**Performance Profiling**](https://github.com/vladmandic/human/wiki/Profiling) - [**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) +- [**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)
@@ -65,57 +71,8 @@ Check out [**Live Demo**](https://vladmandic.github.io/human/demo/index.html) fo *Suggestions are welcome!* -

- -## 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 `