tsing90 / pytorch_semantic_human_matting

This is an unofficial implementation of the paper "Semantic human matting":
https://arxiv.org/pdf/1809.01354.pdf
83 stars 18 forks source link

关于test.py中测试t_net的一个问题 #35

Open jiusigua opened 4 years ago

jiusigua commented 4 years ago

@tsing90 已经完成t模型和m模型的训练,但是在test.py中测试m_net是遇到一个问题,运行命令python test.py --train_phase=pre_train_m_net,报错如下: use GPU Loading model from ./ckpt/pre_train_m_net/model/model_obj.pth... torch.Size([1, 3, 635, 408]) torch.Size([1, 3, 640, 408]) Traceback (most recent call last): File "test.py", line 159, in main(args) File "test.py", line 155, in main test(args, myModel) File "test.py", line 138, in test frame_seg = seg_process(args, (tensor_img, tensor_tri), net) File "test.py", line 67, in seg_process alpha = net(inputs[0], inputs[1]) File "/home/gpower/anaconda3/envs/pytorch0.4/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/home/gpower/ztj/cv/Matting/pytorch_semantic_human_matting/model/network.py", line 39, in forward m_net_input = torch.cat((input, trimap), 1) RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 640 and 635 in dimension 2 at /opt/conda/conda-bld/pytorch_1535491974311/work/aten/src/THC/generic/THCTensorMath.cu:87

发现图片通过t_net预测的trimap图发生了尺寸的改变,原图是(635,408),而trimap图是(640,408)我仔细看了源代码,也没有找到原因,,请问这是什么原因造成的呢?谢谢!