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.38k stars 325 forks source link

error loading model: @vladmandic/human-models/models/blazeface.json TypeError: Failed to parse URL from @vladmandic/human-models/models/blazeface.json #459

Closed Victor1890 closed 7 months ago

Victor1890 commented 7 months ago

Issue Description I get an error when doing the first detect and the program is loading the models

09:31:55.482 Human: error loading model: @vladmandic/human-models/models/blazeface.json TypeError: Failed to parse URL from @vladmandic/human-models/models/blazeface.json
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at new Request (node:internal/deps/undici/undici:5270:25)
      at fetch (node:internal/deps/undici/undici:9508:25)
      at Object.fetch (node:internal/deps/undici/undici:11728:18)
      at fetch (node:internal/process/pre_execution:281:25)
      at xs (/root/workspaces/hobbies/human-face/backend-face-js/node_modules/.pnpm/@vladmandic+human@3.2.2/node_modules/@vladmandic/human/dist/human.node.js:99:25051)
      at HTTPRequest.fetchFunc [as fetch] (/root/workspaces/hobbies/human-face/backend-face-js/node_modules/.pnpm/@vladmandic+human@3.2.2/node_modules/@vladmandic/human/dist/human.node.js:99:25777)
      at HTTPRequest.<anonymous> (/root/workspaces/hobbies/human-face/backend-face-js/node_modules/.pnpm/@tensorflow+tfjs-core@4.18.0/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:25938:55)
      at step (/root/workspaces/hobbies/human-face/backend-face-js/node_modules/.pnpm/@tensorflow+tfjs-core@4.18.0/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:138:27) {
    input: '@vladmandic/human-models/models/blazeface.json',
    code: 'ERR_INVALID_URL'
  }
}

Steps to Reproduce Install Human and Tensorflow Initialize Human

import '@tensorflow/tfjs-node'
import H from '@vladmandic/human'

/**
 * @type {import('@vladmandic/human').Config}
 */
export const humanConfig = {
    async: false,
    backend: "cpu",
    debug: true,
    cacheSensitivity: 0,
    cacheModels: true,
    modelBasePath: '@vladmandic/human-models/models/',
    face: {
        scale: 1.4,
        detector: { enabled: true, maxDetected: 1, minSize: 256 },
        mesh: { enabled: true },
        iris: { enabled: false },
        description: { enabled: false },
        emotion: { enabled: true, crop: 0.15 },
    },
    body: { enabled: false },
    hand: { enabled: false },
    object: { enabled: false },
    gestures: { enabled: false },
};

export const human = new H.Human(humanConfig);

Expected Behavior

Environment

/**

export const human = new H.Human(humanConfig);

const file = readFileSync(join(process.cwd(), "src", "assets", "face.jpeg"))

console.log("file: ", file) console.log("human: ", human)

const tensor = human.tf.node.decodeImage(file, 3); const result = await human.detect(tensor, humanConfig);

console.log("result: ", result)

- TensorFlow/JS version (if not using bundled module)?
**@tensorflow/tfjs-node: 4.18.0**
- Browser or NodeJS and version (e.g. *NodeJS 14.15* or *Chrome 89*)?
**Node Version 18.19.0**
- OS and Hardware platform (e.g. *Windows 10*, *Ubuntu Linux on x64*, *Android 10*)?
**Windows 11 with WSL 2 (Ubuntu)**
- Packager (if any) (e.g, *webpack*, *rollup*, *parcel*, *esbuild*, etc.)?
- Framework (if any) (e.g. *React*, *NextJS*, etc.)?

**Diagnostics**

- Check out any applicable [diagnostic steps](https://github.com/vladmandic/human/wiki/Diag)

```js
console.log(human.config)

"config": {
        "backend": "cpu",
        "modelBasePath": "@vladmandic/human-models/models/",
        "cacheModels": true,
        "validateModels": true,
        "wasmPath": "https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@4.17.0/dist/",
        "wasmPlatformFetch": false,
        "debug": true,
        "async": false,
        "warmup": "full",
        "cacheSensitivity": 0,
        "skipAllowed": false,
        "deallocate": false,
        "flags": {},
        "softwareKernels": false,
        "filter": {
            "enabled": true,
            "equalization": false,
            "width": 0,
            "height": 0,
            "flip": false,
            "return": true,
            "autoBrightness": true,
            "brightness": 0,
            "contrast": 0,
            "sharpness": 0,
            "blur": 0,
            "saturation": 0,
            "hue": 0,
            "negative": false,
            "sepia": false,
            "vintage": false,
            "kodachrome": false,
            "technicolor": false,
            "polaroid": false,
            "pixelate": 0
        },
        "gesture": {
            "enabled": true
        },
        "face": {
            "enabled": true,
            "detector": {
                "modelPath": "blazeface.json",
                "rotation": false,
                "maxDetected": 1,
                "skipFrames": 99,
                "skipTime": 2500,
                "minConfidence": 0.2,
                "minSize": 256,
                "iouThreshold": 0.1,
                "scale": 1.4,
                "mask": false,
                "return": false,
                "enabled": true
            },
            "mesh": {
                "enabled": true,
                "modelPath": "facemesh.json",
                "keepInvalid": false
            },
            "attention": {
                "enabled": false,
                "modelPath": "facemesh-attention.json"
            },
            "iris": {
                "enabled": false,
                "scale": 2.3,
                "modelPath": "iris.json"
            },
            "emotion": {
                "enabled": true,
                "minConfidence": 0.1,
                "skipFrames": 99,
                "skipTime": 1500,
                "modelPath": "emotion.json",
                "crop": 0.15
            },
            "description": {
                "enabled": false,
                "modelPath": "faceres.json",
                "skipFrames": 99,
                "skipTime": 3000,
                "minConfidence": 0.1
            },
            "antispoof": {
                "enabled": false,
                "skipFrames": 99,
                "skipTime": 4000,
                "modelPath": "antispoof.json"
            },
            "liveness": {
                "enabled": false,
                "skipFrames": 99,
                "skipTime": 4000,
                "modelPath": "liveness.json"
            },
            "scale": 1.4
        },
        "body": {
            "enabled": false,
            "modelPath": "movenet-lightning.json",
            "maxDetected": -1,
            "minConfidence": 0.3,
            "skipFrames": 1,
            "skipTime": 200
        },
        "hand": {
            "enabled": false,
            "rotation": true,
            "skipFrames": 99,
            "skipTime": 1000,
            "minConfidence": 0.5,
            "iouThreshold": 0.2,
            "maxDetected": -1,
            "landmarks": true,
            "detector": {
                "modelPath": "handtrack.json"
            },
            "skeleton": {
                "modelPath": "handlandmark-lite.json"
            }
        },
        "object": {
            "enabled": false,
            "modelPath": "centernet.json",
            "minConfidence": 0.2,
            "iouThreshold": 0.4,
            "maxDetected": 10,
            "skipFrames": 99,
            "skipTime": 2000
        },
        "segmentation": {
            "enabled": false,
            "modelPath": "rvm.json",
            "ratio": 0.5,
            "mode": "default"
        },
        "gestures": {
            "enabled": false
        }
    }

Models exist at path

console.log(human.version)
version: 3.2.2

Debug gives:

09:47:10.062 Human: version: 3.2.2
09:47:10.063 Human: tfjs version: 4.17.0
09:47:10.064 Human: environment: {
  browser: false,
  node: true,
  platform: 'linux x64',
  agent: 'NodeJS v18.19.0',
  backends: [],
  tfjs: { version: '4.17.0' },
  offscreen: false,
  tensorflow: {},
  wasm: {},
  webgl: {},
  webgpu: {},
  cpu: { flags: [] }
}

Package.json:

{
    "scripts": {
        "dev": "nodemon"
    },
    "dependencies": {
        "@tensorflow/tfjs-node": "4.18.0",
        "@vladmandic/human": "3.2.2",
        "@vladmandic/human-models": "3.0.4",
        "cors": "2.8.5",
        "express": "4.19.2",
        "nodemon": "3.1.0"
    }
}
vladmandic commented 7 months ago
modelBasePath: '@vladmandic/human-models/models/',

this is not a path

just tried your code and using modelBasePath: 'file://node_modules/@vladmandic/human/models/', works fine