Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to perform inference #30

@AngeloPrete

Description

@AngeloPrete

I get this error when i try to run inference:

Traceback (most recent call last):
File "../opt/project/main.py", line 392, in
inference(args)
File "/opt/project/inference_tools/inference_engine.py", line 37, in inference
model.load_state_dict(checkpoint['model'], strict=False)
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1490, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for PoET:
size mismatch for transformer.encoder.layers.0.self_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.encoder.layers.0.self_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.encoder.layers.0.self_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.encoder.layers.0.self_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.encoder.layers.1.self_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.encoder.layers.1.self_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.encoder.layers.1.self_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.encoder.layers.1.self_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.encoder.layers.2.self_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.encoder.layers.2.self_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.encoder.layers.2.self_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.encoder.layers.2.self_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.encoder.layers.3.self_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.encoder.layers.3.self_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.encoder.layers.3.self_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.encoder.layers.3.self_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.encoder.layers.4.self_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.encoder.layers.4.self_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.encoder.layers.4.self_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.encoder.layers.4.self_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.decoder.layers.0.cross_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.decoder.layers.0.cross_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.decoder.layers.0.cross_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.decoder.layers.0.cross_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.decoder.layers.1.cross_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.decoder.layers.1.cross_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.decoder.layers.1.cross_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.decoder.layers.1.cross_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.decoder.layers.2.cross_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.decoder.layers.2.cross_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.decoder.layers.2.cross_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.decoder.layers.2.cross_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.decoder.layers.3.cross_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.decoder.layers.3.cross_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.decoder.layers.3.cross_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.decoder.layers.3.cross_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for transformer.decoder.layers.4.cross_attn.sampling_offsets.weight: copying a param with shape torch.Size([512, 256]) from checkpoint, the shape in current model is torch.Size([256, 256]).
size mismatch for transformer.decoder.layers.4.cross_attn.sampling_offsets.bias: copying a param with shape torch.Size([512]) from checkpoint, the shape in current model is torch.Size([256]).
size mismatch for transformer.decoder.layers.4.cross_attn.attention_weights.weight: copying a param with shape torch.Size([256, 256]) from checkpoint, the shape in current model is torch.Size([128, 256]).
size mismatch for transformer.decoder.layers.4.cross_attn.attention_weights.bias: copying a param with shape torch.Size([256]) from checkpoint, the shape in current model is torch.Size([128]).
size mismatch for translation_head.0.layers.2.weight: copying a param with shape torch.Size([27, 256]) from checkpoint, the shape in current model is torch.Size([66, 256]).
size mismatch for translation_head.0.layers.2.bias: copying a param with shape torch.Size([27]) from checkpoint, the shape in current model is torch.Size([66]).
size mismatch for translation_head.1.layers.2.weight: copying a param with shape torch.Size([27, 256]) from checkpoint, the shape in current model is torch.Size([66, 256]).
size mismatch for translation_head.1.layers.2.bias: copying a param with shape torch.Size([27]) from checkpoint, the shape in current model is torch.Size([66]).
size mismatch for translation_head.2.layers.2.weight: copying a param with shape torch.Size([27, 256]) from checkpoint, the shape in current model is torch.Size([66, 256]).
size mismatch for translation_head.2.layers.2.bias: copying a param with shape torch.Size([27]) from checkpoint, the shape in current model is torch.Size([66]).
size mismatch for translation_head.3.layers.2.weight: copying a param with shape torch.Size([27, 256]) from checkpoint, the shape in current model is torch.Size([66, 256]).
size mismatch for translation_head.3.layers.2.bias: copying a param with shape torch.Size([27]) from checkpoint, the shape in current model is torch.Size([66]).
size mismatch for translation_head.4.layers.2.weight: copying a param with shape torch.Size([27, 256]) from checkpoint, the shape in current model is torch.Size([66, 256]).
size mismatch for translation_head.4.layers.2.bias: copying a param with shape torch.Size([27]) from checkpoint, the shape in current model is torch.Size([66]).
size mismatch for rotation_head.0.layers.2.weight: copying a param with shape torch.Size([54, 256]) from checkpoint, the shape in current model is torch.Size([132, 256]).
size mismatch for rotation_head.0.layers.2.bias: copying a param with shape torch.Size([54]) from checkpoint, the shape in current model is torch.Size([132]).
size mismatch for rotation_head.1.layers.2.weight: copying a param with shape torch.Size([54, 256]) from checkpoint, the shape in current model is torch.Size([132, 256]).
size mismatch for rotation_head.1.layers.2.bias: copying a param with shape torch.Size([54]) from checkpoint, the shape in current model is torch.Size([132]).
size mismatch for rotation_head.2.layers.2.weight: copying a param with shape torch.Size([54, 256]) from checkpoint, the shape in current model is torch.Size([132, 256]).
size mismatch for rotation_head.2.layers.2.bias: copying a param with shape torch.Size([54]) from checkpoint, the shape in current model is torch.Size([132]).
size mismatch for rotation_head.3.layers.2.weight: copying a param with shape torch.Size([54, 256]) from checkpoint, the shape in current model is torch.Size([132, 256]).
size mismatch for rotation_head.3.layers.2.bias: copying a param with shape torch.Size([54]) from checkpoint, the shape in current model is torch.Size([132]).
size mismatch for rotation_head.4.layers.2.weight: copying a param with shape torch.Size([54, 256]) from checkpoint, the shape in current model is torch.Size([132, 256]).
size mismatch for rotation_head.4.layers.2.bias: copying a param with shape torch.Size([54]) from checkpoint, the shape in current model is torch.Size([132]).

I run this comand:

docker run --rm --gpus all
-v poet:/opt/project
-v poet/my_data:/data
-v poet/inference_output:/output
aaucns/poet:latest
python -u ../opt/project/main.py
--enc_layers 5
--dec_layers 5
--resume /opt/project/checkpoints/poet_lmo_maskrcnn.pth
--inference
--backbone maskrcnn
--inference_path /data/images
--inference_output /output
--backbone_cfg /opt/project/configs/lmo_rcnn.yaml
--backbone_weights /opt/project/models/lmo_maskrcnn_checkpoint.pth.tar

Do you have any advice on how to make it work?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions