mirror of https://github.com/vladmandic/human
fix backend order initialization
parent
04e832f512
commit
6bbbeaf452
|
@ -135,6 +135,7 @@ async function detect(input) {
|
||||||
} else {
|
} else {
|
||||||
log.data(' Gesture: N/A');
|
log.data(' Gesture: N/A');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result && result.object && result.object.length > 0) {
|
if (result && result.object && result.object.length > 0) {
|
||||||
for (let i = 0; i < result.object.length; i++) {
|
for (let i = 0; i < result.object.length; i++) {
|
||||||
const object = result.object[i];
|
const object = result.object[i];
|
||||||
|
|
|
@ -45,7 +45,7 @@ export async function check(instance, force = false) {
|
||||||
|
|
||||||
if (!available.includes(instance.config.backend)) {
|
if (!available.includes(instance.config.backend)) {
|
||||||
log(`error: backend ${instance.config.backend} not found in registry`);
|
log(`error: backend ${instance.config.backend} not found in registry`);
|
||||||
instance.config.backend = env.env.node ? 'tensorflow' : 'humangl';
|
instance.config.backend = env.env.node ? 'tensorflow' : 'webgl';
|
||||||
if (instance.config.debug) log(`override: setting backend ${instance.config.backend}`);
|
if (instance.config.debug) log(`override: setting backend ${instance.config.backend}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,9 +83,17 @@ export async function check(instance, force = false) {
|
||||||
log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true);
|
log('changing webgl: WEBGL_DELETE_TEXTURE_THRESHOLD:', true);
|
||||||
tf.ENV.set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0);
|
tf.ENV.set('WEBGL_DELETE_TEXTURE_THRESHOLD', 0);
|
||||||
}
|
}
|
||||||
// @ts-ignore getGPGPUContext only exists on WebGL backend
|
if (tf.backend().getGPGPUContext) {
|
||||||
const gl = await tf.backend().getGPGPUContext().gl;
|
const gl = await tf.backend().getGPGPUContext().gl;
|
||||||
if (instance.config.debug) log(`gl version:${gl.getParameter(gl.VERSION)} renderer:${gl.getParameter(gl.RENDERER)}`);
|
if (instance.config.debug) log(`gl version:${gl.getParameter(gl.VERSION)} renderer:${gl.getParameter(gl.RENDERER)}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle webgpu
|
||||||
|
if (tf.getBackend() === 'humangl') {
|
||||||
|
tf.ENV.set('WEBGPU_USE_GLSL', true);
|
||||||
|
tf.ENV.set('WEBGL_PACK_DEPTHWISECONV', false);
|
||||||
|
tf.ENV.set('WEBGL_USE_SHAPES_UNIFORMS', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for ready
|
// wait for ready
|
||||||
|
|
|
@ -93,13 +93,6 @@ export async function register(instance): Promise<void> {
|
||||||
log('error: cannot set WebGL context:', err);
|
log('error: cannot set WebGL context:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const current = tf.backend().getGPGPUContext ? tf.backend().getGPGPUContext().gl : null;
|
|
||||||
if (current) {
|
|
||||||
log(`humangl webgl version:${current.getParameter(current.VERSION)} renderer:${current.getParameter(current.RENDERER)}`);
|
|
||||||
} else {
|
|
||||||
log('error: no current gl context:', current, config.gl);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const ctx = new tf.GPGPUContext(config.gl);
|
const ctx = new tf.GPGPUContext(config.gl);
|
||||||
tf.registerBackend(config.name, () => new tf.MathBackendWebGL(ctx), config.priority);
|
tf.registerBackend(config.name, () => new tf.MathBackendWebGL(ctx), config.priority);
|
||||||
|
@ -117,6 +110,13 @@ export async function register(instance): Promise<void> {
|
||||||
log('error: cannot update WebGL backend registration:', err);
|
log('error: cannot update WebGL backend registration:', err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const current = tf.backend().getGPGPUContext ? tf.backend().getGPGPUContext().gl : null;
|
||||||
|
if (current) {
|
||||||
|
log(`humangl webgl version:${current.getParameter(current.VERSION)} renderer:${current.getParameter(current.RENDERER)}`);
|
||||||
|
} else {
|
||||||
|
log('error: no current gl context:', current, config.gl);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
tf.ENV.set('WEBGL_VERSION', 2);
|
tf.ENV.set('WEBGL_VERSION', 2);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in New Issue