recognize-anything icon indicating copy to clipboard operation
recognize-anything copied to clipboard

Cannot run plus RAM model

Open ghost opened this issue 2 years ago • 2 comments

I have downloaded ram_plus_swin_large_14m and placed it in the correct directory, but trying to use it generates the following error:


pretrained/ram_plus_swin_large_14m.pth

Traceback (most recent call last): File "C:\taggers\recognize-anything\inference_ram.py", line 43, in model = ram(pretrained=args.pretrained, File "C:\taggers\recognize-anything\ram\models\ram.py", line 392, in ram model, msg = load_checkpoint_swinlarge(model, pretrained, kwargs) File "C:\taggers\recognize-anything\ram\models\utils.py", line 274, in load_checkpoint_swinlarge msg = model.load_state_dict(state_dict, strict=False) File "C:\taggers\recognize-anything\venv\lib\site-packages\torch\nn\modules\module.py", line 2152, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for RAM: size mismatch for label_embed: copying a param with shape torch.Size([233835, 512]) from checkpoint, the shape in current model is torch.Size([4585, 512]).

All I have changed is the model used. Can you advise iif I am missing some step here?

ghost avatar Dec 05 '23 09:12 ghost

Hi, you download ram_plus model, but you run the inference_ram.py, you should run inference_ram_plus.py

xinyu1205 avatar Dec 05 '23 09:12 xinyu1205

@xinyu1205 that was such a simple error and fix. Thank you for your quick reply!

ghost avatar Dec 05 '23 12:12 ghost