Error when run demo code on Chrome
#1
by
tidus2102
- opened
hi, I try to run demo code but got error at this line:
const { output_image } = await model({ input_image: pixel_values });
main.js:
import { AutoModel, AutoProcessor, RawImage } from 'https://cdn.jsdelivr.net/npm/@huggingface/transformers';
// Load model and processor
const model_id = 'onnx-community/BiRefNet_T';
const model = await AutoModel.from_pretrained(model_id, { dtype: 'fp32' });
const processor = await AutoProcessor.from_pretrained(model_id);
// Load image from URL
const url = 'https://images.pexels.com/photos/5965592/pexels-photo-5965592.jpeg?auto=compress&cs=tinysrgb&w=1024';
const image = await RawImage.fromURL(url);
// Pre-process image
const { pixel_values } = await processor(image);
// Predict alpha matte
const { output_image } = await model({ input_image: pixel_values });
// Save output mask
const mask = await RawImage.fromTensor(output_image[0].sigmoid().mul(255).to('uint8')).resize(image.width, image.height);
mask.save('mask.png');
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Background Removal</title>
</head>
<body>
<script type="module" src="/main.js"></script>
</body>
</html>
Please help to check it. Thank you.
I am getting An error occurred during model execution: "246040216".
with 3.0.0-alpha.14
tidus2102
changed discussion title from
Error when run demo code
to Error when run demo code on Chrome
filed a webgpu issue for this:
https://github.com/microsoft/onnxruntime/issues/21968
Yes, using lots of memory but should still work.
Somebody is looking into it.