facebookresearch / ConvNeXt

Code release for ConvNeXt model
MIT License
5.78k stars 696 forks source link

cannot load all 22k_models #125

Open Nise-2-meet-U opened 2 years ago

Nise-2-meet-U commented 2 years ago

C:\ProgramData\Anaconda3\envs\yolo\python.exe G:/nft/code/inference.py Traceback (most recent call last): File "G:/nft/code/inference.py", line 37, in model = con.convnext_xlarge(pretrained=True, in_22k=True) File "G:\nft\code\convnext.py", line 211, in convnext_xlarge model.load_state_dict(checkpoint["model"]) File "C:\ProgramData\Anaconda3\envs\yolo\lib\site-packages\torch\nn\modules\module.py", line 1482, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for ConvNeXt: size mismatch for head.weight: copying a param with shape torch.Size([21841, 2048]) from checkpoint, the shape in current model is torch.Size([1000, 2048]). size mismatch for head.bias: copying a param with shape torch.Size([21841]) from checkpoint, the shape in current model is torch.Size([1000]).

theguardsgod commented 2 years ago

u need to modify num_classes=21841

kalelpark commented 1 year ago

model = convnext_base(pretrained = True, in_22k = True, num_classes=21841)