-
Notifications
You must be signed in to change notification settings - Fork 917
Remove background - onnx-community/BEN2-ONNX - bug when using webGPU #1272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
cc @fs-eire in case you have any ideas. |
Looking into the issue... |
Hi @pikilipita do you have a full index.html that reproduces this issue? Something that generates the binary image and displays it on the page? |
@prathikr |
Hi @pikilipita, thank you for your patience. @fs-eire and I looked at your model and noticed a peculiar pattern. In both the multifieldcrossatt and dec_blk modules there is a softmax that feeds to a cast-to-fp32 followed by a cast-to-fp16: Can you please double check how the multifieldcrossatt and dec_blk modules are implemented to see if the second pattern can be followed? |
Hello @prathikr , thank you for looking into the issue, |
@xenova I see you uploaded the BEN2 model to HF model hub. Do you know where the model code is to check why the cast nodes are being exported incorrectly? |
It's using the float16 quantization script: https://github.com/huggingface/transformers.js/blob/main/scripts/float16.py, which is adapted from a bunch of other scripts. I'm pretty certain the bug is from there, for when there is already an existing cast node in the graph. Would greatly appreciate help in fixing it @prathikr if you have time. |
@xenova do you use BEN2_Base.onnx as input to this script? I can see the softmax --> cast to fp32 --> cast to fp16 is in the base model so this script may not be the issue. It is likely an issue in the original model implementation. I have a version of onnx-community/BEN2-ONNX with the swapped nodes and the script that swaps the nodes. I can share both via email if that would be helpful. |
System Info
transformers 3.4.1
macOs 14.7.4
Chrome 136
Environment/Platform
Description
While using onnx-community/BEN2-ONNX to remove background, the wasm version result is fine, but the webGPU result adds a 'ghost' on the mask:
the original image of this example be found here, but the ghosting issue is happening on all images I tested.
https://unsplash.com/photos/woman-standing-near-pink-concrete-wall-during-daytime-TT-ROxWj9nA
tested on transformers 3.4.1 with those settings:
var segmenter = await pipeline("background-removal", "onnx-community/BEN2-ONNX", { device:"webgpu" });
Reproduction
to reproduce, use those settings with any input image:
var segmenter = await pipeline("background-removal", "onnx-community/BEN2-ONNX", { device:"webgpu" });
The text was updated successfully, but these errors were encountered: