Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

"Can't find 'MetaOneStageDetector' in D2Go's META_ARCH_REGISTRY #15

Open
kirk86 opened this issue May 7, 2023 · 6 comments
Open

"Can't find 'MetaOneStageDetector' in D2Go's META_ARCH_REGISTRY #15

kirk86 opened this issue May 7, 2023 · 6 comments

Comments

@kirk86
Copy link

kirk86 commented May 7, 2023

How should we register MetaOneStageDetector in D2Go's META_ARCH_REGISTRY? If I'm not mistaken that should be already registered, right?

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/mobile_cv/common/misc/py.py", line 136, in new_func
    return func(*args, **kwargs)
  File "/content/sylph-few-shot-detection/tools/train_net.py", line 48, in main
    model = runner.build_model(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 318, in build_model
    model = self._build_model(cfg, eval_only)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 277, in _build_model
    model = build_d2go_model(cfg).model
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 57, in build_d2go_model
    model = build_meta_arch(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 42, in build_meta_arch
    raise KeyError(
KeyError: "Can't find 'MetaOneStageDetector' in D2Go's META_ARCH_REGISTRY, although it is in D2's META_ARCH_REGISTRY, now D2Go uses its own registry, please register it in D2Go's META_ARCH_REGISTRY."
> /usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py(42)build_meta_arch()
-> raise KeyError(
@RockJim2001
Copy link

As the error message says, please use from d2go.registry.builtin import META_ARCH_REGISTRY instead of detectron2.modeling import META_ARCH_REGISTRY.
https://github.com/facebookresearch/d2go/issues/490

@kirk86
Copy link
Author

kirk86 commented May 8, 2023

Thanks for the reply, I'm trying to test this project on google colab notebook.
Yesterday I could install requirements without producing many issues along the way but today it seems that AdelaiDet cannot be installed.

When installing requirements from requirements.txt I get the following error:

Building wheels for collected packages: AdelaiDet
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  Building wheel for AdelaiDet (setup.py) ... error
  ERROR: Failed building wheel for AdelaiDet
  Running setup.py clean for AdelaiDet
Failed to build AdelaiDet
ERROR: Could not build wheels for AdelaiDet, which is required to install pyproject.toml-based projects

Any ideas how to resolve that?

@RockJim2001
Copy link

I suggest that you could install AdelaiDet with sound code of it.
https://github.com/aim-uofa/AdelaiDet

@kirk86
Copy link
Author

kirk86 commented May 16, 2023

Thanks, managed to partially run it but now sylph raises new errors:

ZERO_GRAD_BEFORE_FORWARD: False
INFO:setup:Full config saved to output/meta-fcos/coco/pretrain/config.yaml
INFO:setup:Initializing runner ...
INFO:setup:Running with runner: <sylph.runner.meta_fcos_runner.MetaFCOSRunner object at 0x7ff15c6bbc70>
INFO:setup:Full config saved to output/meta-fcos/coco/pretrain/diff_config.yaml
INFO:__main__:setup_after_launch done
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474e40>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474eb0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474e40>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474eb0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474e40>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474eb0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474e40>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474eb0>
init Conv2d(256, 60, kernel_size=(1, 1), stride=(1, 1)) in <generator object Module.modules at 0x7ff150474e40>
init Conv2d(256, 4, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474dd0>
init Conv2d(256, 1, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474eb0>
init Conv2d(256, 1, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7ff150474dd0>
weight path: detectron2://ImageNetPretrained/MSRA/R-50.pkl
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/mobile_cv/common/misc/py.py", line 136, in new_func
    return func(*args, **kwargs)
  File "/content/sylph-few-shot-detection/tools/train_net.py", line 48, in main
    model = runner.build_model(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 318, in build_model
    model = self._build_model(cfg, eval_only)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 277, in _build_model
    model = build_d2go_model(cfg).model
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 57, in build_d2go_model
    model = build_meta_arch(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 47, in build_meta_arch
    model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
  File "/usr/local/lib/python3.10/dist-packages/detectron2/config/config.py", line 189, in wrapped
    explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/detectron2/config/config.py", line 245, in _get_args_from_config
    ret = from_config_func(*args, **kwargs)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_arch/meta_one_stage_detector.py", line 77, in from_config
    proposal_generator = build_proposal_generator(
  File "/usr/local/lib/python3.10/dist-packages/detectron2/modeling/proposal_generator/build.py", line 24, in build_proposal_generator
    return PROPOSAL_GENERATOR_REGISTRY.get(name)(cfg, input_shape)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 178, in __init__
    self.fcos_head = MetaFCOSHead(
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 292, in __init__
    super().__init__(cfg, input_shape)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 131, in __init__
    self._init_base_detector_config()
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 476, in _init_base_detector_config
    self.base_weight, self.base_bias = load_pretrained_class_conv_kernel_weights(
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 39, in load_pretrained_class_conv_kernel_weights
    if not PathManager.exists(weight_path):
  File "/usr/local/lib/python3.10/dist-packages/iopath/common/file_io.py", line 1247, in exists
    bret = handler._exists(path, **kwargs)  # type: ignore
  File "/usr/local/lib/python3.10/dist-packages/iopath/common/file_io.py", line 428, in _exists
    raise NotImplementedError()
NotImplementedError

Does this have to do with the fact that can't find weight path: detectron2://ImageNetPretrained/MSRA/R-50.pkl?

@RockJim2001
Copy link

RockJim2001 commented May 17, 2023 via email

@kirk86
Copy link
Author

kirk86 commented May 17, 2023

Thanks that seemed to work for a while but now throws a different error, by the way your english is fine and can understand you very well 😉

INFO:__main__:setup_after_launch done
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa70>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffae0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa70>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffae0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa70>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffae0>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa70>
init Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffae0>
init Conv2d(256, 60, kernel_size=(1, 1), stride=(1, 1)) in <generator object Module.modules at 0x7f10cccffa70>
init Conv2d(256, 4, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa00>
init Conv2d(256, 1, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffae0>
init Conv2d(256, 1, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1)) in <generator object Module.modules at 0x7f10cccffa00>
weight path: detectron2://ImageNetPretrained/MSRA/R-50.pkl
the path of weight file is :detectron2://ImageNetPretrained/MSRA/R-50.pkl
INFO:iopath.common.file_io:URL https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/MSRA/R-50.pkl cached in /root/.torch/iopath_cache/detectron2/ImageNetPretrained/MSRA/R-50.pkl
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/mobile_cv/common/misc/py.py", line 136, in new_func
    return func(*args, **kwargs)
  File "/content/sylph-few-shot-detection/tools/train_net.py", line 48, in main
    model = runner.build_model(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 318, in build_model
    model = self._build_model(cfg, eval_only)
  File "/usr/local/lib/python3.10/dist-packages/d2go/runner/default_runner.py", line 277, in _build_model
    model = build_d2go_model(cfg).model
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 57, in build_d2go_model
    model = build_meta_arch(cfg)
  File "/usr/local/lib/python3.10/dist-packages/d2go/modeling/api.py", line 47, in build_meta_arch
    model = META_ARCH_REGISTRY.get(meta_arch)(cfg)
  File "/content/detectron2/detectron2/config/config.py", line 189, in wrapped
    explicit_args = _get_args_from_config(from_config_func, *args, **kwargs)
  File "/content/detectron2/detectron2/config/config.py", line 245, in _get_args_from_config
    ret = from_config_func(*args, **kwargs)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_arch/meta_one_stage_detector.py", line 77, in from_config
    proposal_generator = build_proposal_generator(
  File "/content/detectron2/detectron2/modeling/proposal_generator/build.py", line 24, in build_proposal_generator
    return PROPOSAL_GENERATOR_REGISTRY.get(name)(cfg, input_shape)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 178, in __init__
    self.fcos_head = MetaFCOSHead(
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 292, in __init__
    super().__init__(cfg, input_shape)
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 131, in __init__
    self._init_base_detector_config()
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 476, in _init_base_detector_config
    self.base_weight, self.base_bias = load_pretrained_class_conv_kernel_weights(
  File "/content/sylph-few-shot-detection/sylph/modeling/meta_fcos/fcos.py", line 44, in load_pretrained_class_conv_kernel_weights
    pretrained_model = torch.load(
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 815, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/usr/local/lib/python3.10/dist-packages/torch/serialization.py", line 1035, in _legacy_load
    raise RuntimeError("Invalid magic number; corrupt file?")
RuntimeError: Invalid magic number; corrupt file?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants