mmtracking
mmtracking copied to clipboard
Deep copy for the hyper-parameter search config
Issue
https://github.com/open-mmlab/mmtracking/blob/3c45b9019c83801c65c40959e65f2ed5c7b97e53/tools/analysis/mot/mot_param_search.py#L144-L149
The dict.copy() method is not applied to its children recursively. The values from the sub-dict are not correctly copied.
A minimal code snippet to reproduce
from dotty_dict import dotty
tracker = dict(
type='ByteTracker',
obj_score_thrs=dict(high=[0.5, 0.6], low=0.1),
)
search_cfgs= []
for c in [0.5, 0.6]:
search_cfg = dotty(tracker.copy())
search_cfg['obj_score_thrs.high'] = c
searech_cfgs.append(dict(search_cfg))
print(search_cfgs[0])
print(search_cfgs[1])
Output:
{'type': 'ByteTracker', 'obj_score_thrs': {'high': 0.6, 'low': 0.1}}
{'type': 'ByteTracker', 'obj_score_thrs': {'high': 0.6, 'low': 0.1}}
Quick fix:
use deepcopy method to construct a new dict object.
import copy
from dotty_dict import dotty
tracker = dict(
type='ByteTracker',
obj_score_thrs=dict(high=[0.5, 0.6], low=0.1),
)
search_cfgs= []
for c in [0.5, 0.6]:
search_cfg = dotty(copy.deepcopy(tracker))
search_cfg['obj_score_thrs.high'] = c
search_cfgs.append(dict(search_cfg))
print(search_cfgs[0])
print(search_cfgs[1])
Output:
{'type': 'ByteTracker', 'obj_score_thrs': {'high': 0.5, 'low': 0.1}}
{'type': 'ByteTracker', 'obj_score_thrs': {'high': 0.6, 'low': 0.1}}
Thanks for your correction. Would you like to open a pull request to fix this?