Skip to content

Conversation

@BIGWangYuDong
Copy link
Collaborator

@BIGWangYuDong BIGWangYuDong commented Mar 2, 2023

Related PR: open-mmlab/mmdetection#9863

Thanks to the previous work of @Even-ok, I optimized it on the basis of #69

  • Support calculate metric on each val iteration
  • Support calculate metric after val have finished (multiprocessing or not)
  • Support with/without using ann_file

TODO:

  • Add UT
  • Add examples

Before:
NzW9XVEsEl

After:
image

@BIGWangYuDong BIGWangYuDong requested a review from RangiLyu March 7, 2023 06:40
thing_classes = self.dataset_meta['thing_classes']
elif self.dataset_meta and 'THING_CLASSES' in self.dataset_meta:
thing_classes = self.dataset_meta['THING_CLASSES']
warnings.warn(
Copy link
Member

Choose a reason for hiding this comment

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

It will raise a warning whenever you call it.

@property
def thing_classes(self) -> tuple:
"""Get thing classes from self.dataset_meta."""
if self.dataset_meta and 'thing_classes' in self.dataset_meta:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add comments we will Deprecate in v1.0.0

Comment on lines +681 to +690
if self.dataset_meta and 'thing_classes' in self.dataset_meta:
thing_classes = self.dataset_meta['thing_classes']
elif self.dataset_meta and 'THING_CLASSES' in self.dataset_meta:
thing_classes = self.dataset_meta['THING_CLASSES']
warnings.warn(
'DeprecationWarning: The `THING_CLASSES` in `dataset_meta` '
'is deprecated, use `thing_classes` instead!')
else:
raise RuntimeError('Could not find `thing_classes` in '
f'dataset_meta: {self.dataset_meta}')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if self.dataset_meta and 'thing_classes' in self.dataset_meta:
thing_classes = self.dataset_meta['thing_classes']
elif self.dataset_meta and 'THING_CLASSES' in self.dataset_meta:
thing_classes = self.dataset_meta['THING_CLASSES']
warnings.warn(
'DeprecationWarning: The `THING_CLASSES` in `dataset_meta` '
'is deprecated, use `thing_classes` instead!')
else:
raise RuntimeError('Could not find `thing_classes` in '
f'dataset_meta: {self.dataset_meta}')
if hasattr(self, '_thing_classes'):
return self._thing_classes
else:
if self.dataset_meta and 'thing_classes' in self.dataset_meta:
thing_classes = self.dataset_meta['thing_classes']
elif self.dataset_meta and 'THING_CLASSES' in self.dataset_meta:
thing_classes = self.dataset_meta['THING_CLASSES']
warnings.warn(
'DeprecationWarning: The `THING_CLASSES` in `dataset_meta` '
'is deprecated, use `thing_classes` instead!')
else:
raise RuntimeError('Could not find `thing_classes` in '
f'dataset_meta: {self.dataset_meta}')
self._thing_classes = thing_classes
return thing_classes

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.

2 participants