|
|
@@ -201,7 +201,7 @@ def single_point_to_heatmap(keypoints, rois, heatmap_size):
|
|
|
y = keypoints[..., 1].unsqueeze(1)
|
|
|
|
|
|
|
|
|
- gs = generate_gaussian_heatmaps(x, y,num_points=1, heatmap_size=heatmap_size, sigma=2.0)
|
|
|
+ gs = generate_gaussian_heatmaps(x, y,num_points=1, heatmap_size=heatmap_size, sigma=1.0)
|
|
|
# show_heatmap(gs[0],'target')
|
|
|
all_roi_heatmap = []
|
|
|
for roi, heatmap in zip(rois, gs):
|
|
|
@@ -648,9 +648,12 @@ def lines_features_align(features, proposals, img_size):
|
|
|
align_feat_list.append(align_feat)
|
|
|
|
|
|
# print(f'align_feat_list:{align_feat_list}')
|
|
|
- feats_tensor = torch.cat(align_feat_list)
|
|
|
+ if len(align_feat_list) > 0:
|
|
|
+ feats_tensor = torch.cat(align_feat_list)
|
|
|
|
|
|
- print(f'align features :{feats_tensor.shape}')
|
|
|
+ print(f'align features :{feats_tensor.shape}')
|
|
|
+ else:
|
|
|
+ feats_tensor = None
|
|
|
|
|
|
return feats_tensor
|
|
|
|
|
|
@@ -1487,7 +1490,7 @@ class RoIHeads(nn.Module):
|
|
|
|
|
|
# print(f'line_features from line_roi_pool:{line_features.shape}')
|
|
|
#(b,256,512,512)
|
|
|
- line_features = self.channel_compress(features['0'])
|
|
|
+ cs_features = self.channel_compress(features['0'])
|
|
|
#(b.8,512,512)
|
|
|
|
|
|
|
|
|
@@ -1501,26 +1504,38 @@ class RoIHeads(nn.Module):
|
|
|
print(f'ap_proposal:{ap.shape}')
|
|
|
|
|
|
filtered_proposals = [proposal for proposal in all_proposals if proposal.shape[0] > 0]
|
|
|
- filtered_proposals_tensor=torch.cat(filtered_proposals)
|
|
|
+ if len(filtered_proposals) > 0:
|
|
|
+ filtered_proposals_tensor=torch.cat(filtered_proposals)
|
|
|
+ print(f'filtered_proposals_tensor:{filtered_proposals_tensor.shape}')
|
|
|
+
|
|
|
line_proposals_tensor=torch.cat(line_proposals)
|
|
|
|
|
|
print(f'line_proposals_tensor:{line_proposals_tensor.shape}')
|
|
|
- print(f'filtered_proposals_tensor:{filtered_proposals_tensor.shape}')
|
|
|
+
|
|
|
|
|
|
point_proposals_tensor=torch.cat(point_proposals)
|
|
|
print(f'point_proposals_tensor:{point_proposals_tensor.shape}')
|
|
|
|
|
|
|
|
|
# line_features = lines_features_align(line_features, filtered_proposals, image_shapes)
|
|
|
- line_features = lines_features_align(line_features, point_proposals, image_shapes)
|
|
|
- print(f'line_features from features_align:{line_features.shape}')
|
|
|
|
|
|
- line_features = self.line_head(line_features)
|
|
|
+ point_features = lines_features_align(cs_features, point_proposals, image_shapes)
|
|
|
+
|
|
|
+ line_features = lines_features_align(cs_features, line_proposals, image_shapes)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ print(f'line_features from features_align:{cs_features.shape}')
|
|
|
+
|
|
|
+ cs_features = self.line_head(cs_features)
|
|
|
#(N,1,512,512)
|
|
|
- print(f'line_features from line_head:{line_features.shape}')
|
|
|
+ print(f'line_features from line_head:{cs_features.shape}')
|
|
|
# line_logits = self.line_predictor(line_features)
|
|
|
|
|
|
- line_logits = line_features
|
|
|
+ line_logits = cs_features
|
|
|
print(f'line_logits:{line_logits.shape}')
|
|
|
|
|
|
loss_line = {}
|
|
|
@@ -1540,26 +1555,27 @@ class RoIHeads(nn.Module):
|
|
|
# line_logits, line_proposals, gt_lines, pos_matched_idxs
|
|
|
# )
|
|
|
# iou_loss = line_iou_loss(line_logits, line_proposals, gt_lines, pos_matched_idxs, img_size)
|
|
|
+
|
|
|
gt_lines_tensor=torch.cat(gt_lines)
|
|
|
gt_points_tensor = torch.cat(gt_points)
|
|
|
print(f'gt_lines_tensor:{gt_lines_tensor.shape}')
|
|
|
print(f'gt_points_tensor:{gt_points_tensor.shape}')
|
|
|
- if gt_lines_tensor.shape[0]>0 :
|
|
|
+ if gt_lines_tensor.shape[0]>0 and line_features is not None:
|
|
|
loss_line = lines_point_pair_loss(
|
|
|
- line_logits, line_proposals, gt_lines, line_pos_matched_idxs
|
|
|
+ line_features, line_proposals, gt_lines, line_pos_matched_idxs
|
|
|
)
|
|
|
loss_line_iou = line_iou_loss(line_logits, line_proposals, gt_lines, line_pos_matched_idxs, img_size)
|
|
|
|
|
|
- if gt_points_tensor.shape[0]>0:
|
|
|
+ if gt_points_tensor.shape[0]>0 and point_features is not None:
|
|
|
loss_point = compute_point_loss(
|
|
|
- line_logits, point_proposals, gt_points, point_pos_matched_idxs
|
|
|
+ point_features, point_proposals, gt_points, point_pos_matched_idxs
|
|
|
)
|
|
|
|
|
|
if not loss_line:
|
|
|
- loss_line = torch.tensor(0.0, device=line_features.device)
|
|
|
+ loss_line = torch.tensor(0.0, device=cs_features.device)
|
|
|
|
|
|
if not loss_line_iou:
|
|
|
- loss_line_iou = torch.tensor(0.0, device=line_features.device)
|
|
|
+ loss_line_iou = torch.tensor(0.0, device=cs_features.device)
|
|
|
|
|
|
loss_line = {"loss_line": loss_line}
|
|
|
loss_line_iou = {'loss_line_iou': loss_line_iou}
|
|
|
@@ -1590,10 +1606,10 @@ class RoIHeads(nn.Module):
|
|
|
)
|
|
|
|
|
|
if not loss_line :
|
|
|
- loss_line=torch.tensor(0.0,device=line_features.device)
|
|
|
+ loss_line=torch.tensor(0.0,device=cs_features.device)
|
|
|
|
|
|
if not loss_line_iou :
|
|
|
- loss_line_iou=torch.tensor(0.0,device=line_features.device)
|
|
|
+ loss_line_iou=torch.tensor(0.0,device=cs_features.device)
|
|
|
|
|
|
loss_line = {"loss_line": loss_line}
|
|
|
loss_line_iou = {'loss_line_iou': loss_line_iou}
|