-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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: "No object named 'DensePoseROIHeads' found in 'ROI_HEADS' registry!" #3155
Comments
Any solution for this problem? Facing the same issue when doing inference with a model with additional ROI Heads. |
I have a similar environment as OP and encountered a similar error. In my case the error occured because I was picking and choosing parts of the project to use rather than using it as-is. When I had the densepose project directory contained within my project directory, I used the same code as OP and it worked fine for me. This error occurs because the ROI head needs to be registered with a particular instance of one of Detectron2's registries, in particular the registry instance called ROI_HEADS_REGISTRY. The Registry class is a global key -> object store. ROI_HEADS_REGISTRY is one particular instance of this class. I noticed a few different kinds of registries being used, such as ROI_HEADS_REGISTRY, ROI_DENSEPOSE_HEAD_REGISTRY, DENSEPOSE_PREDICTOR_REGISTRY, and DENSEPOSE_LOSS_REGISTRY. They are all used kind of like globally scoped dicts. In OP's case, for some reason the code in densepose -> modeling -> roi_heads -> roi_head.py is not being executed. In particular, this part:
@DomiSchmauser For your case, I think you might be able to solve your problem by importing the ROI_HEADS_REGISTRY instance like so: |
can you help me please below my code and I have same error error is
code is
|
from detectron2.engine import DefaultPredictor
from detectron2.config import get_cfg
cfg = get_cfg()
add_densepose_config(cfg)
cfg.merge_from_file("/content/detectron2_repo/projects/DensePose/configs/densepose_rcnn_R_50_FPN_s1x.yaml")
Find a model from detectron2's model zoo. You can either use the https://dl.fbaipublicfiles.... url, or use the following shorthand
cfg.MODEL.WEIGHTS = "https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/143908701/model_final_dd99d2.pkl"
predictor = DefaultPredictor(cfg)
outputs = predictor(im)
Logs
KeyError Traceback (most recent call last)
in ()
7 # Find a model from detectron2's model zoo. You can either use the https://dl.fbaipublicfiles.... url, or use the following shorthand
8 cfg.MODEL.WEIGHTS = "https://dl.fbaipublicfiles.com/densepose/densepose_rcnn_R_50_FPN_s1x/143908701/model_final_dd99d2.pkl"
----> 9 predictor = DefaultPredictor(cfg)
10 outputs = predictor(im)
6 frames
/usr/local/lib/python3.7/dist-packages/fvcore/common/registry.py in get(self, name)
70 if ret is None:
71 raise KeyError(
---> 72 "No object named '{}' found in '{}' registry!".format(name, self._name)
73 )
74 return ret
KeyError: "No object named 'DensePoseROIHeads' found in 'ROI_HEADS' registry!"
Environment:
sys.platform linux
Python 3.7.10 (default, May 3 2021, 02:48:31) [GCC 7.5.0]
numpy 1.19.5
detectron2 0.4 @/usr/local/lib/python3.7/dist-packages/detectron2
Compiler GCC 7.3
CUDA compiler CUDA 10.1
detectron2 arch flags 3.7, 5.0, 5.2, 6.0, 6.1, 7.0, 7.5
DETECTRON2_ENV_MODULE
PyTorch 1.8.1+cu101 @/usr/local/lib/python3.7/dist-packages/torch
PyTorch debug build False
GPU available True
GPU 0 Tesla T4 (arch=7.5)
CUDA_HOME /usr/local/cuda
Pillow 7.1.2
torchvision 0.9.1+cu101 @/usr/local/lib/python3.7/dist-packages/torchvision
torchvision arch flags 3.5, 5.0, 6.0, 7.0, 7.5
fvcore 0.1.3.post20210317
cv2 4.1.2
PyTorch built with:
The text was updated successfully, but these errors were encountered: