Skip to content
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

ScatterElements not supported #136

Closed
leavittx opened this issue Jan 30, 2021 · 10 comments
Closed

ScatterElements not supported #136

leavittx opened this issue Jan 30, 2021 · 10 comments

Comments

@leavittx
Copy link

Hi. This is similar to #124
The solution suggested isn't any good: it's much worser quality-wise.
ScatterElements should be properly supported in order to allow sophisticated models usage inside Unity

@AlexRibard
Copy link
Collaborator

@leavittx thanks for the suggestion, we will take note.
If you have a specific model which uses that op, feel free to share it as it so we can test that it works

@leavittx
Copy link
Author

leavittx commented Feb 7, 2021

@brgishy
Copy link

brgishy commented Mar 24, 2021

If Barracuda could run the BackgroundMattingV2 onnx model, that would be amazing!

@AlexRibard
Copy link
Collaborator

agreed, bumping up the priority

@FlorentGuinier
Copy link

ScatterElement support have been added to the backlog, closing the github issue. Will let you guys know when it happens (no ETA for now).

@AlexRibard
Copy link
Collaborator

AlexRibard commented Sep 16, 2021

Hey guys, I wanted to say that we added support for BackgroundMattingv2.
It will be present in 2.3.0
It does require you exporting the model with fixed input size. But otherwise than that it works on the base model.

@tramper2
Copy link

tramper2 commented Dec 2, 2021

Hey guys, I wanted to say that we added support for BackgroundMattingv2. It will be present in 2.3.0 It does require you exporting the model with fixed input size. But otherwise than that it works on the base model.

I am using barracuda 2.3.1

Still Error "Asset import failed, "Assets/Artractive/Onnx/onnx_mobilenetv2_hd.onnx" > OnnxImportException: Unknown type ScatterElements encountered while parsing layer 878."

@AlexRibard
Copy link
Collaborator

AlexRibard commented Dec 2, 2021

Hello! In order to be able to use BackgroundMattingV2 models, you'll need to export the .pth to onnx with fixed input size
Here is the code to achieve that:

    // https://github.com/PeterL1n/BackgroundMattingV2
    // Download the github repo.
    // Download the pth models here https://drive.google.com/drive/folders/1cbetlrKREitIgjnIikG1HdM4x72FtgBh
    // Execute this script:
       import torch
    
       from model import MattingBase, MattingRefine
    
       for model_backbone in ['resnet101', 'resnet50', 'mobilenetv2']:
           model = MattingBase(model_backbone)
           model.load_state_dict(torch.load('pytorch_' + model_backbone + '.pth', map_location='cpu'), strict=False)
    
           src = torch.randn(2, 3, 224, 224)
           bgr = torch.randn(2, 3, 224, 224)
    
           # Export ONNX
           input_names=['src', 'bgr']
           output_names = ['pha', 'fgr', 'err', 'hid']
    
    
           torch.onnx.export(
               model=model,
               args=(src, bgr),
               f='MattingBase_' + model_backbone + '.onnx',
               verbose=True,
               opset_version=12,
               do_constant_folding=True,
               input_names=input_names,
               output_names=output_names)

Let me know how that works out for you

@leavittx
Copy link
Author

Hi there!
I was able to convert the model and import in Unity 2021.2.15f1 / Barracuda 3.0.0. Great work!
Opening another issue for a newer model which was released just recently and doesn't require background clean image :)

image

@Thaina
Copy link

Thaina commented Aug 24, 2022

3.0.0 still got OnnxImportException: Unknown type ScatterElements encountered while parsing layer 2704.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants