PeterL1n / BackgroundMattingV2

Real-Time High-Resolution Background Matting
MIT License
6.85k stars 952 forks source link

How can I optimize for CPU #46

Open bianxg opened 3 years ago

bianxg commented 3 years ago

Thanks for your awesome work! I hope to apply it on CPU. How can I optimize it for CPU ? Any suggestions? Thanks.

bianxg commented 3 years ago

Can I optimizing trained model using openvino? Please refer the openvino's limit: https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_Supported_Frameworks_Layers.html

bianxg commented 3 years ago

https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_Convert_Model_From_ONNX.html

PeterL1n commented 3 years ago

You can give it a try and let me know how it goes.

bianxg commented 3 years ago

I tried and met a error, please refer https://github.com/openvinotoolkit/openvino/issues/3846

bianxg commented 3 years ago

Please refer the response on openvinotoolkit/openvino#3846 What should the input_shape be? Is [1,3,1080,1920] ok What's difference between the output pha_sm and pha? Thanks.

PeterL1n commented 3 years ago

The input shape is correct if your image is 1920x1080 resolution.

pha and fgr are the actual output. pha_sm is from the base network (You can refer to the architecture in the original research paper). It is only output for training.

bianxg commented 3 years ago

There is a challenge to support If. Any ideas? https://github.com/openvinotoolkit/openvino/issues/2406

bianxg commented 3 years ago

The input shape is correct if your image is 1920x1080 resolution.

pha and fgr are the actual output. pha_sm is from the base network (You can refer to the architecture in the original research paper). It is only output for training.

Please refer : https://blog.csdn.net/lhyyhlfornew/article/details/109562383

Can you remove If operator by modifying squeeze() using index method like the blog's method? Or how can I do it? Thanks.

PeterL1n commented 3 years ago

I see. The only place squeeze() is used is in refiner.py. You can change ref.squeeze(1) in refiner.py to ref[:, 0, :, :]. Then re-export ONNX. This should get rid of the if node.

972461099 commented 3 years ago

Hi,Does OpenVino accelerate only on Intel CPUs? Does it work for AMD?