YexingWan / Fast-Portrait-Segmentation

The MNN base implementation of SINet for CPU realtime portrait segmentation
MIT License
63 stars 13 forks source link

about input format #5

Closed linghai06 closed 3 years ago

linghai06 commented 3 years ago

hi, nice work! 我看你的源代码输入格式是nhwc格式的, auto nhwcTensor = MNN::Tensor::create<float>({1, input_h, input_w, 3}, image.data, MNN::Tensor::TENSORFLOW); 但是reademe说到用的是pytorch的checkpoint,pytorch用的格式应该是nchw?

YexingWan commented 3 years ago

hi, 感谢你的提问。MNN默认是nchw顺序。而这里的nwhc是tensorflow的常用顺序,MNN的tensor可以定义维度顺序为TENSORFLOW的格式(mnn::Tensor::TENSORFLOW),在MNN模型infer时候会判定输入Tensor的格式为tensorflow的tensor并自动做转换。这里这样写只是懒得在做一次transfer而已,用MNN自带的机制做dimension transfer了😆

YexingWan commented 3 years ago

我暂时吧issue关闭啦,如果还有额外的问题可以再将issue从开起来,谢谢

DCC-lzhy commented 3 years ago

我也没明白,既然SINet是Pytorch训练得到的,是nchw格式,那为啥这边要用tensorflow的nhwc,这边为啥要做dimension transfer。