Open liuxiang2000-star opened 1 week ago
def forward(self, pheatmap, poffset, heatmap, mask, offset, offset_w, pbone, bone, bone_w, loc_map):#pheatmap.shape torch.Size([6, 34, 128, 128]) heatmap.shape torch.Size([6, 34, 128, 128]) mask.shape torch.Size([6, 51, 128, 128])
#mask[:, :self.num_joints] torch.Size([6, 17, 128, 128])
#print("pheatmap.shape", pheatmap.shape)
#print("heatmap.shape", poffset.shape)
#print("mask.shape", mask.shape)
#print("mask[:, :self.num_joints*2]", mask[:, :self.num_joints*2].shape)
heatmap_loss = self.heatmap_loss(pheatmap, heatmap, mask[:, :self.num_joints*2])#只选取self.num_joints个点
#heatmap_loss = self.heatmap_loss(pheatmap, heatmap, mask[:, :self.num_joints])
heatmap_loss = heatmap_loss * self.heatmap_loss_factor
offset_loss = self.offset_loss(poffset, offset, offset_w, loc_map, self.num_joints)
offset_loss = offset_loss * self.offset_loss_factor
bone_loss = self.bone_loss(pbone, bone, bone_w)
bone_loss = bone_loss * self.bone_loss_factor
# 选点 loc_loss = self.loc_loss(loc_map, mask[:, self.num_joints:])
print('loc_map.shape', loc_map.shape)
loc_loss = self.loc_loss(loc_map, mask[:, self.num_joints*2:])
loc_loss = loc_loss * self.loc_loss_factor
return heatmap_loss, offset_loss, bone_loss, loc_loss
在这里做了修改,可以执行,不知道是否正确
是的,感谢你的指正,这里对应DecenterNet/lib/dataset/target_generators/target_generators.py line86, 前34是可见和不可见关节点的heatmap的mask,后17是location map的mask。如果有其他问题欢迎讨论
建立环境摆放好coco相关数据集和模型之后执行 python tools/launch.py --cfg experiments/coco/w32/w32_4x_reg03_bs10_512_adam_lr1e-3_coco_x140.yaml --versionid 0 --train 1 在训练最开始的时候 59.585 Total estimated model params size (MB) Epoch 0: 0%| 0/10686 出现
File "/home/loftdusk/work/DecenterNet/lib/models/refine.py", line 71, in training_step self.loss(pheatmap, poffset, heatmap, mask, offset, offset_w, pbone, bone, bone_w, ploc) File "/home/loftdusk/anaconda3/envs/decenternet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(*input, *kwargs) File "/home/loftdusk/work/DecenterNet/lib/core/loss.py", line 90, in forward heatmap_loss = self.heatmap_loss(pheatmap, heatmap, mask[:, :self.num_joints]) File "/home/loftdusk/anaconda3/envs/decenternet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1110, in _call_impl return forward_call(input, kwargs) File "/home/loftdusk/work/DecenterNet/lib/core/loss.py", line 29, in forward loss = ((pred - gt)2) * mask RuntimeError: The size of tensor a (34) must match the size of tensor b (17) at non-singleton dimension 1 请教一下问题出在哪里,为什么pred会是34