Skip to content

Some problems to run evaluate.py #2

@nviolante25

Description

@nviolante25

Hello,

Thank you for open-sourcing your project!

I'm trying to run the evaluation script using the pretrained models 2doc.pt and 3doc.pt from Huggingface) , which I placed under the folders configs/2d and configs/3d respectively.
To run the 2D model I'm doing

python evaluate.py -m configs/2d

I encountered some errors at this point, and here are the changes I made to fix them.
First, I changed the name of the .yml file in the folder configs from dtc_multilight_2d.yml to config.yml and adapted this line of code to read that config file instead of the required .py. With this change, I can load the model configuration.
Second, to load the 2doc.pt model I changed these lines into this:

model_ckpt = [step for step in os.listdir(model_path) if "pt" in step][0]
ckpt_path = os.path.join(model_path, model_ckpt)

So in the end ckpt_path=configs/2d/2doc.pt , and I can load the pretrained weights.

However, after doing this, the load_state_dict operation fails due to mismatch in the shapes of the parameters (see part of the error message below):

RuntimeError: Error(s) in loading state_dict for SwinT2D:
        size mismatch for conv_first.0.weight: copying a param with shape torch.Size([96, 7, 3, 3]) from checkpoint, the shape in current model is torch.Size([192, 7, 3, 3]).
        size mismatch for conv_first.0.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for conv_first.1.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([192, 192, 3, 3]).
        size mismatch for conv_first.1.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for conv_first.2.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([192, 192, 3, 3]).
        size mismatch for conv_first.2.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for conv_skip.weight: copying a param with shape torch.Size([96, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([192, 192, 3, 3]).
        size mismatch for conv_skip.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for conv_end.weight: copying a param with shape torch.Size([3, 96, 3, 3]) from checkpoint, the shape in current model is torch.Size([3, 192, 3, 3]).
        size mismatch for patch_embed.norm.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for patch_embed.norm.bias: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).
        size mismatch for layers.0.residual_group.blocks.0.norm1.weight: copying a param with shape torch.Size([96]) from checkpoint, the shape in current model is torch.Size([192]).

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