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

Modify Config file for Custom Modules #12002

Open
Mukil07 opened this issue Oct 18, 2024 · 1 comment
Open

Modify Config file for Custom Modules #12002

Mukil07 opened this issue Oct 18, 2024 · 1 comment
Assignees

Comments

@Mukil07
Copy link

Mukil07 commented Oct 18, 2024

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 !

@PeterVennerstrom
Copy link
Contributor

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.

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

No branches or pull requests

3 participants