Skip to content

Commit

Permalink
feat: rename thresholds into success_thresholds
Browse files Browse the repository at this point in the history
Signed-off-by: ktro2828 <[email protected]>
  • Loading branch information
ktro2828 committed Dec 29, 2023
1 parent 903601c commit c5803be
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from typing import TYPE_CHECKING
from typing import Union

from perception_eval.common.evaluation_task import EvaluationTask
from perception_eval.common.label import set_target_lists
from perception_eval.common.threshold import check_thresholds
from perception_eval.config.params import PerceptionFilterParam
Expand Down Expand Up @@ -62,7 +63,7 @@ def __init__(
confidence_threshold_list: Optional[List[float]] = None,
target_uuids: Optional[List[str]] = None,
ignore_attributes: Optional[List[str]] = None,
thresholds: Optional[List[float]] = None,
success_thresholds: Optional[List[float]] = None,
) -> None:
"""
Args:
Expand Down Expand Up @@ -102,13 +103,22 @@ def __init__(
)

num_elements: int = len(self.target_labels)
if thresholds is None:
self.thresholds = None
if success_thresholds is None:
self.success_thresholds = None
else:
self.thresholds = check_thresholds(thresholds, num_elements)
self.success_thresholds = check_thresholds(success_thresholds, num_elements)

@classmethod
def from_eval_cfg(cls, eval_cfg: PerceptionEvaluationConfig) -> PerceptionFrameConfig:
if eval_cfg.evaluation_task.is_3d():
success_thresholds = eval_cfg.metrics_param.plane_distance_thresholds
else:
success_thresholds = (
None
if eval_cfg.evaluation_task == EvaluationTask.CLASSIFICATION2D
else eval_cfg.metrics_param.iou_2d_thresholds
)

return cls(
evaluator_config=eval_cfg,
target_labels=eval_cfg.target_labels,
Expand All @@ -120,5 +130,5 @@ def from_eval_cfg(cls, eval_cfg: PerceptionEvaluationConfig) -> PerceptionFrameC
confidence_threshold_list=eval_cfg.filter_param.confidence_threshold_list,
target_uuids=eval_cfg.filter_param.target_uuids,
ignore_attributes=eval_cfg.filter_param.ignore_attributes,
thresholds=eval_cfg.metrics_param.plane_distance_thresholds,
success_thresholds=success_thresholds,
)
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def evaluate(
object_results,
self.frame_config.target_labels,
MatchingMode.IOU2D if self.frame_config.evaluation_task.is_2d() else MatchingMode.PLANEDISTANCE,
self.frame_config.thresholds,
self.frame_config.success_thresholds,
)

self.critical_ground_truth_objects = critical_ground_truth_objects
Expand Down Expand Up @@ -151,7 +151,7 @@ def __get_positive_object_results(
matching_mode=MatchingMode.IOU2D
if self.frame_config.evaluation_task.is_2d()
else MatchingMode.PLANEDISTANCE,
matching_threshold_list=self.frame_config.thresholds,
matching_threshold_list=self.frame_config.success_thresholds,
)

# filter by critical_ground_truth_objects
Expand Down
2 changes: 1 addition & 1 deletion perception_eval/test/perception_fp_validation_lsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def callback(self, unix_time: int, estimated_objects: List[ObjectType]) -> None:
target_labels=["car", "bicycle", "pedestrian", "motorbike"],
max_x_position_list=[100.0, 100.0, 100.0, 100.0],
max_y_position_list=[100.0, 100.0, 100.0, 100.0],
thresholds=[2.0, 2.0, 2.0, 2.0],
success_thresholds=[2.0, 2.0, 2.0, 2.0],
)

frame_result = self.evaluator.add_frame_result(
Expand Down
2 changes: 1 addition & 1 deletion perception_eval/test/perception_lsim.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def callback(
ignore_attributes=["cycle_state.without_rider"],
max_x_position_list=[30.0, 30.0, 30.0, 30.0],
max_y_position_list=[30.0, 30.0, 30.0, 30.0],
thresholds=[2.0, 2.0, 2.0, 2.0],
success_thresholds=[2.0, 2.0, 2.0, 2.0],
)

frame_result = self.evaluator.add_frame_result(
Expand Down
4 changes: 2 additions & 2 deletions perception_eval/test/perception_lsim2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,14 @@ def callback(
else ["car", "bicycle", "pedestrian", "motorbike"]
)
ignore_attributes = ["cycle_state.without_rider"] if self.label_prefix == "autoware" else None
thresholds = None if self.evaluation_task == "classification2d" else [0.5, 0.5, 0.5, 0.5]
success_thresholds = None if self.evaluation_task == "classification2d" else [0.5, 0.5, 0.5, 0.5]
# 距離などでUC評価objectを選別するためのインターフェイス(PerceptionEvaluationManager初期化時にConfigを設定せず、関数受け渡しにすることで動的に変更可能なInterface)
# どれを注目物体とするかのparam
frame_config = PerceptionFrameConfig(
evaluator_config=self.evaluator.config,
target_labels=target_labels,
ignore_attributes=ignore_attributes,
thresholds=thresholds,
success_thresholds=success_thresholds,
)

frame_result = self.evaluator.add_frame_result(
Expand Down

0 comments on commit c5803be

Please sign in to comment.