Skip to content

wasmPath isn’t applied when other backends fail to initialize #530

@gjf7

Description

@gjf7

Thanks for the great work!

Issue Description
Initialize human with backend webgpu set, when webgpu fail to initialize, TF fallback to webgl then wasm, but wasmPath isn't respected.

Steps to Reproduce

const humanConfig: Partial<Config> = {
  cacheSensitivity: 0,
  debug: true,
  async: true,
  warmup: "face",
  backend: "webgpu"
  modelBasePath: "https://example.com/front-end-resource/tfjs/models/",
  wasmPath: "https://example.com/front-end-resource/tfjs/tfjs-backend-wasm@4.22.0/",
  filter: { enabled: false },
  face: {
    enabled: true,
    detector: {
      rotation: false,
      modelPath: "blazeface-front.json",
      maxDetected: 3,
      minConfidence: 0.8,
      return: false,
      square: false,
    },
    iris: { enabled: false },
    description: { enabled: false },
    emotion: { enabled: false },
    mesh: { enabled: false },
  },
  body: { enabled: false },
  hand: { enabled: false },
  object: { enabled: false },
  gesture: { enabled: false },
  segmentation: { enabled: false },
};

export const human = new Human(humanConfig);

 await human.load();
 await human.warmup();

Logs:

Human: version: 3.3.5

Human: tfjs version: 4.22.0

Human: environment: { "cpu": "[Object]", "node": false, "tfjs": "[Object]", "wasm": "[Object]", "agent": "Mozilla/5.0 AppleWebKit/537.36 Version/4.0 Chrome/134.0.6998.135 Mobile Safari/537.36", "webgl": "[Object]", "webgpu": "[Object]", "worker": false, "browser": true, "backends": "[Array]", "platform": "Linux; Android 15; PHW110 Build/AP3A.240617.008; wv", "offscreen": true, "tensorflow": "[Object]" }

Human: available backends: cpu,webgl,wasm,webgpu

Human: enumerated webgpu adapter: {}

Human: webgpu adapter info: {}

Initialization of backend webgpu failed

OperationError: Failed to execute 'requestDevice' on 'GPUAdapter': A valid external Instance reference no longer exists.

Initialization of backend webgpu failed

TypeError: Cannot read properties of null (reading 'features') at Object.factory


Could not get context for WebGL version 2

Could not get context for WebGL version 1

Initialization of backend webgl failed

Error: WebGL is not supported on this device at new d6


fetch | url | "tfjs-backend-wasm-simd.wasm" | method | "GET" | status_code | 404

wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': HTTP status code is not ok

Expected Behavior
Even fallback to wasm, wasmPath should respect.

For example, my website host at https://www.a.com, wasm file url should be https://example.com/front-end-resource/tfjs/tfjs-backend-wasm@4.22.0/tfjs-backend-wasm-simd.wasm instead of https://www.a.com/tfjs-backend-wasm-simd.wasm

Environment

  • Human library version?
    3.3.5
  • Built-in demo or custom code?
    custom code
  • Type of module used (e.g. js, esm, esm-nobundle)?
    esm
  • TensorFlow/JS version (if not using bundled module)?
    4.22.0
  • Browser or NodeJS and version (e.g. NodeJS 14.15 or Chrome 89)?
    Chrome 134.0.6998 (webview)
  • OS and Hardware platform (e.g. Windows 10, Ubuntu Linux on x64, Android 10)
    Android 15
  • Packager (if any) (e.g, webpack, rollup, parcel, esbuild, etc.)?
    Vite
  • Framework (if any) (e.g. React, NextJS, etc.)?
    React

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions