Modify Config file for Custom Modules
Im Currently working on YoloWorld which is built on mmdet and mmyolo. I have added mytransform.py file custom module in the config file as mentioned below,
config.py
custom_imports = dict(imports=['mytransform','yolo_world'], allow_failed_imports=False)
test_pipeline = [
*_base_.test_pipeline[:-1],
dict(type='LoadText'),
dict(type='CustomResize',severity=3),
dict(
type='mmdet.PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor', 'pad_param', 'texts'))
]
Here mytransform.py has the class CustomResize.
Custom Module (mytransform.py) works when I manually make these changes in the config.py,
But it is not working, when I append this dict(type='CustomResize',severity=3) to the test_pipeline list from test.py as mentioned below,
tools/test.py
def main():
#
args = parse_args()
# load config
cfg = Config.fromfile(args.config)
cfg.test_pipeline.insert(-2,dict(type='CustomResize',severity=args.severity))
# replace the ${key} with the value of cfg.key
# cfg = replace_cfg_vals(cfg)
cfg.launcher = args.launcher
And I could notice the changes made when the cfg is printed during the run.
Please look into the issue on how to modify the custom modules parameters in the config file from the main.py/test.py/command-line. Thanks !
Is CustomResize registered with the decorator in the same pattern as seen in transforms.py?
The configs are python and run in a typical python procedural manner when loaded. In other words, loading a config is basically running the python within. Any variables created in the config that depend on test_pipeline are already created with the original version when it is loaded.
Please give a bit more detail on why the config needs to be patched in test.py rather than before it is loaded.
@Mukil07 It looks like you're trying to use YOLO World as a custom model. Have you had any success with that? If you have created any modules for it, could you please share them?