Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add support of multiple object's shapes #7

Merged
merged 29 commits into from
Aug 3, 2023

Conversation

ktro2828
Copy link
Collaborator

@ktro2828 ktro2828 commented Oct 5, 2022

Signed-off-by: ktro2828 kotaro.uetake@tier4.jp

Category

  • Perception
  • Sensing

What

Add support of evaluating the objects not only shape with box, but also polygon and cylinder.

After this PR, We need to specify shape paramter to initialize DynamicObject instead of size as below.
Only for POLYGON objects, footprint must be specified.
BOX or CYLINDER objects' footprint can be computed internally as a rectangle.

NOTE
Input footprint is assumed that it is with respect to each object's coordinate system.
Although polygon returned with DynamicObject.state.footprint is with respect to each object's coordinate system, polygon returned with DynamicObject.get_footprint() is with respect to base_link or map coordinate system.

we support following shapes.

class ShapeType(Enum):
    BOUNDING_BOX = "bounding_box"
    # CYLINDER = "cylinder" -> removed at https://github.com/tier4/autoware_perception_evaluation/pull/7/commits/f957d2e5f0b55f280c0365ac3318203264527e65
    POLYGON = "polygon"
from perception_eval.common.object import DynamicObject
from perception_eval.common.shape import Shape, ShapeType

shape_type: Union[str, ShapeType] = ShapeType.BOUNDING_BOX  # or "bounding_box" is also OK.
size: Tuple[float, float, float]
footprint: Optional[Polygon] = None # For BOUNDING_BOX None is OK. For POLYGON it should be specified.
 
shape = Shape(shape_type=shape_type, size=size, footprint=footprint)

dynamic_object = DynamicObject(
    ...
    shape=shape,
    ...
)

# We can access "size" as before
object_size: Tuple[float, float, float] = dynamic_object.state.size

# This is with respect to each object's coordinate system
footprint: Polygon = dynamic_object.state.footprint

# This is with respect to base_link or map coordinate system
footprint: Polygon = dynamic_object.get_footprint()

Type of change

  • New feature
  • Update document

Test performed

  • test.sensing_lsim



  • test.perception_lsim



Reference

Notes for reviewer

@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch 2 times, most recently from e83466c to 454868d Compare October 6, 2022 09:09
@ktro2828 ktro2828 self-assigned this Oct 6, 2022
@ktro2828 ktro2828 added the enhancement New feature or request label Oct 6, 2022
@ktro2828 ktro2828 marked this pull request as ready for review October 6, 2022 10:46
@ktro2828 ktro2828 requested a review from miursh October 6, 2022 10:46
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch 3 times, most recently from 8dd2bac to 74c18b9 Compare January 30, 2023 03:55
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from 149dc32 to bd91413 Compare June 27, 2023 02:33
Copy link
Contributor

@miursh miursh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have forgotten it because it's been too long, but I was going to leave a comment.

perception_eval/perception_eval/common/shape.py Outdated Show resolved Hide resolved
perception_eval/test/visualization/test_eda_tool.py Outdated Show resolved Hide resolved
perception_eval/test/visualization/test_eda_tool.py Outdated Show resolved Hide resolved
perception_eval/test/visualization/test_eda_tool.py Outdated Show resolved Hide resolved
perception_eval/test/visualization/test_eda_tool.py Outdated Show resolved Hide resolved
perception_eval/test/util/dummy_object.py Outdated Show resolved Hide resolved
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from 3c077bb to f957d2e Compare July 11, 2023 14:53
@ktro2828
Copy link
Collaborator Author

@miursh Cylinder has been removed at f957d2e

@ktro2828
Copy link
Collaborator Author

ktro2828 commented Jul 11, 2023

NOTE

In this PR, when estimation has unknown label it will be allowed to be matched

if (
estimated_object_.semantic_label == ground_truth_object_.semantic_label
or estimated_object_.semantic_label.label == AutowareLabel.UNKNOWN

Also, object_result.is_label_correct always returns True if label of estimation is unknown

def is_label_correct(self) -> bool:
"""Get whether label is correct.
Returns:
bool: Whether label is correct
"""
if self.ground_truth_object:
return (
self.estimated_object.semantic_label == self.ground_truth_object.semantic_label
or self.estimated_object.semantic_label.label == AutowareLabel.UNKNOWN
)
else:
return False

@miursh
Copy link
Contributor

miursh commented Jul 12, 2023

@ktro2828

Also, object_result.is_label_correct always returns True if label of estimation is unknown

Is this always used if label is unknown? or is there some config/option to use this?

@ktro2828
Copy link
Collaborator Author

ktro2828 commented Jul 12, 2023

@miursh Sorry, I made a mistake, and I have updated like following.

  1. Allows to match when either Est or GT has unknown label

    if (
    est_obj.semantic_label == gt_obj.semantic_label
    or any(
    label == CommonLabel.UNKNOWN
    for label in (est_obj.semantic_label.label, gt_obj.semantic_label.label)
    )

  2. DynamicObjectResult.is_result_correct() only checks matching score except of classification task

    def is_result_correct(
    self,
    matching_mode: MatchingMode,
    matching_threshold: float,
    ) -> bool:
    """The function judging whether the result is target or not.
    Args:
    matching_mode (MatchingMode):
    The matching mode to evaluate.
    matching_threshold (float):
    The matching threshold to evaluate.
    For example, if matching_mode = IOU3d and matching_threshold = 0.5,
    and IoU of the object is higher than "matching_threshold",
    this function appends to return objects.
    Returns:
    bool: If label is correct and satisfy matching threshold, return True
    """
    # Whether is matching to ground truth
    matching: Optional[MatchingMethod] = self.get_matching(matching_mode)
    return (
    self.is_label_correct
    if matching is None
    else matching.is_better_than(matching_threshold)
    )

for classification, returns is_label_correct result. It checks whether label is same, which means it is not allowed to match unknown and the other labels

def is_label_correct(self) -> bool:
"""Get whether label is correct.
Returns:
bool: Whether label is correct
"""
if self.ground_truth_object:
return self.estimated_object.semantic_label == self.ground_truth_object.semantic_label
else:
return False

@miursh
Copy link
Contributor

miursh commented Jul 12, 2023

@ktro2828
For current implementation,

if (
est_obj.semantic_label == gt_obj.semantic_label
or any(
label == CommonLabel.UNKNOWN
for label in (est_obj.semantic_label.label, gt_obj.semantic_label.label)
)

if the autoware output label is "unknown", it always run matching, isn't it?
I think V&V team requirement is that they want to evaluate both with and without "unknown" class by one scenario.

@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from f01f350 to eefd3e9 Compare July 14, 2023 04:19
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from 6003414 to ef93f48 Compare July 21, 2023 06:07
@ktro2828
Copy link
Collaborator Author

ktro2828 commented Jul 21, 2023

@miursh @hayato-m126 in 6003414

I added a LabelParam and it has a parameter named allow_matching_unknonw. This is a flag whether allow to match unknown and the other labels.

from perception_eval.common.label import LabelParam

# === Perception ===
perception_label_param = LabelParam(
            label_prefix="autoware",  # Prefix of label name ... ("autoware", "traffic_light")
            merge_similar_labels=False,  # A flag if merge similar labels ... e.g. bus -> car
            allow_matching_unknown=True,  # A flag if allow to matching unknown and the other labels
            count_label_number=True,  # A flag if count the number of each label as debug
)

perception_cfg = PerceptionEvaluationConfig(
    ...
    label_param=perception_label_param,
    ...
)

# === Sensing ===
sensing_label_param = LabelParam(
            label_prefix="autoware",  # Prefix of label name ... ("autoware", "traffic_light")
            count_label_number=True,  # A flag if count the number of each label as debug
)

sensing_cfg = SensingEvaluationConfig(
    ...
    label_param=sensing_label_param,
    ...
)
  • TODO: update documents and docstrings

Copy link
Contributor

@hayato-m126 hayato-m126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR for driving_log_replayer corresponding to this PR is made below.
tier4/driving_log_replayer#198

I will review it as soon as I can confirm that it works.

@ktro2828
Copy link
Collaborator Author

ktro2828 commented Jul 21, 2023

@hayato-m126 I'm sorry for that I've removed LabelParam and make it possible to specify label parameters in evaluation_config_dict like following, because I think this is easier for users to initialize PerceptionEvaluationConfig 🙏

evaluation_config_dict = {
            ....
            # label parameters
            "label_prefix": "autoware",
            "merge_similar_labels": False,
            "allow_matching_unknown": True,
           ....
}


evaluation_config = PerceptionEvaluationConfig(
            ...
            evaluation_config_dict=evaluation_config_dict, # <- label_param has been removed
            load_raw_data=True,
)

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 changed the title feat: add support of multiple object's shapes feat!: add support of multiple object's shapes Jul 26, 2023
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from 27fda6a to 87d98cf Compare July 26, 2023 09:14
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from 87d98cf to c101cfa Compare July 26, 2023 09:15
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 marked this pull request as draft August 1, 2023 08:13
…ct-shapes

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
@ktro2828 ktro2828 force-pushed the feat/multiple-object-shapes branch from d67704e to cd7d28a Compare August 2, 2023 01:13
@ktro2828 ktro2828 marked this pull request as ready for review August 2, 2023 01:17
@ktro2828
Copy link
Collaborator Author

ktro2828 commented Aug 2, 2023

@hayato-m126 I've merged develop, so could you check this with driving_log_replayer?

@hayato-m126
Copy link
Contributor

Thank you for updating this branch. I'm going to check.

ktro2828 and others added 3 commits August 2, 2023 16:04
…t or not

Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Co-authored-by: Hayato Mizushima <hayato-m126@users.noreply.github.com>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Copy link
Contributor

@hayato-m126 hayato-m126 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This PR works fine with tier4/driving_log_replayer#198

@ktro2828 ktro2828 enabled auto-merge (squash) August 3, 2023 13:26
@ktro2828 ktro2828 disabled auto-merge August 3, 2023 13:26
@ktro2828 ktro2828 merged commit 97c7bbb into develop Aug 3, 2023
19 checks passed
@ktro2828 ktro2828 deleted the feat/multiple-object-shapes branch August 3, 2023 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants