vladmandic / human

Human: AI-powered 3D Face Detection & Rotation Tracking, Face Description & Recognition, Body Pose Tracking, 3D Hand & Finger Tracking, Iris Analysis, Age & Gender & Emotion Prediction, Gaze Tracking, Gesture Recognition
https://vladmandic.github.io/human/demo/index.html
MIT License
2.23k stars 316 forks source link

Issues running from VSCode with option to Launch Chrome with task package #226

Closed TheRankin closed 2 years ago

TheRankin commented 2 years ago

Discussed in https://github.com/vladmandic/human/discussions/225

Originally posted by **TheRankin** December 6, 2021 I literally copy/paste the code from the "demo/typescript" and removed unnecessary code (those to show information as fps, etc) and am getting -NodeJS - Ok -Webcam - Ok -Models - Ok ```ts Uncaught (in promise) Error: Based on the provided shape, [1,1,96,2], the tensor should have 192 values but has 0 at assert (human.esm.js:5709) at makeTensor (human.esm.js:8289) at tensor (human.esm.js:8305) at Object.decodeWeights (human.esm.js:8448) at GraphModel.loadSync (human.esm.js:37757) at GraphModel.load (human.esm.js:37744) at async loadGraphModel (human.esm.js:37853) at async load5 (human.esm.js:75436) at async load19 (human.esm.js:81414) at async Human.load (human.esm.js:83800) Uncaught (in promise) Error: Based on the provided shape, [3,3,3,16], the tensor should have 432 values but has 0 at assert (human.esm.js:5709) at makeTensor (human.esm.js:8289) at tensor (human.esm.js:8305) at Object.decodeWeights (human.esm.js:8448) at GraphModel.loadSync (human.esm.js:37757) at GraphModel.load (human.esm.js:37744) at async loadGraphModel (human.esm.js:37853) at async load11 (human.esm.js:76367) ```
vladmandic commented 2 years ago

What is PWA-Chrome?
I know what PWA is (and Human does work as PWA, main demo actually does actually showcase that), but PWA-Chrome does not ring any bells right now...

Btw, you still did not post browser inspector log as requested AND ignored what I already diagnosed in the discussion?

TheRankin commented 2 years ago

in VSCode you can launch a PWA-Chrome that is like a Guest Chrome where your settings exist only in that mode (like when you login into another user in Chrome), mostly used for debugging

launch.json

{
  "configurations": [
    {
      "name": "Launch Chrome",
      "request": "launch",
      "preLaunchTask": "npm: start",
      "type": "pwa-chrome",
      "url": "http://localhost:1234",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

I use this mode for web development (like Reach, Angular, etc) so in this case, I guess if someone tries to implement Human and is running the dev-server on PWA-Chrome in the VSCode launch, they will get this problem without understand 'why?'

TheRankin commented 2 years ago

Well, actually is just the launch mode, because I get the same problem on webpack

vladmandic commented 2 years ago

Issue with incorrectly detecting Node is due to fact that VSCode runs as ElectronJS process which creates process namespace which normally doesn't exist in browser environments

This is now fixed in the main branch, but that was not a critical issue (result was that Human was attempting to use incorrect backend, but then fall back to default works anyhow)

Core issue is HTTP Error code 204 "No Content" when downloading *.bin files which comes between browser and Parcel dev web server

I cannot reproduce that as it works correctly on my system - this is likely a WebPack config issue, possibly a race condition where WebPack is not ready to serve binary files by the time that browser tries to load them

Closing as user environment setup specific

TheRankin commented 2 years ago

the problem happens in both parcel and webpack🤣, but I guess they actually don't generate that problem, just the browser environment

vladmandic commented 2 years ago

Most likely it's the same problem - they are both extremely slow and dev server has not yet processed binary files for serving by the time browser requests files.

vladmandic commented 2 years ago

To prove, set baseModelPath config option to load models from my git pages instead.

TheRankin commented 2 years ago

Well actually in both cases the models are static, parcel and webpack are not touching the models/ folder, the only change is on the web files, both ignore the models/ folder

vladmandic commented 2 years ago

we can have a theoretical discussion but the fact is that HTTP code 204 is not normal. just try something like this to rule out (or confirm issue) webpack/parcel http dev server as root cause:

  config.baseModelPath = `https://cdn.jsdelivr.net/npm/@vladmandic/human/models/`;
TheRankin commented 2 years ago

with that link works properly on PWA-Chrome

with config.baseModelPath = './models/' is downloading the file with a save-as dialog

vladmandic commented 2 years ago

so its proven - your webpack or parcel are serving binary files incorrectly in a way that it confuses pwa-chrome
could be mime-type issue or something else, but in either case not related to human code

TheRankin commented 2 years ago

Yes, in that case I guess is the serving files