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

KeyError: 'PackDetInputs is not in the transform registry. Please check whether the value of PackDetInputs is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module' #10900

Open
niharika-soni opened this issue Sep 8, 2023 · 14 comments
Assignees

Comments

@niharika-soni
Copy link

No description provided.

@niharika-soni
Copy link
Author

I am using mmdet version 3.0.0 and mmcbv-full version 2.0.2

@niharika-soni
Copy link
Author

@BIGWangYuDong can you please help me out with your valuable suggestion?

@lzx101
Copy link

lzx101 commented Sep 17, 2023

Has this issue been resolved?

@HonglinChu
Copy link

me too

@ElviraLL
Copy link

I encountered a similar problem. It appears that the sequence in which the models are loaded can impact this. In my experience, I initially loaded the mmpose model after mmdet model. It's possible that, during the 2nd loading process, mmengine changed its scope to mmpose, which caused issues when trying to run inference for the mmdet model. However, when I first loaded the mmpose model and then the detector model, followed by running the detector inference and subsequently the pose estimation, the error was resolved.

@HonglinChu
Copy link

KeyError: 'PackDetInputs is not in the mmpose::transform registry. Please check whether the value of PackDetInputs is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

@niharika-soni
Copy link
Author

niharika-soni commented Nov 2, 2023 via email

@ElviraLL
Copy link

ElviraLL commented Nov 6, 2023

KeyError: 'PackDetInputs is not in the mmpose::transform registry. Please check whether the value of PackDetInputs is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'

Yea, that's what I met, this is indicating that you are running mmdet models under mmpose scope. Try to modify the order of your code. I don't know if I'm right about this, maybe mmlab's developer can answer this better, but I didn't find anything in mmengine that can change the scope of your registry when you are switching between mmdet and mmpose models. Maybe try to load the model or declear the model or read the model config right before you run inference or other part of the det models.

@RameenAbdal
Copy link

A hacky way is to register the modules every time you run inference on the mmdet model.

from mmdet.utils.setup_env import register_all_modules 
from mmpose.apis import (init_model , inference_topdown)
from mmdet.apis import init_detector, inference_detector
### Init mmpose model
### init mmdet model
...
register_all_modules(True)
mmdet_results = inference_detector(...)
...
pose_results = inference_topdown(...)

@smidm
Copy link

smidm commented Dec 15, 2023

Thanks for the clue #10900 (comment) !

The detector pipeline has to fixed for use in the mmpose scope:

from mmdet.apis import inference_detector, init_detector
from mmpose.utils import adapt_mmdet_pipeline

detector = init_detector(args.det_config, args.det_checkpoint, device=args.device)
detector.cfg = adapt_mmdet_pipeline(detector.cfg)

see https://github.com/open-mmlab/mmpose/blob/efe09cd5268d4d6b21100334fbf2947ef36fc7db/demo/topdown_demo_with_mmdet.py#L182C26-L182C26

@letriet96
Copy link

you should import all the transform that used in pipeline. For example:

import os.path as osp
from mmengine.dataset import Compose
from my_transforms import VideoDecode, VideoFormat,
VideoResize, VideoSample, VideoPack, VideoCrop, VideoInit

pipeline_cfg = [
dict(type='VideoInit'),
dict(type='VideoSample', clip_len=16, num_clips=1, test_mode=False),
dict(type='VideoDecode'),
dict(type='VideoResize', r_size=256),
dict(type='VideoCrop', c_size=224),
dict(type='VideoFormat'),
dict(type='VideoPack')
]

in the scrip above, I write several transform to apply on video preprocessing in my_transform.py, if you don't import these transform, this error will occur

@letriet96
Copy link

In conclusion, to fix this issue, you have to import all the transform in pipeline

@ElviraLL
Copy link

detector.cfg = adapt_mmdet_pipeline(detector.cfg)

Thanks for the information! This works! Now I don't have to load my detector everytime!

@letriet96
Copy link

letriet96 commented Jan 31, 2024 via email

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

8 participants