human: faceres model returns null values for humangl backend

Issue Description After update Human to 2.9.3 and tf 3.20. face embedding always Nan image

Steps to Reproduce Config Human as image

Expected Behavior All work good and const found = result.face[0].embedding return 1024 array with values Environment Chrome 104.0.5112.102 (64 бит)

  • Human library version?
  • 2.9.3
  • Built-in demo or custom code?

image

Diagnostics

Additional

  • For installation or startup issues include your package.json
  • For usage issues, it is recommended to post your code as gist
  • For general questions, create a discussion topic

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 45 (22 by maintainers)

Most upvoted comments

@shurshilov i’m going to close this issue here - lets continue conversation in https://github.com/tensorflow/tfjs/issues/6822
(please provide info tfjs devs need when you can)

ok, so now we i have a confirmation of a root cause, i’ll work with tfjs team to figure it out

i don’t want to globally disable this feature as it has significant performance advantages

fyi, this feature enables usage of gl uniforms instead of textures in some places in glsl code so it speeds up model compilation as multiple models can be warmed-up/compiled in parallel so time to first result is about 2x faster

so you can disable it for your app for now:

  • in human versions 2.7 - 2.9 you can simply set config.backend = 'webgl'
    as optimizations are not enabled for default webgl backend, only for my port which is humangl
  • in human versions 2.10 (will be released this week), you can explicitly
    disable this optimization with config.flags.WEBGL_USE_SHAPES_UNIFORMS = false

regarding serialization, avoid looping and doing things such as charCodeAt
very simple approach:

  // serialize
  const blob = new Blob([Float32Array.from(result.face[0].embedding)]); // store fixed-size 4k blob to database (4 bytes per float entry) and if you need to store text, you can use blob.text()
  // deserialize
  const embedding = new Float32Array(await blob.arrayBuffer());
   // verify that they are the same -> returns 100%
  const similarity = human.similarity(result.face[0].embedding, embedding);