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] Memory leaking in panpotic segmentation evaluation #7538

Merged
merged 7 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions configs/mask2former/mask2former_r50_lsj_8x2_50e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,16 @@
dict(type='TextLoggerHook', by_epoch=False),
dict(type='TensorboardLoggerHook', by_epoch=False)
])
interval = 200000
interval = 5000
workflow = [('train', interval)]
checkpoint_config = dict(
by_epoch=False, interval=interval, save_last=True, max_keep_ckpts=3)

# Before 365001th iteration, we do evaluation every 200000 iterations.
# Before 365001th iteration, we do evaluation every 5000 iterations.
# After 365000th iteration, we do evaluation every 368750 iterations,
# which means do evaluation at the end of training.
# In all, we do evaluation at the 200000th iteration and the
# last iteratoin.
# which means that we do evaluation at the end of training.
dynamic_intervals = [(max_iters // interval * interval + 1, max_iters)]
evaluation = dict(
interval=interval, dynamic_intervals=dynamic_intervals, metric='PQ')
interval=interval,
dynamic_intervals=dynamic_intervals,
metric=['PQ', 'bbox', 'segm'])
7 changes: 7 additions & 0 deletions mmdet/datasets/api_wrappers/panoptic_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ def pq_compute_multi_core(matched_annotations_list,
(proc_id, annotation_set, gt_folder,
pred_folder, categories, file_client))
processes.append(p)

# Close the process pool, otherwise it will lead to memory
# leaking problems.
workers.close()
chhluo marked this conversation as resolved.
Show resolved Hide resolved
workers.join()

pq_stat = PQStat()
for p in processes:
pq_stat += p.get()

return pq_stat
8 changes: 3 additions & 5 deletions tests/test_utils/test_assigner.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,11 @@ def test_mask_hungarian_match_assigner():
assert (assign_result.gt_inds > 0).sum() == gt_labels.size(0)
assert (assign_result.labels > -1).sum() == gt_labels.size(0)

# test with mask ce mode
# test with ce mode of CrossEntropyLossCost which is not supported yet
assigner_cfg = dict(
cls_cost=dict(type='ClassificationCost', weight=0.0),
mask_cost=dict(
type='CrossEntropyLossCost', weight=1.0, use_sigmoid=False),
dice_cost=dict(type='DiceCost', weight=0.0, pred_act=True, eps=1.0))
self = MaskHungarianAssigner(**assigner_cfg)
with pytest.raises(NotImplementedError):
assign_result = self.assign(cls_pred, mask_pred, gt_labels, gt_masks,
img_meta)
with pytest.raises(AssertionError):
chhluo marked this conversation as resolved.
Show resolved Hide resolved
self = MaskHungarianAssigner(**assigner_cfg)