mirror of https://github.com/vladmandic/human
minor update
parent
fc6873c092
commit
ab49b01df2
|
@ -18,6 +18,8 @@
|
||||||
* ui={}: contains all variables exposed in the UI
|
* ui={}: contains all variables exposed in the UI
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// test url <https://human.local/?worker=false&async=false&bench=false&draw=true&warmup=full&backend=humangl>
|
||||||
|
|
||||||
// @ts-nocheck // typescript checks disabled as this is pure javascript
|
// @ts-nocheck // typescript checks disabled as this is pure javascript
|
||||||
|
|
||||||
import Human from '../dist/human.esm.js'; // equivalent of @vladmandic/human
|
import Human from '../dist/human.esm.js'; // equivalent of @vladmandic/human
|
||||||
|
@ -907,7 +909,7 @@ async function main() {
|
||||||
log('overriding worker:', ui.useWorker);
|
log('overriding worker:', ui.useWorker);
|
||||||
}
|
}
|
||||||
if (params.has('backend')) {
|
if (params.has('backend')) {
|
||||||
userConfig.backend = params.get('backend');
|
userConfig.backend = params.get('backend'); // string
|
||||||
log('overriding backend:', userConfig.backend);
|
log('overriding backend:', userConfig.backend);
|
||||||
}
|
}
|
||||||
if (params.has('preload')) {
|
if (params.has('preload')) {
|
||||||
|
@ -915,9 +917,21 @@ async function main() {
|
||||||
log('overriding preload:', ui.modelsPreload);
|
log('overriding preload:', ui.modelsPreload);
|
||||||
}
|
}
|
||||||
if (params.has('warmup')) {
|
if (params.has('warmup')) {
|
||||||
ui.modelsWarmup = JSON.parse(params.get('warmup'));
|
ui.modelsWarmup = params.get('warmup'); // string
|
||||||
log('overriding warmup:', ui.modelsWarmup);
|
log('overriding warmup:', ui.modelsWarmup);
|
||||||
}
|
}
|
||||||
|
if (params.has('bench')) {
|
||||||
|
ui.bench = JSON.parse(params.get('bench'));
|
||||||
|
log('overriding bench:', ui.bench);
|
||||||
|
}
|
||||||
|
if (params.has('draw')) {
|
||||||
|
ui.drawWarmup = JSON.parse(params.get('draw'));
|
||||||
|
log('overriding drawWarmup:', ui.drawWarmup);
|
||||||
|
}
|
||||||
|
if (params.has('async')) {
|
||||||
|
userConfig.async = JSON.parse(params.get('async'));
|
||||||
|
log('overriding async:', userConfig.async);
|
||||||
|
}
|
||||||
|
|
||||||
// create instance of human
|
// create instance of human
|
||||||
human = new Human(userConfig);
|
human = new Human(userConfig);
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9444,33 +9444,35 @@ function process4(input, config3) {
|
||||||
if (fx)
|
if (fx)
|
||||||
fx = null;
|
fx = null;
|
||||||
}
|
}
|
||||||
let pixels;
|
if (!tensor2) {
|
||||||
if (outCanvas.data) {
|
let pixels;
|
||||||
const shape = [outCanvas.height, outCanvas.width, 3];
|
if (outCanvas.data) {
|
||||||
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
const shape = [outCanvas.height, outCanvas.width, 3];
|
||||||
} else if (outCanvas instanceof ImageData) {
|
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
} else if (outCanvas instanceof ImageData) {
|
||||||
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
} else {
|
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
||||||
}
|
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
||||||
if (pixels) {
|
}
|
||||||
const casted = tf18.cast(pixels, "float32");
|
if (pixels) {
|
||||||
tensor2 = tf18.expandDims(casted, 0);
|
const casted = tf18.cast(pixels, "float32");
|
||||||
tf18.dispose(pixels);
|
tensor2 = tf18.expandDims(casted, 0);
|
||||||
tf18.dispose(casted);
|
tf18.dispose(pixels);
|
||||||
|
tf18.dispose(casted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const canvas2 = config3.filter.return ? outCanvas : null;
|
const canvas2 = config3.filter.return ? outCanvas : null;
|
||||||
|
|
|
@ -9445,33 +9445,35 @@ function process4(input, config3) {
|
||||||
if (fx)
|
if (fx)
|
||||||
fx = null;
|
fx = null;
|
||||||
}
|
}
|
||||||
let pixels;
|
if (!tensor2) {
|
||||||
if (outCanvas.data) {
|
let pixels;
|
||||||
const shape = [outCanvas.height, outCanvas.width, 3];
|
if (outCanvas.data) {
|
||||||
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
const shape = [outCanvas.height, outCanvas.width, 3];
|
||||||
} else if (outCanvas instanceof ImageData) {
|
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
} else if (outCanvas instanceof ImageData) {
|
||||||
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
} else {
|
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
||||||
}
|
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
||||||
if (pixels) {
|
}
|
||||||
const casted = tf18.cast(pixels, "float32");
|
if (pixels) {
|
||||||
tensor2 = tf18.expandDims(casted, 0);
|
const casted = tf18.cast(pixels, "float32");
|
||||||
tf18.dispose(pixels);
|
tensor2 = tf18.expandDims(casted, 0);
|
||||||
tf18.dispose(casted);
|
tf18.dispose(pixels);
|
||||||
|
tf18.dispose(casted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const canvas2 = config3.filter.return ? outCanvas : null;
|
const canvas2 = config3.filter.return ? outCanvas : null;
|
||||||
|
|
|
@ -9444,33 +9444,35 @@ function process4(input, config3) {
|
||||||
if (fx)
|
if (fx)
|
||||||
fx = null;
|
fx = null;
|
||||||
}
|
}
|
||||||
let pixels;
|
if (!tensor2) {
|
||||||
if (outCanvas.data) {
|
let pixels;
|
||||||
const shape = [outCanvas.height, outCanvas.width, 3];
|
if (outCanvas.data) {
|
||||||
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
const shape = [outCanvas.height, outCanvas.width, 3];
|
||||||
} else if (outCanvas instanceof ImageData) {
|
pixels = tf18.tensor3d(outCanvas.data, shape, "int32");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
} else if (outCanvas instanceof ImageData) {
|
||||||
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
pixels = tf18.browser ? tf18.browser.fromPixels(outCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else if (config3.backend === "webgl" || config3.backend === "humangl") {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
} else {
|
pixels = tf18.browser ? tf18.browser.fromPixels(tempCanvas) : null;
|
||||||
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
} else {
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = typeof OffscreenCanvas !== "undefined" ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement("canvas");
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext("2d");
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext("2d");
|
||||||
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
tempCtx == null ? void 0 : tempCtx.drawImage(outCanvas, 0, 0);
|
||||||
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
const data = tempCtx == null ? void 0 : tempCtx.getImageData(0, 0, targetWidth, targetHeight);
|
||||||
}
|
pixels = tf18.browser ? tf18.browser.fromPixels(data) : null;
|
||||||
if (pixels) {
|
}
|
||||||
const casted = tf18.cast(pixels, "float32");
|
if (pixels) {
|
||||||
tensor2 = tf18.expandDims(casted, 0);
|
const casted = tf18.cast(pixels, "float32");
|
||||||
tf18.dispose(pixels);
|
tensor2 = tf18.expandDims(casted, 0);
|
||||||
tf18.dispose(casted);
|
tf18.dispose(pixels);
|
||||||
|
tf18.dispose(casted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const canvas2 = config3.filter.return ? outCanvas : null;
|
const canvas2 = config3.filter.return ? outCanvas : null;
|
||||||
|
|
|
@ -65,14 +65,14 @@
|
||||||
"@tensorflow/tfjs-layers": "^3.8.0",
|
"@tensorflow/tfjs-layers": "^3.8.0",
|
||||||
"@tensorflow/tfjs-node": "^3.8.0",
|
"@tensorflow/tfjs-node": "^3.8.0",
|
||||||
"@tensorflow/tfjs-node-gpu": "^3.8.0",
|
"@tensorflow/tfjs-node-gpu": "^3.8.0",
|
||||||
"@types/node": "^16.4.9",
|
"@types/node": "^16.4.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.28.5",
|
"@typescript-eslint/eslint-plugin": "^4.29.0",
|
||||||
"@typescript-eslint/parser": "^4.28.5",
|
"@typescript-eslint/parser": "^4.29.0",
|
||||||
"@vladmandic/pilogger": "^0.2.18",
|
"@vladmandic/pilogger": "^0.2.18",
|
||||||
"canvas": "^2.8.0",
|
"canvas": "^2.8.0",
|
||||||
"chokidar": "^3.5.2",
|
"chokidar": "^3.5.2",
|
||||||
"dayjs": "^1.10.6",
|
"dayjs": "^1.10.6",
|
||||||
"esbuild": "^0.12.17",
|
"esbuild": "^0.12.18",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-airbnb-base": "^14.2.1",
|
"eslint-config-airbnb-base": "^14.2.1",
|
||||||
"eslint-plugin-import": "^2.23.4",
|
"eslint-plugin-import": "^2.23.4",
|
||||||
|
|
|
@ -1,22 +1,22 @@
|
||||||
2021-07-31 20:38:26 [36mINFO: [39m @vladmandic/human version 2.1.2
|
2021-08-05 10:24:04 [36mINFO: [39m @vladmandic/human version 2.1.2
|
||||||
2021-07-31 20:38:26 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.5.0
|
2021-08-05 10:24:04 [36mINFO: [39m User: vlado Platform: linux Arch: x64 Node: v16.5.0
|
||||||
2021-07-31 20:38:26 [36mINFO: [39m Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.17","typescript":"4.3.5","typedoc":"0.21.5","eslint":"7.32.0"}
|
2021-08-05 10:24:04 [36mINFO: [39m Toolchain: {"tfjs":"3.8.0","esbuild":"0.12.18","typescript":"4.3.5","typedoc":"0.21.5","eslint":"7.32.0"}
|
||||||
2021-07-31 20:38:26 [36mINFO: [39m Clean: ["dist/*","types/*","typedoc/*"]
|
2021-08-05 10:24:04 [36mINFO: [39m Clean: ["dist/*","types/*","typedoc/*"]
|
||||||
2021-07-31 20:38:27 [36mINFO: [39m Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
|
2021-08-05 10:24:04 [36mINFO: [39m Build: file startup all type: production config: {"minifyWhitespace":true,"minifyIdentifiers":true,"minifySyntax":true}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: node type: tfjs: {"imports":1,"importBytes":102,"outputBytes":1303,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: node type: node: {"imports":42,"importBytes":435502,"outputBytes":377743,"outputFiles":"dist/human.node.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: node type: node: {"imports":42,"importBytes":435865,"outputBytes":377825,"outputFiles":"dist/human.node.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: nodeGPU type: tfjs: {"imports":1,"importBytes":110,"outputBytes":1311,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: nodeGPU type: node: {"imports":42,"importBytes":435510,"outputBytes":377747,"outputFiles":"dist/human.node-gpu.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: nodeGPU type: node: {"imports":42,"importBytes":435873,"outputBytes":377829,"outputFiles":"dist/human.node-gpu.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: nodeWASM type: tfjs: {"imports":1,"importBytes":149,"outputBytes":1378,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: nodeWASM type: node: {"imports":42,"importBytes":435577,"outputBytes":377819,"outputFiles":"dist/human.node-wasm.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: nodeWASM type: node: {"imports":42,"importBytes":435940,"outputBytes":377901,"outputFiles":"dist/human.node-wasm.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2111,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: browserNoBundle type: tfjs: {"imports":1,"importBytes":2111,"outputBytes":1242,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: browserNoBundle type: esm: {"imports":42,"importBytes":435441,"outputBytes":247945,"outputFiles":"dist/human.esm-nobundle.js"}
|
2021-08-05 10:24:04 [35mSTATE:[39m target: browserNoBundle type: esm: {"imports":42,"importBytes":435804,"outputBytes":247953,"outputFiles":"dist/human.esm-nobundle.js"}
|
||||||
2021-07-31 20:38:27 [35mSTATE:[39m target: browserBundle type: tfjs: {"modules":1170,"moduleBytes":4145868,"imports":7,"importBytes":2111,"outputBytes":2334701,"outputFiles":"dist/tfjs.esm.js"}
|
2021-08-05 10:24:05 [35mSTATE:[39m target: browserBundle type: tfjs: {"modules":1170,"moduleBytes":4145868,"imports":7,"importBytes":2111,"outputBytes":2334701,"outputFiles":"dist/tfjs.esm.js"}
|
||||||
2021-07-31 20:38:28 [35mSTATE:[39m target: browserBundle type: iife: {"imports":42,"importBytes":2768900,"outputBytes":1378408,"outputFiles":"dist/human.js"}
|
2021-08-05 10:24:05 [35mSTATE:[39m target: browserBundle type: iife: {"imports":42,"importBytes":2769263,"outputBytes":1378416,"outputFiles":"dist/human.js"}
|
||||||
2021-07-31 20:38:28 [35mSTATE:[39m target: browserBundle type: esm: {"imports":42,"importBytes":2768900,"outputBytes":1378400,"outputFiles":"dist/human.esm.js"}
|
2021-08-05 10:24:06 [35mSTATE:[39m target: browserBundle type: esm: {"imports":42,"importBytes":2769263,"outputBytes":1378408,"outputFiles":"dist/human.esm.js"}
|
||||||
2021-07-31 20:38:28 [36mINFO: [39m Running Linter: ["server/","src/","tfjs/","test/","demo/"]
|
2021-08-05 10:24:06 [36mINFO: [39m Running Linter: ["server/","src/","tfjs/","test/","demo/"]
|
||||||
2021-07-31 20:38:50 [36mINFO: [39m Linter complete: files: 75 errors: 0 warnings: 0
|
2021-08-05 10:24:27 [36mINFO: [39m Linter complete: files: 75 errors: 0 warnings: 0
|
||||||
2021-07-31 20:38:50 [36mINFO: [39m Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"]
|
2021-08-05 10:24:27 [36mINFO: [39m Generate ChangeLog: ["/home/vlado/dev/human/CHANGELOG.md"]
|
||||||
2021-07-31 20:38:50 [36mINFO: [39m Generate Typings: ["src/human.ts"] outDir: ["types"]
|
2021-08-05 10:24:27 [36mINFO: [39m Generate Typings: ["src/human.ts"] outDir: ["types"]
|
||||||
2021-07-31 20:39:03 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"]
|
2021-08-05 10:24:41 [36mINFO: [39m Generate TypeDocs: ["src/human.ts"] outDir: ["typedoc"]
|
||||||
2021-07-31 20:39:16 [36mINFO: [39m Documentation generated at /home/vlado/dev/human/typedoc 1
|
2021-08-05 10:24:55 [36mINFO: [39m Documentation generated at /home/vlado/dev/human/typedoc 1
|
||||||
|
|
|
@ -128,6 +128,10 @@ export function process(input: Input, config: Config): { tensor: Tensor | null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outCanvas.data = pixBuffer;
|
outCanvas.data = pixBuffer;
|
||||||
|
const shape = [outCanvas.height, outCanvas.width, 3];
|
||||||
|
const pixels = tf.tensor3d(outCanvas.data, shape, 'float32');
|
||||||
|
tensor = tf.expandDims(pixels, 0);
|
||||||
|
tf.dispose(pixels);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
|
@ -135,36 +139,38 @@ export function process(input: Input, config: Config): { tensor: Tensor | null,
|
||||||
if (fx) fx = null;
|
if (fx) fx = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create tensor from image
|
// create tensor from image if tensor is not already defined
|
||||||
let pixels;
|
if (!tensor) {
|
||||||
if (outCanvas.data) { // if we have data, just convert to tensor
|
let pixels;
|
||||||
const shape = [outCanvas.height, outCanvas.width, 3];
|
if (outCanvas.data) { // if we have data, just convert to tensor
|
||||||
pixels = tf.tensor3d(outCanvas.data, shape, 'int32');
|
const shape = [outCanvas.height, outCanvas.width, 3];
|
||||||
} else if (outCanvas instanceof ImageData) { // if input is imagedata, just use it
|
pixels = tf.tensor3d(outCanvas.data, shape, 'int32');
|
||||||
pixels = tf.browser ? tf.browser.fromPixels(outCanvas) : null;
|
} else if (outCanvas instanceof ImageData) { // if input is imagedata, just use it
|
||||||
} else if (config.backend === 'webgl' || config.backend === 'humangl') { // tf kernel-optimized method to get imagedata
|
pixels = tf.browser ? tf.browser.fromPixels(outCanvas) : null;
|
||||||
// we can use canvas as-is as it already has a context, so we do a silly one more canvas
|
} else if (config.backend === 'webgl' || config.backend === 'humangl') { // tf kernel-optimized method to get imagedata
|
||||||
const tempCanvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement('canvas');
|
// we cant use canvas as-is as it already has a context, so we do a silly one more canvas
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement('canvas');
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext('2d');
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx?.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext('2d');
|
||||||
pixels = tf.browser ? tf.browser.fromPixels(tempCanvas) : null;
|
tempCtx?.drawImage(outCanvas, 0, 0);
|
||||||
} else { // cpu and wasm kernel does not implement efficient fromPixels method
|
pixels = tf.browser ? tf.browser.fromPixels(tempCanvas) : null;
|
||||||
// we can use canvas as-is as it already has a context, so we do a silly one more canvas
|
} else { // cpu and wasm kernel does not implement efficient fromPixels method
|
||||||
const tempCanvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement('canvas');
|
// we cant use canvas as-is as it already has a context, so we do a silly one more canvas and do fromPixels on ImageData instead
|
||||||
tempCanvas.width = targetWidth;
|
const tempCanvas = (typeof OffscreenCanvas !== 'undefined') ? new OffscreenCanvas(targetWidth, targetHeight) : document.createElement('canvas');
|
||||||
tempCanvas.height = targetHeight;
|
tempCanvas.width = targetWidth;
|
||||||
const tempCtx = tempCanvas.getContext('2d');
|
tempCanvas.height = targetHeight;
|
||||||
tempCtx?.drawImage(outCanvas, 0, 0);
|
const tempCtx = tempCanvas.getContext('2d');
|
||||||
const data = tempCtx?.getImageData(0, 0, targetWidth, targetHeight);
|
tempCtx?.drawImage(outCanvas, 0, 0);
|
||||||
pixels = tf.browser ? tf.browser.fromPixels(data) : null;
|
const data = tempCtx?.getImageData(0, 0, targetWidth, targetHeight);
|
||||||
}
|
pixels = tf.browser ? tf.browser.fromPixels(data) : null;
|
||||||
if (pixels) {
|
}
|
||||||
const casted = tf.cast(pixels, 'float32');
|
if (pixels) {
|
||||||
tensor = tf.expandDims(casted, 0);
|
const casted = tf.cast(pixels, 'float32');
|
||||||
tf.dispose(pixels);
|
tensor = tf.expandDims(casted, 0);
|
||||||
tf.dispose(casted);
|
tf.dispose(pixels);
|
||||||
|
tf.dispose(casted);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const canvas = config.filter.return ? outCanvas : null;
|
const canvas = config.filter.return ? outCanvas : null;
|
||||||
|
|
Loading…
Reference in New Issue