-
Notifications
You must be signed in to change notification settings - Fork 721
/
box_coder_builder.py
28 lines (22 loc) · 964 Bytes
/
box_coder_builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import numpy as np
from second.protos import box_coder_pb2
from second.pytorch.core.box_coders import (BevBoxCoderTorch,
GroundBox3dCoderTorch)
def build(box_coder_config):
"""Create optimizer based on config.
Args:
optimizer_config: A Optimizer proto message.
Returns:
An optimizer and a list of variables for summary.
Raises:
ValueError: when using an unsupported input data type.
"""
box_coder_type = box_coder_config.WhichOneof('box_coder')
if box_coder_type == 'ground_box3d_coder':
cfg = box_coder_config.bev_box_coder
return GroundBox3dCoderTorch(cfg.linear_dim, cfg.encode_angle_vector)
elif box_coder_type == 'bev_box_coder':
cfg = box_coder_config.bev_box_coder
return BevBoxCoderTorch(cfg.linear_dim, cfg.encode_angle_vector, cfg.z_fixed, cfg.h_fixed)
else:
raise ValueError("unknown box_coder type")