Fails on WebGPU
#2
by
notecola
- opened
Thanks for your great work!
Unfortunately webgpu doesn't seem to work with this model.
Any help is appreciated, perhaps loading a different export from local file?
Here is the error I am getting:
"Error: using ceil() in shape computation is not yet supported for MaxPool".
Sample code:
import { pipeline } from 'https://cdn.jsdelivr.net/npm/@huggingface/[email protected]';
const IMG_URL = 'https://huggingface.co/datasets/Xenova/transformers.js-docs/resolve/main/cats.jpg';
const detector = await pipeline(
'object-detection',
'onnx-community/dfine_s_coco-ONNX',
{ device: 'webgpu' }
);
const img = new Image();
img.crossOrigin = 'anonymous';
img.src = IMG_URL;
await img.decode();
const canvas = document.getElementById('canvas');
canvas.width = img.naturalWidth;
canvas.height = img.naturalHeight;
const ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
const preds = await detector(IMG_URL, { threshold: 0.5 });
ctx.strokeStyle = '#00FF00';
ctx.lineWidth = 2;
ctx.font = '18px sans-serif';
ctx.fillStyle = '#00FF00';
for (const { box, label, score } of preds) {
const { xmin, ymin, xmax, ymax } = box; // pixel coords
ctx.strokeRect(xmin, ymin, xmax - xmin, ymax - ymin);
ctx.fillText(`${label} ${(score * 100).toFixed(1)}%`,
xmin + 4, ymin > 20 ? ymin - 6 : ymin + 18);
}
See https://github.com/huggingface/transformers.js/issues/1435 for more info about this issue (it will be fixed in transformers.js v4)