moondream icon indicating copy to clipboard operation
moondream copied to clipboard

Torch size mismatch

Open AWAS666 opened this issue 1 year ago • 1 comments

Just cloned this repo and running into a torch size mismatch error. If I do set the "ignore_mismatched_sizes" flag on the model it seems to run though, still weird.

Using python 3.10.12

Error log:

Traceback (most recent call last):
  File "/home/userName/Documents/moondream/batch_generate_example.py", line 10, in <module>
    moondream = Moondream.from_pretrained(
  File "/home/userName/Documents/moondream/venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3941, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/home/userName/Documents/moondream/venv/lib/python3.10/site-packages/transformers/modeling_utils.py", line 4473, in _load_pretrained_model
    raise RuntimeError(f"Error(s) in loading state_dict for {model.__class__.__name__}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for Moondream:
        size mismatch for region_model.size_features.weight: copying a param with shape torch.Size([128, 2]) from checkpoint, the shape in current model is torch.Size([256, 2]).
        size mismatch for region_model.size_encoder.weight: copying a param with shape torch.Size([2048, 256]) from checkpoint, the shape in current model is torch.Size([2048, 512]).
        You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.

AWAS666 avatar Nov 10 '24 22:11 AWAS666

Can be ignored for now (via ignore_mismatched_sizes=True) -- the region model is for the next upcoming version of the model, the current version doesn't use it.

vikhyat avatar Nov 18 '24 04:11 vikhyat