|
@@ -13,7 +13,7 @@ import libs.vision_libs.models.detection._utils as det_utils
|
|
|
from collections import OrderedDict
|
|
from collections import OrderedDict
|
|
|
|
|
|
|
|
from models.line_detect.heads.head_losses import point_inference, compute_point_loss, line_iou_loss, \
|
|
from models.line_detect.heads.head_losses import point_inference, compute_point_loss, line_iou_loss, \
|
|
|
- lines_point_pair_loss, features_align, line_inference, compute_arc_loss
|
|
|
|
|
|
|
+ lines_point_pair_loss, features_align, line_inference, compute_arc_loss, arc_inference
|
|
|
|
|
|
|
|
|
|
|
|
|
def fastrcnn_loss(class_logits, box_regression, labels, regression_targets):
|
|
def fastrcnn_loss(class_logits, box_regression, labels, regression_targets):
|
|
@@ -954,7 +954,7 @@ class RoIHeads(nn.Module):
|
|
|
gt_lines = [t["lines"] for t in targets if "lines" in t]
|
|
gt_lines = [t["lines"] for t in targets if "lines" in t]
|
|
|
|
|
|
|
|
|
|
|
|
|
- print(f'gt_lines:{gt_lines[0].shape}')
|
|
|
|
|
|
|
+ # print(f'gt_lines:{gt_lines[0].shape}')
|
|
|
h, w = targets[0]["img_size"]
|
|
h, w = targets[0]["img_size"]
|
|
|
img_size = h
|
|
img_size = h
|
|
|
|
|
|
|
@@ -1161,6 +1161,7 @@ class RoIHeads(nn.Module):
|
|
|
# print(f'labels:{labels}')
|
|
# print(f'labels:{labels}')
|
|
|
arc_proposals = [p["boxes"] for p in result]
|
|
arc_proposals = [p["boxes"] for p in result]
|
|
|
print(f'boxes_proposals:{len(arc_proposals)}')
|
|
print(f'boxes_proposals:{len(arc_proposals)}')
|
|
|
|
|
+ print(f'boxes_proposals:{len(arc_proposals)}')
|
|
|
|
|
|
|
|
# if line_proposals is None or len(line_proposals) == 0:
|
|
# if line_proposals is None or len(line_proposals) == 0:
|
|
|
# # è¿å空ç¹å¾æè
è·³è¿è¯¥é¨å计ç®
|
|
# # è¿å空ç¹å¾æè
è·³è¿è¯¥é¨å计ç®
|
|
@@ -1195,7 +1196,7 @@ class RoIHeads(nn.Module):
|
|
|
arc_pos_matched_idxs.append(matched_idxs[img_id][arc_pos])
|
|
arc_pos_matched_idxs.append(matched_idxs[img_id][arc_pos])
|
|
|
|
|
|
|
|
else:
|
|
else:
|
|
|
- pos_matched_idxs = None
|
|
|
|
|
|
|
+ arc_pos_matched_idxs = None
|
|
|
|
|
|
|
|
feature_logits = self.arc_forward1(features, image_shapes, arc_proposals)
|
|
feature_logits = self.arc_forward1(features, image_shapes, arc_proposals)
|
|
|
|
|
|
|
@@ -1212,15 +1213,15 @@ class RoIHeads(nn.Module):
|
|
|
h, w = targets[0]["img_size"]
|
|
h, w = targets[0]["img_size"]
|
|
|
img_size = h
|
|
img_size = h
|
|
|
|
|
|
|
|
- gt_arcs_tensor = torch.zeros(0, 0)
|
|
|
|
|
|
|
+ # gt_arcs_tensor = torch.zeros(0, 0)
|
|
|
# if len(gt_arcs) > 0:
|
|
# if len(gt_arcs) > 0:
|
|
|
- # gt_arcs_tensor = torch.cat(gt_arcs)
|
|
|
|
|
- # print(f'gt_arcs_tensor:{gt_arcs_tensor.shape}')
|
|
|
|
|
-
|
|
|
|
|
|
|
+ # gt_arcs_tensor = torch.cat(gt_arcs)
|
|
|
|
|
+ # print(f'gt_arcs_tensor:{gt_arcs_tensor.shape}')
|
|
|
|
|
+ #
|
|
|
# if gt_arcs_tensor.shape[0] > 0:
|
|
# if gt_arcs_tensor.shape[0] > 0:
|
|
|
# print(f'start to compute point_loss')
|
|
# print(f'start to compute point_loss')
|
|
|
-
|
|
|
|
|
- loss_arc=compute_arc_loss(feature_logits,arc_proposals,gt_arcs,arc_pos_matched_idxs)
|
|
|
|
|
|
|
+ if len(gt_arcs) > 0 and feature_logits is not None:
|
|
|
|
|
+ loss_arc = compute_arc_loss(feature_logits, arc_proposals, gt_arcs, arc_pos_matched_idxs)
|
|
|
|
|
|
|
|
if loss_arc is None:
|
|
if loss_arc is None:
|
|
|
print(f'loss_arc is None111')
|
|
print(f'loss_arc is None111')
|
|
@@ -1243,9 +1244,8 @@ class RoIHeads(nn.Module):
|
|
|
gt_arcs_tensor = torch.cat(gt_arcs)
|
|
gt_arcs_tensor = torch.cat(gt_arcs)
|
|
|
print(f'gt_arcs_tensor:{gt_arcs_tensor.shape}')
|
|
print(f'gt_arcs_tensor:{gt_arcs_tensor.shape}')
|
|
|
|
|
|
|
|
- if gt_arcs_tensor.shape[0] > 0:
|
|
|
|
|
- print(f'start to compute point_loss')
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if gt_arcs_tensor.shape[0] > 0 and feature_logits is not None:
|
|
|
|
|
+ print(f'start to compute arc_loss')
|
|
|
loss_arc = compute_arc_loss(feature_logits, arc_proposals, gt_arcs, arc_pos_matched_idxs)
|
|
loss_arc = compute_arc_loss(feature_logits, arc_proposals, gt_arcs, arc_pos_matched_idxs)
|
|
|
|
|
|
|
|
if loss_arc is None:
|
|
if loss_arc is None:
|
|
@@ -1270,8 +1270,8 @@ class RoIHeads(nn.Module):
|
|
|
r["arcs"] = keypoint_prob
|
|
r["arcs"] = keypoint_prob
|
|
|
r["arcs_scores"] = kps
|
|
r["arcs_scores"] = kps
|
|
|
|
|
|
|
|
- print(f'loss_point:{loss_point}')
|
|
|
|
|
- losses.update(loss_point)
|
|
|
|
|
|
|
+ # print(f'loss_point:{loss_point}')
|
|
|
|
|
+ losses.update(loss_arc)
|
|
|
print(f'losses:{losses}')
|
|
print(f'losses:{losses}')
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1369,7 +1369,7 @@ class RoIHeads(nn.Module):
|
|
|
def line_forward1(self, features, image_shapes, line_proposals):
|
|
def line_forward1(self, features, image_shapes, line_proposals):
|
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
|
# cs_features= features['0']
|
|
# cs_features= features['0']
|
|
|
- print(f'features-0:{features['0'].shape}')
|
|
|
|
|
|
|
+ # print(f'features-0:{features['0'].shape}')
|
|
|
cs_features = self.channel_compress(features['0'])
|
|
cs_features = self.channel_compress(features['0'])
|
|
|
filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
|
if len(filtered_proposals) > 0:
|
|
if len(filtered_proposals) > 0:
|
|
@@ -1387,7 +1387,7 @@ class RoIHeads(nn.Module):
|
|
|
def line_forward2(self, features, image_shapes, line_proposals):
|
|
def line_forward2(self, features, image_shapes, line_proposals):
|
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
|
# cs_features= features['0']
|
|
# cs_features= features['0']
|
|
|
- print(f'features-0:{features['0'].shape}')
|
|
|
|
|
|
|
+ # print(f'features-0:{features['0'].shape}')
|
|
|
# cs_features = self.channel_compress(features['0'])
|
|
# cs_features = self.channel_compress(features['0'])
|
|
|
cs_features=features['0']
|
|
cs_features=features['0']
|
|
|
filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
@@ -1410,7 +1410,7 @@ class RoIHeads(nn.Module):
|
|
|
def line_forward3(self, features, image_shapes, line_proposals):
|
|
def line_forward3(self, features, image_shapes, line_proposals):
|
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
print(f'line_proposals:{len(line_proposals)}')
|
|
|
# cs_features= features['0']
|
|
# cs_features= features['0']
|
|
|
- print(f'features-0:{features['0'].shape}')
|
|
|
|
|
|
|
+ # print(f'features-0:{features['0'].shape}')
|
|
|
# cs_features = self.channel_compress(features['0'])
|
|
# cs_features = self.channel_compress(features['0'])
|
|
|
cs_features=features['0']
|
|
cs_features=features['0']
|
|
|
# filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
# filtered_proposals = [proposal for proposal in line_proposals if proposal.shape[0] > 0]
|
|
@@ -1433,7 +1433,7 @@ class RoIHeads(nn.Module):
|
|
|
def point_forward1(self, features, image_shapes, proposals):
|
|
def point_forward1(self, features, image_shapes, proposals):
|
|
|
print(f'point_proposals:{len(proposals)}')
|
|
print(f'point_proposals:{len(proposals)}')
|
|
|
# cs_features= features['0']
|
|
# cs_features= features['0']
|
|
|
- print(f'features-0:{features['0'].shape}')
|
|
|
|
|
|
|
+ # print(f'features-0:{features['0'].shape}')
|
|
|
# cs_features = self.channel_compress(features['0'])
|
|
# cs_features = self.channel_compress(features['0'])
|
|
|
cs_features=features['0']
|
|
cs_features=features['0']
|
|
|
# filtered_proposals = [proposal for proposal in proposals if proposal.shape[0] > 0]
|
|
# filtered_proposals = [proposal for proposal in proposals if proposal.shape[0] > 0]
|
|
@@ -1457,7 +1457,7 @@ class RoIHeads(nn.Module):
|
|
|
def arc_forward1(self, features, image_shapes, proposals):
|
|
def arc_forward1(self, features, image_shapes, proposals):
|
|
|
print(f'point_proposals:{len(proposals)}')
|
|
print(f'point_proposals:{len(proposals)}')
|
|
|
# cs_features= features['0']
|
|
# cs_features= features['0']
|
|
|
- print(f'features-0:{features['0'].shape}')
|
|
|
|
|
|
|
+ # print(f'features-0:{features['0'].shape}')
|
|
|
# cs_features = self.channel_compress(features['0'])
|
|
# cs_features = self.channel_compress(features['0'])
|
|
|
cs_features=features['0']
|
|
cs_features=features['0']
|
|
|
# filtered_proposals = [proposal for proposal in proposals if proposal.shape[0] > 0]
|
|
# filtered_proposals = [proposal for proposal in proposals if proposal.shape[0] > 0]
|