Unverified Commit 076b2cbd authored by encore-zhou's avatar encore-zhou Committed by GitHub
Browse files

[fix]: fix bug of H3DNet config (#105)

* add h3d backbone

* add h3d backbone

* add h3dnet

* modify scannet config

* fix bugs for proposal refine

* fix bugs for test backbone

* add primitive head test

* modify h3dhead

* modify h3d head

* update loss weight config

* fix bugs for h3d head loss

* modify h3d head get targets function

* update h3dnet base config

* modify weighted loss

* Revert "Merge branch 'h3d_u2' into 'master'"

This reverts merge request !5

* fix depth box3d

* fix bugs of test box3d
parent 3c166ae5
...@@ -219,7 +219,8 @@ model = dict( ...@@ -219,7 +219,8 @@ model = dict(
mlp_channels=[256, 128, 128, 128], mlp_channels=[256, 128, 128, 128],
use_xyz=True, use_xyz=True,
normalize_xyz=True), normalize_xyz=True),
pred_layer_cfg=dict(in_channels=128, shared_conv_channels=(128, 128)), pred_layer_cfg=dict(
in_channels=128, shared_conv_channels=(128, 128), bias=True),
conv_cfg=dict(type='Conv1d'), conv_cfg=dict(type='Conv1d'),
norm_cfg=dict(type='BN1d'), norm_cfg=dict(type='BN1d'),
objectness_loss=dict( objectness_loss=dict(
......
...@@ -274,7 +274,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): ...@@ -274,7 +274,7 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
torch.Tensor: Surface and line center of bounding boxes. torch.Tensor: Surface and line center of bounding boxes.
""" """
obj_size = self.dims obj_size = self.dims
center = self.gravity_center center = self.gravity_center.view(-1, 1, 3)
batch_size = center.shape[0] batch_size = center.shape[0]
rot_sin = torch.sin(-self.yaw) rot_sin = torch.sin(-self.yaw)
...@@ -290,8 +290,9 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): ...@@ -290,8 +290,9 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
offset = obj_size.new_tensor([[0, 0, 1], [0, 0, -1], [0, 1, 0], offset = obj_size.new_tensor([[0, 0, 1], [0, 0, -1], [0, 1, 0],
[0, -1, 0], [1, 0, 0], [-1, 0, 0]]) [0, -1, 0], [1, 0, 0], [-1, 0, 0]])
offset = offset.view(1, 6, 3) / 2 offset = offset.view(1, 6, 3) / 2
surface_3d = (offset * obj_size.view(batch_size, 1, 3).repeat( surface_3d = (offset *
1, 6, 1)).transpose(0, 1).reshape(-1, 3) obj_size.view(batch_size, 1, 3).repeat(1, 6, 1)).reshape(
-1, 3)
# Get the object line center # Get the object line center
offset = obj_size.new_tensor([[1, 0, 1], [-1, 0, 1], [0, 1, 1], offset = obj_size.new_tensor([[1, 0, 1], [-1, 0, 1], [0, 1, 1],
...@@ -301,17 +302,17 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes): ...@@ -301,17 +302,17 @@ class DepthInstance3DBoxes(BaseInstance3DBoxes):
offset = offset.view(1, 12, 3) / 2 offset = offset.view(1, 12, 3) / 2
line_3d = (offset * line_3d = (offset *
obj_size.view(batch_size, 1, 3).repeat(1, 12, 1)).transpose( obj_size.view(batch_size, 1, 3).repeat(1, 12, 1)).reshape(
0, 1).reshape(-1, 3) -1, 3)
surface_rot = rot_mat_T.repeat(6, 1, 1) surface_rot = rot_mat_T.repeat(6, 1, 1)
surface_3d = torch.matmul( surface_3d = torch.matmul(
surface_3d.unsqueeze(-2), surface_rot.transpose(2, 1)).squeeze(-2) surface_3d.unsqueeze(-2), surface_rot.transpose(2, 1)).squeeze(-2)
surface_center = center.repeat(6, 1) + surface_3d surface_center = center.repeat(1, 6, 1).reshape(-1, 3) + surface_3d
line_rot = rot_mat_T.repeat(12, 1, 1) line_rot = rot_mat_T.repeat(12, 1, 1)
line_3d = torch.matmul( line_3d = torch.matmul(
line_3d.unsqueeze(-2), line_rot.transpose(2, 1)).squeeze(-2) line_3d.unsqueeze(-2), line_rot.transpose(2, 1)).squeeze(-2)
line_center = center.repeat(12, 1) + line_3d line_center = center.repeat(1, 12, 1).reshape(-1, 3) + line_3d
return surface_center, line_center return surface_center, line_center
...@@ -1142,42 +1142,43 @@ def test_depth_boxes3d(): ...@@ -1142,42 +1142,43 @@ def test_depth_boxes3d():
boxes = DepthInstance3DBoxes( boxes = DepthInstance3DBoxes(
boxes, box_dim=boxes.shape[-1], with_yaw=True, origin=(0.5, 0.5, 0.5)) boxes, box_dim=boxes.shape[-1], with_yaw=True, origin=(0.5, 0.5, 0.5))
surface_center, line_center = boxes.get_surface_line_center() surface_center, line_center = boxes.get_surface_line_center()
expected_surface_center = torch.tensor([[0.3294, 1.0359, 0.8031], expected_surface_center = torch.tensor([[0.3294, 1.0359, 0.8031],
[-2.4630, -2.6324, -0.0620],
[0.3294, 1.0359, -0.5689], [0.3294, 1.0359, -0.5689],
[-2.4630, -2.6324, -0.2612],
[0.5949, 1.5317, 0.1171], [0.5949, 1.5317, 0.1171],
[-2.1828, -1.7826, -0.1616], [0.1533, 0.5018, 0.1171],
[0.0640, 0.5401, 0.1171],
[-2.7432, -3.4822, -0.1616],
[0.8064, 0.7805, 0.1171], [0.8064, 0.7805, 0.1171],
[-2.0260, -2.7765, -0.1616], [-0.1845, 1.2053, 0.1171],
[-0.1476, 1.2913, 0.1171], [-2.4630, -2.6324, -0.0620],
[-2.4630, -2.6324, -0.2612],
[-2.0406, -1.8436, -0.1616],
[-2.7432, -3.4822, -0.1616],
[-2.0574, -2.8496, -0.1616],
[-2.9000, -2.4883, -0.1616]]) [-2.9000, -2.4883, -0.1616]])
expected_line_center = torch.tensor([[0.8064, 0.7805, 0.8031], expected_line_center = torch.tensor([[0.8064, 0.7805, 0.8031],
[-2.0260, -2.7765, -0.0620], [-0.1845, 1.2053, 0.8031],
[-0.1476, 1.2913, 0.8031],
[-2.9000, -2.4883, -0.0620],
[0.5949, 1.5317, 0.8031], [0.5949, 1.5317, 0.8031],
[-2.1828, -1.7826, -0.0620], [0.1533, 0.5018, 0.8031],
[0.0640, 0.5401, 0.8031],
[-2.7432, -3.4822, -0.0620],
[0.8064, 0.7805, -0.5689], [0.8064, 0.7805, -0.5689],
[-2.0260, -2.7765, -0.2612], [-0.1845, 1.2053, -0.5689],
[-0.1476, 1.2913, -0.5689],
[-2.9000, -2.4883, -0.2612],
[0.5949, 1.5317, -0.5689], [0.5949, 1.5317, -0.5689],
[-2.1828, -1.7826, -0.2612], [0.1533, 0.5018, -0.5689],
[0.0640, 0.5401, -0.5689],
[-2.7432, -3.4822, -0.2612],
[1.0719, 1.2762, 0.1171], [1.0719, 1.2762, 0.1171],
[-1.7458, -1.9267, -0.1616], [0.6672, 0.3324, 0.1171],
[0.5410, 0.2847, 0.1171],
[-2.3062, -3.6263, -0.1616],
[0.1178, 1.7871, 0.1171], [0.1178, 1.7871, 0.1171],
[-2.6198, -1.6385, -0.1616], [-0.3606, 0.6713, 0.1171],
[-0.4131, 0.7956, 0.1171], [-2.0574, -2.8496, -0.0620],
[-2.9000, -2.4883, -0.0620],
[-2.0406, -1.8436, -0.0620],
[-2.7432, -3.4822, -0.0620],
[-2.0574, -2.8496, -0.2612],
[-2.9000, -2.4883, -0.2612],
[-2.0406, -1.8436, -0.2612],
[-2.7432, -3.4822, -0.2612],
[-1.6350, -2.0607, -0.1616],
[-2.3062, -3.6263, -0.1616],
[-2.4462, -1.6264, -0.1616],
[-3.1802, -3.3381, -0.1616]]) [-3.1802, -3.3381, -0.1616]])
assert torch.allclose(surface_center, expected_surface_center, atol=1e-04) assert torch.allclose(surface_center, expected_surface_center, atol=1e-04)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment