DefTruth
DefTruth
可以看一下这个issue: * https://github.com/DefTruth/RobustVideoMatting.lite.ai.toolkit/issues/12 你这里看起来像是downsample_ratio的数据类型不对。
你看看upsample_bilnear2d对于scale_factor的要求吧,需要是 float元组或float,不是Tensor
可以参考我写的一个动态onnx推理的python版本,在我fork的分支里的inference_onnx.py(可以推理视频): * https://github.com/DefTruth/RobustVideoMatting/blob/onnx/inference_onnx.py 以及我在RVM里的PR: * https://github.com/PeterL1n/RobustVideoMatting/pull/27 我这个仓库的C++ API有推理视频的接口啊,你看下README.md
请看以下这个issue中的讨论,已经有说明: * #12 至于理解为什么这样做,可能需要你看一下RVM的论文,以及它的pytorch源码进行理解。
这我就不太清楚了,openvino我也没玩过
你的数据预处理出错了。为啥是减去这些均值呢?RVM的源码没有啊。它的预处理是: ```python transform = transforms.Compose([ transforms.Resize(input_resize[::-1]), transforms.ToTensor() ]) ``` transforms.ToTensor()里面做了归一化,x=x/255.
你要不考虑直接用RVM官方提供的onnx吧,然后用我写的inference_onnx.py来推理,效果应该是没问题的。openvino我是真不了解,用的太少了。
我没有保留我转的静态onnx,我拿来转静态的MNN和TNN文件后就删掉了。ONNXRuntime版本的我是拿动态的来推的。过去大半年啦.....
鉴于问这个问题的人比较多,我写了一份详细的知乎教程,请参考: * [🔧填坑: RobustVideoMatting(5k+🔥 star)视频抠图静态ONNX模型转换](https://zhuanlan.zhihu.com/p/459088407)
可以参考我在lite.ai.toolkit的一个回答: * https://github.com/DefTruth/lite.ai.toolkit/issues/223 ```C++ cv::Mat out_mat = fgr_mat.mul(three_channel_pha_mat) + bgr_mat.mul(1. - three_channel_pha_mat); ``` 应该是用类似的逻辑,opencv的mul方法支持相同size大小的Mat进行逐元素运算。或者先将fgr_mat和img_bgr用split成三个通道,逐个通道运算后合并就行。 ```C++ std::vector fgr_mat_channels, bgr_mat_channels; cv::split(fgr_mat, fgr_mat_channels); cv::split(img_bgr, bgr_mat_channels); auto rmat = fgr_mat_channels.at(0); auto bmat = fgr_mat_channels.at(1);...