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

[Fix] Update the ClassBalancedDataset logic #1048

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion mmengine/dataset/dataset_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,16 @@ def _get_repeat_factors(self, dataset: BaseDataset,
# r(I) = max_{c in L(I)} r(c)
repeat_factors = []
for idx in range(num_images):
# the length of `repeat_factors` need equal to the length of
# dataset. Hence, if the `cat_ids` is empty,
# the repeat_factor should be 1.
repeat_factor: float = 1.
cat_ids = set(self.dataset.get_cat_ids(idx))
if len(cat_ids) != 0:
repeat_factor = max(
{category_repeat[cat_id]
for cat_id in cat_ids})
repeat_factors.append(repeat_factor)
repeat_factors.append(repeat_factor)

return repeat_factors

Expand Down