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

Validate the data in StartupDialog and handle mismatched segmentation labels #125

Conversation

chingyulin
Copy link
Collaborator

@chingyulin chingyulin commented Dec 10, 2022

This PR addresses:

  • mismatch between segmentation labels and label definition. It prompts a message box to user to overwrite the missing labels with the default labels, if not the label stays as-is. The check happens when a PointCloud is initialised or is being saved to .bin file Handle missing class definitions for semantic segmentation #124
  • validate the self-correctness of the data in the StartupDialog and prompts a message box when errors occurred. Handled errors are 1. no label defined, 2. label ids are not unique, 3. label name is empty, 4. default id in the _classes.json doesn't present in the dialog. The trackback of the non-handled errors are printed to the message box.

Screenshots of the error handling in the StartupDialog
No label defined
No label defined
default id in the _classes.json doesn't present in the dialog
image
label ids are not unique
image
label name is empty
image
Unhandled error
image

Screenshots of the message box when the segmentation labels don't match with LabelConfig
image

@chingyulin chingyulin changed the title [WIP] detect the config and segmentation label errors Validate the data in StartupDialog and handle mismatched segmentation labels Dec 29, 2022
@chingyulin chingyulin marked this pull request as ready for review December 29, 2022 05:54
@ch-sa
Copy link
Owner

ch-sa commented Dec 30, 2022

Nice, looks good on first sight. Will review as soon as I have my laptop.

First small comment:
"Default class id is missing in the class list."

Copy link
Owner

@ch-sa ch-sa left a comment

Choose a reason for hiding this comment

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

LGTM!

Please have a look at the comments and then feel free to squash and merge.

@@ -30,6 +30,22 @@ def to_dict(self) -> dict:
}


class ZeroLabelException(Exception):
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe move them into a new file .../labels/exceptions.py.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done here e4ce835

for c in self.classes:
if c.id == self.default:
return c.name
raise DefaultIdMismatchException(
Copy link
Owner

Choose a reason for hiding this comment

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

Good point. Didn't consider this case so far.

f"Segmentation labels {unique_label_ids} of `{self.path}` don't match with the label config {unique_class_ids}."
)
labels_to_replace = unique_label_ids.difference(unique_class_ids)
msg.setInformativeText(
Copy link
Owner

Choose a reason for hiding this comment

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

What is happening in the case the user clicks on "Cancel"? ... it keeps the old (unknown) label?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes. It is done this way in case the user doesn't want to change their label files. However, if the user doesn't agree to replace, it will prompt every time it's checked.

msg.setInformativeText(
f"""
Do you want to overwrite
the mismatch labels {labels_to_replace} with
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe "undefined labels" instead of "mismatch labels"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done here 84558e1

@@ -20,6 +19,8 @@
QMessageBox,
)

from labelCloud.view.startup_dialog import StartupDialog
Copy link
Owner

Choose a reason for hiding this comment

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

Please use relative imports.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done here 1f8fa59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants