Closed gtrabanco closed 6 months ago
Same error with fixed code as expected.
Here the sample code that works with NodeJS (sharp package is not necessary):
import { removeBackground } from "@imgly/background-removal-node";
const url =
"https://balonmano.isquad.es/images/afiliacion_clubs/2898/square_35723432687275366a39.jpg";
try {
const imgBg = await removeBackground(url, {
model: "medium", // default but I want to be explicity with this
progress: (key, current, total) => {
console.log(`Downloading ${key}: ${current} of ${total}`);
},
});
sharp(await imgBg.arrayBuffer()).toFile("output.png");
} catch (error) {
console.log(error);
}
Output with NodeJS
$ node index.mjs
Downloading fetch:/models/medium: 88188479 of 88188479
Downloading compute:inference: 0 of 1
Output with Bun
$ bun index.mjs
Downloading fetch:/models/medium: 16384 of 88188479
Downloading fetch:/models/medium: 88188479 of 88188479
[1] 78105 segmentation fault bun index.mjs
Segfault is at Napi::InstanceWrap<InferenceSessionWrap>::InstanceMethodCallbackWrapper(napi_env__*, napi_callback_info__*)
when calling https://github.com/microsoft/onnxruntime/blob/785e2b1eaec2b2e69267cc9320f7749315c0e686/js/node/src/inference_session_wrap.cc#L51
Same error with transformers.js due onnyxruntime with Bun 1.0.11+84414f8fe
@imgly/background-removal-node
examples here now work as expected for me.
The transformers.js one works for me as well on my fork. Hopefully fixed will move upstream soon.
Yes, it is working now with Bun 1.0.21+837cbd60d
. I am closing this issue :)
Thanks @sroussey
What version of Bun is running?
1.0.4+387f1260c9dc0cea667b44ec0152fff0cd4def25
What platform is your computer?
Darwin 21.6.0 x86_64 i386
What steps can reproduce the bug?
Code of
index.ts
Sharp
I installed sharp because I though
@imgly/background-removal-node
was only accepting pngs so I tried also with this code in a new file calledindex.js
:What is the expected behavior?
Create
imgBg.png
file with, at least, a try to remove background of the image or any issue with remove background package. If all goes right and model could remove the image background should be a transparent background png with the shield shape.What do you see instead?
Additional information
This package requires
onnyxruntime-node
which has opened issues due it does not work currently on bun:3574
4616
My package of using the code can be wrong but if thats the case I think segfault is not an expected error BTW. If segfault can be an expected error then this issue I opened in the package repository should be tracked as well: