transformers.js-examples
transformers.js-examples copied to clipboard
fix(models): use runtime device detection instead of hardcoded webgpu
Abstract
Removes hardcoded device: "webgpu" from model configs to let transformers.js automatically choose the optimal device at runtime. This avoids hard-failure on non-WebGPU environments, where gpu is explicitly set for running inference.
This maintains optimal performance on supported devices while ensuring the example works everywhere.
Before
Hard failure on non-WebGPU environments with "Unsupported device: webgpu
After
Auto-selects WebGPU when available, gracefully falls back to WASM