Skip to content

Unmatched tensor sizes and no 'fc3' attribute when running Instance Segmentation in PyTorch demo #162

Description

@hiankun

I have tried to run python3 tools/train_0050.py of Instance Segmentation with a small new data set which has only 3 classes. The losses converged and I assumed that the training was successful. But when I tried to test the trained model with the following commands:

python3 tools/demo.py \
    --dataset coco_2017_val \
    --ckpt outputs/Oct24-11-45-33/ckpt/model_step_20000.pth \
    --mean_pixel 102.9801 115.9465 122.7717 \
    --fit_window 800 1333 \
    --video 0 \
    --delay 1 \
    --show_fps \
    pytorch \
    --model segmentoly.rcnn.model_zoo.resnet_fpn_mask_rcnn.ResNet50FPNMaskRCNN \
    --show_flops

It returned the following error message:

loading annotations into memory...
Done (t=0.03s)
creating index...
index created!
INFO 24-10-19 16:47:26 demo.py: 119] Dataset COCODataset
    Number of datapoints: 3
    Number of classes: 3
    Transforms: Compose(
                    Resize[widow_size = [800, 1333]]
                    ToTensor
                    Normalize[mean = [102.9801, 115.9465, 122.7717], std = [1.0, 1.0, 1.0], rgb = False]
                )

INFO 24-10-19 16:47:26 demo.py: 122] Using pytorch backend
INFO 24-10-19 16:47:26 demo.py: 124] Loading network...
WARNING 24-10-19 16:47:28 weights.py:  59] Model and checkpoint have different sizes of tensors in 'fpn.conv_top.weight': torch.Size([256, 2048, 1, 1]) vs torch.Size([128, 2048, 1, 1]). Weights will not b
e loaded
WARNING 24-10-19 16:47:28 weights.py:  59] Model and checkpoint have different sizes of tensors in 'fpn.conv_top.bias': torch.Size([256]) vs torch.Size([128]). Weights will not be loaded

(many similar warnings omitted...)

Traceback (most recent call last):
  File "tools/demo.py", line 229, in <module>
    main(args)
  File "tools/demo.py", line 128, in main
    load_checkpoint(net, args.checkpoint_file_path)
  File "/media/thk/storage/sandbox_2019/gitlab_proj/openvino_training_extensions/pytorch_toolkit/instance_segmentation/segmentoly/utils/weights.py", line 53, in load_checkpoint
    tensor = operator.attrgetter(name)(model)
  File "/home/thk/.local/lib/python3.5/site-packages/torch/nn/modules/module.py", line 585, in __getattr__
    type(self).__name__, name))
AttributeError: 'BboxHead' object has no attribute 'fc3'

My questions:

  1. Where or at which step should I check the sizes? According to the warnings, I guess that was due to something like input image sizes, but I have no clues for further investigation.
  2. My system already has PyTorch 1.13.0, which I have forgotten how it was installed (I tried pip3 to uninstall but failed). The instruction of Instance Segmentation suggests PyTorch 0.4.1. Does the unmatched PyTorch version cause the AttributeError?

The working system is Ubuntu 16.04.

Metadata

Metadata

Labels

QUESTIONFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions