You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for bothering you again, I am trying to load the pose estimation model in mmpose and trying to perform inference on it without using the torchserve container found in your repo and I ran into some problems.
I extracted the .mar model file and got a weights file (best_AP_epoch_72.pth) and a config for the model.
When I load this into mmpose for inference I get the following error:
KeyError Traceback (most recent call last)
Cell In[7], line 1
----> 1 model = init_model(CONFIG_PATH, WEIGHTS_PATH)
File /opt/conda/lib/python3.10/site-packages/mmpose/apis/inference.py:104, in init_model(config, checkpoint, device, cfg_options)
101 if scope is not None:
102 init_default_scope(scope)
--> 104 model = build_pose_estimator(config.model)
105 model = revert_sync_batchnorm(model)
106 # get dataset_meta in this priority: checkpoint > config > default (COCO)
File /opt/conda/lib/python3.10/site-packages/mmpose/models/builder.py:35, in build_pose_estimator(cfg)
33 def build_pose_estimator(cfg):
34 """Build pose estimator."""
---> 35 return POSE_ESTIMATORS.build(cfg)
File /opt/conda/lib/python3.10/site-packages/mmengine/registry/registry.py:570, in Registry.build(self, cfg, *args, **kwargs)
548 def build(self, cfg: dict, *args, **kwargs) -> Any:
549 """Build an instance.
550
551 Build an instance by calling :attr:`build_func`.
(...)
568 >>> model = MODELS.build(cfg)
569 """
--> 570 return self.build_func(cfg, *args, **kwargs, registry=self)
File /opt/conda/lib/python3.10/site-packages/mmengine/registry/build_functions.py:232, in build_model_from_cfg(cfg, registry, default_args)
230 return Sequential(*modules)
231 else:
--> 232 return build_from_cfg(cfg, registry, default_args)
File /opt/conda/lib/python3.10/site-packages/mmengine/registry/build_functions.py:100, in build_from_cfg(cfg, registry, default_args)
98 obj_cls = registry.get(obj_type)
99 if obj_cls is None:
--> 100 raise KeyError(
101 f'{obj_type} is not in the {registry.scope}::{registry.name} registry. ' # noqa: E501
102 f'Please check whether the value of `{obj_type}` is '
103 'correct or it was registered as expected. More details '
104 'can be found at '
105 '[https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module](https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module%3C/span%3E%3Cspan) style="color:rgb(175,0,0)">' # noqa: E501
106 )
107 # this will include classes, functions, partial functions and more
108 elif callable(obj_type):
KeyError: 'TopDown is not in the mmpose::model registry. Please check whether the value of `TopDown` 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'
Since, I had the weights I decided to code the model out in pytorch but its complete architecture was unknown to me especially the TopdownHeatmapSimpleHead but while doing so I wrote this code:
# Example instantiation of the model with the data configuration parametersmodel=KeypointModel(
image_size=(192, 256), # From data_cfgheatmap_size=(48, 64), # From data_cfgnum_keypoints=17, # From data_cfgpretrained=True
)
# Path to the weights fileweights_path='D:/fyp-codebase/mmpose/weights/best_AP_epoch_72.pth'# Load the state dictionary from the filestate_dict=torch.load(weights_path, map_location=torch.device('cpu'))
# Load the weights into the modelmodel.load_state_dict(state_dict)
# Set the model to evaluation mode (if you're using it for inference)model.eval()
print("Weights loaded successfully!")
I have been stuck for week procrastinating on this and it is really frustrating to find no solution. I am really sory for disturbing you again. The last time you help was really simple and I hope it is the same this time too. I will be waiting for you to provide me with a solution to this.
Thank you,
Raahim
The text was updated successfully, but these errors were encountered:
Sorry for bothering you again, I am trying to load the pose estimation model in mmpose and trying to perform inference on it without using the torchserve container found in your repo and I ran into some problems.
I extracted the .mar model file and got a weights file (best_AP_epoch_72.pth) and a config for the model.
When I load this into mmpose for inference I get the following error:
The Code I am Using is this:
Secondly I tried This:
Since, I had the weights I decided to code the model out in pytorch but its complete architecture was unknown to me especially the TopdownHeatmapSimpleHead but while doing so I wrote this code:
And I encountered this error:
I have been stuck for week procrastinating on this and it is really frustrating to find no solution. I am really sory for disturbing you again. The last time you help was really simple and I hope it is the same this time too. I will be waiting for you to provide me with a solution to this.
Thank you,
Raahim
The text was updated successfully, but these errors were encountered: