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

Run test on pretrained model #32

Closed
EmbeddedAndMore opened this issue Jun 1, 2021 · 6 comments
Closed

Run test on pretrained model #32

EmbeddedAndMore opened this issue Jun 1, 2021 · 6 comments

Comments

@EmbeddedAndMore
Copy link

EmbeddedAndMore commented Jun 1, 2021

i am getting the following error by running this command:

python ./tools/test.py --cfg_file ./tools/cfgs/kitti_models/CaDDN.yaml --launcher pytorch --eval_all

error:


Traceback (most recent call last):
  File "./tools/test.py", line 199, in <module>
    main()
  File "./tools/test.py", line 190, in main
    model = build_network(model_cfg=cfg.MODEL, num_class=len(cfg.CLASS_NAMES), dataset=test_set)
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/__init__.py", line 14, in build_network
    model = build_detector(
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/detectors/__init__.py", line 23, in build_detector
    model = __all__[model_cfg.NAME](
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/detectors/caddn.py", line 7, in __init__
    self.module_list = self.build_networks()
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/detectors/detector3d_template.py", line 50, in build_networks
    module, model_info_dict = getattr(self, 'build_%s' % module_name)(
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/detectors/detector3d_template.py", line 74, in build_ffe
    ffe_module = ffe.__all__[self.model_cfg.FFE.NAME](
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/backbones_3d/ffe/depth_ffe.py", line 25, in __init__
    self.ddn = ddn.__all__[ddn_cfg.NAME](
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_deeplabv3.py", line 21, in __init__
    super().__init__(constructor=constructor, **kwargs)
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 34, in __init__
    self.model = self.get_model(constructor=constructor)
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 63, in get_model
    pretrained_dict = self.filter_pretrained_dict(model_dict=model_dict, pretrained_dict=pretrained_dict)
  File "/home/mm/MasterThesis/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 88, in filter_pretrained_dict
    pretrained_num_classes = pretrained_dict["classifier.4.weight"].shape[0]
KeyError: 'classifier.4.weight'

to be more precise: i downloaded the cadnn.pth from the link in README.md and set the path in the config file.
also pretrained_dict only contains: pretrained_dict : dict_keys(['epoch', 'it', 'model_state', 'optimizer_state', 'version'])

installation is based on what you mentioned in INSTALL.md

@codyreading
Copy link
Member

codyreading commented Jun 1, 2021

Hello,

The path in the config file is only for the pretrained DeepLabV3 model, and not the full CaDDN model. Please revert that change in order to get rid of this error. I recommend to leave this config as is.

If you would like to run the pretrained CaDDN model, please specify the path to caddn.pth via the command line: I also recommend to run all commands while inside the tools directory

cd tools
python test.py --cfg_file cfgs/kitti_models/CaDDN.yaml --ckpt caddn.pth

@codyreading
Copy link
Member

Closing due to inactivity

@octavianplesea
Copy link

Hello,
I have the same problem, run the command exactly as you indicated.

I still get this error.
Traceback (most recent call last): File "test.py", line 199, in <module> main() File "test.py", line 190, in main model = build_network(model_cfg=cfg.MODEL, num_class=len(cfg.CLASS_NAMES), dataset=test_set) File "/content/drive/MyDrive/CaDDN/pcdet/models/__init__.py", line 15, in build_network model_cfg=model_cfg, num_class=num_class, dataset=dataset File "/content/drive/MyDrive/CaDDN/pcdet/models/detectors/__init__.py", line 24, in build_detector model_cfg=model_cfg, num_class=num_class, dataset=dataset File "/content/drive/MyDrive/CaDDN/pcdet/models/detectors/caddn.py", line 7, in __init__ self.module_list = self.build_networks() File "/content/drive/MyDrive/CaDDN/pcdet/models/detectors/detector3d_template.py", line 51, in build_networks model_info_dict=model_info_dict File "/content/drive/MyDrive/CaDDN/pcdet/models/detectors/detector3d_template.py", line 76, in build_ffe downsample_factor=model_info_dict["downsample_factor"] File "/content/drive/MyDrive/CaDDN/pcdet/models/backbones_3d/ffe/depth_ffe.py", line 28, in __init__ **ddn_cfg.ARGS File "/content/drive/MyDrive/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_deeplabv3.py", line 21, in __init__ super().__init__(constructor=constructor, **kwargs) File "/content/drive/MyDrive/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 34, in __init__ self.model = self.get_model(constructor=constructor) File "/content/drive/MyDrive/CaDDN/pcdet/models/backbones_3d/ffe/ddn/ddn_template.py", line 60, in get_model pretrained_dict = torch.load(self.pretrained_path) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 525, in load with _open_file_like(f, 'rb') as opened_file: File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 212, in _open_file_like return _open_file(name_or_buffer, mode) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 193, in __init__ super(_open_file, self).__init__(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: '../checkpoints/deeplabv3_resnet101_coco-586e9e4e.pth'

Should I just add this checkpoint in order to make it work even though I will not use it?

@m-Just
Copy link

m-Just commented May 26, 2022

Hi @octavianplesea. I also had this issue. Did you get it to work in the end?

Edit: set pretrained_path to ~ (which means None in YAML) in the config file and also provide --ckpt in the command line works.

Correction: don't change pretrained_path. It turns out that the pre-trained model is still required (for some unknown reason) to get the correct output. The pre-trained model can be downloaded here.

@octavianplesea
Copy link

hi @m-Just .
In the end I made it work exactly as you've done. You must respect the whole structure of the files even though normally they wouldn't be needed. I would have one question for you also. In the end, you end up getting a file "result.pkl". What did you do with it in order to see the results?

@m-Just
Copy link

m-Just commented Jun 5, 2022

@octavianplesea, I used pickle.load to see the results in "result.pkl".

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

4 participants