[Python] Runtime Error while trying to train RTDetrV2 with Transformer

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to train RTDetrV2 for detection on water meter digit. I use an ipynb file form here https://colab.research.google.com/g...with-transformers.ipynb#scrollTo=a7kZr8OtGkIO. But when I run through the code:

    model = AutoModelForObjectDetection.from_pretrained(
    CHECKPOINT,
    id2label=id2label,
    label2id=label2id,
    anchor_image_size=None,
    ignore_mismatched_sizes=True,)


    This Warning appear

    `RuntimeError: Error(s) in loading state_dict for RTDetrV2ForObjectDetection:
    size mismatch for model.denoising_class_embed.weight: copying a param with shape torch.Size([81, 256]) from checkpoint, the shape in current model is torch.Size([12, 256]).
    size mismatch for model.enc_score_head.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.enc_score_head.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.0.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.0.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.1.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.1.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.2.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.2.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.3.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.3.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.4.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.4.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).
    size mismatch for model.decoder.class_embed.5.weight: copying a param with shape torch.Size([80, 256]) from checkpoint, the shape in current model is torch.Size([11, 256]).
    size mismatch for model.decoder.class_embed.5.bias: copying a param with shape torch.Size([80]) from checkpoint, the shape in current model is torch.Size([11]).


    `

    I running this ipynb on pycharm.

    I try to delete id2label and label2id. It does not show the error but when I try to train for only one epoch it still training. IDK how to check if it works or not.

    Continue reading...

Compartilhe esta Página