def __init__(self, **kwargs): # get target assigner & box_coder configs. assigner_cfg = kwargs["cfg"] target_assigner_config = assigner_cfg.target_assigner self.tasks = target_assigner_config.tasks # num_class=1, class_names=["Car"] box_coder_cfg = assigner_cfg.box_coder # "ground_box3d_coder" # get anchor_generator anchor_cfg = target_assigner_config.anchor_generators # anchor_generator_range anchor_generators = [] for a_cfg in anchor_cfg: anchor_generator = build_anchor_generator(a_cfg) anchor_generators.append(anchor_generator) # my addition self.target_class_names = [ anchor_generator.class_name for anchor_generator in anchor_generators ] self.target_class_ids = [1] # for car id self.enable_similar_type = assigner_cfg.get("enable_similar_type", False) if self.enable_similar_type: self.target_class_ids = [ 1, 2 ] # for car id # todo: addition of similar type # get target_assigner target_assigners = [] similarity_calc = build_similarity_metric( target_assigner_config.region_similarity_calculator) # nearest iou positive_fraction = target_assigner_config.sample_positive_fraction # -1 if positive_fraction < 0: positive_fraction = None flag = 0 for task in self.tasks: # { num_class=1, class_names=["Car"] } target_assigner = TargetAssigner( box_coder=build_box_coder( box_coder_cfg), # "ground_box3d_coder" anchor_generators=anchor_generators[flag:flag + task.num_class], region_similarity_calculator=similarity_calc, # nearest iou positive_fraction=positive_fraction, # None sample_size=target_assigner_config.sample_size, # 512 ) flag += task.num_class # 1 target_assigners.append(target_assigner) # results self.target_assigners = target_assigners self.out_size_factor = assigner_cfg.out_size_factor # 8 feature_map_size = [1, 200, 176] self.anchor_dicts_by_task = [ assigner.generate_anchors_dict(feature_map_size) for assigner in self.target_assigners ]
def __init__(self, **kwargs): # get configs assigner_cfg = kwargs["cfg"] target_assigner_config = assigner_cfg.target_assigner tasks = target_assigner_config.tasks # num_class=1, class_names=["Car"] box_coder_cfg = assigner_cfg.box_coder # type="ground_box3d_coder", n_dim=7, linear_dim=False, encode_angle_vector=False, # get anchor_generator anchor_cfg = target_assigner_config.anchor_generators anchor_generators = [] for a_cfg in anchor_cfg: anchor_generator = build_anchor_generator(a_cfg) anchor_generators.append(anchor_generator) ############# prepare configs and get target_assigner ############# # non-rotated iou similarity_calc = build_similarity_metric( target_assigner_config.region_similarity_calculator) positive_fraction = target_assigner_config.sample_positive_fraction # -1 if positive_fraction < 0: positive_fraction = None target_assigners = [] flag = 0 box_coder = build_box_coder(box_coder_cfg) for task in tasks: # { num_class=1, class_names=["Car"] } target_assigner = TargetAssigner( box_coder=box_coder, anchor_generators=anchor_generators[flag:flag + task.num_class], region_similarity_calculator=similarity_calc, positive_fraction=positive_fraction, # None sample_size=target_assigner_config.sample_size, # 512 ) flag += task.num_class # 1 target_assigners.append(target_assigner) # results self.target_assigners = target_assigners self.out_size_factor = assigner_cfg.out_size_factor self.anchor_area_threshold = target_assigner_config.pos_area_threshold # -1
def __init__(self, **kwargs): assigner_cfg = kwargs["cfg"] target_assigner_config = assigner_cfg.target_assigner tasks = target_assigner_config.tasks box_coder_cfg = assigner_cfg.box_coder anchor_cfg = target_assigner_config.anchor_generators anchor_generators = [] for a_cfg in anchor_cfg: anchor_generator = build_anchor_generator(a_cfg) anchor_generators.append(anchor_generator) similarity_calc = build_similarity_metric( target_assigner_config.region_similarity_calculator) positive_fraction = target_assigner_config.sample_positive_fraction if positive_fraction < 0: positive_fraction = None target_assigners = [] flag = 0 box_coder = build_box_coder(box_coder_cfg) for task in tasks: target_assigner = TargetAssigner( box_coder=box_coder, anchor_generators=anchor_generators[flag:flag + task.num_class], region_similarity_calculator=similarity_calc, positive_fraction=positive_fraction, sample_size=target_assigner_config.sample_size, ) flag += task.num_class target_assigners.append(target_assigner) self.target_assigners = target_assigners self.out_size_factor = assigner_cfg.out_size_factor self.anchor_area_threshold = target_assigner_config.pos_area_threshold