naver / mast3r

Grounding Image Matching in 3D with MASt3R
Other
796 stars 45 forks source link

Errors with the shape of img_size #18

Closed Loping151 closed 1 month ago

Loping151 commented 1 month ago
noname in 🌐 junkserver in mast3r on  main [!?] via 🐍 v3.11 via 🅒 mast3r took 26s
❯ python3 demo.py --model_name MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric
Traceback (most recent call last):
  File "/home/mast3r/demo.py", line 37, in <module>
    model = AsymmetricMASt3R.from_pretrained(weights_path).to(args.device)
  File "/home/mast3r/mast3r/model.py", line 52, in from_pretrained
    return super(AsymmetricMASt3R, cls).from_pretrained(pretrained_model_name_or_path, **kw)
  File "/home/mast3r/dust3r/dust3r/model.py", line 79, in from_pretrained
    return super(AsymmetricCroCo3DStereo, cls).from_pretrained(pretrained_model_name_or_path, **kw)
  File "/home/.local/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
  File "/home/.local/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py", line 511, in from_pretrained
    instance = cls._from_pretrained(
  File "/home/.local/lib/python3.10/site-packages/huggingface_hub/hub_mixin.py", line 727, in _from_pretrained
    model = cls(**model_kwargs)
  File "/home/mast3r/mast3r/model.py", line 45, in __init__
    super().__init__(**kwargs)
  File "/home/mast3r/dust3r/dust3r/model.py", line 71, in __init__
    self.set_downstream_head(output_mode, head_type, landscape_only, depth_mode, conf_mode, **croco_kwargs)
  File "/home/mast3r/mast3r/model.py", line 55, in set_downstream_head
    assert img_size[0] % patch_size == 0 and img_size[
TypeError: 'int' object is not subscriptable

I wonder what happens. It seems to me that this param is passed from croco_kwargs, and it is set as

img_size=224,           # input image size

I wonder if I got something wrong. I did not change anything before I ran.

yocabon commented 1 month ago

This error happens when the 'weights_path' is incorrect (it doesn't load the correct arguments for AsymmetricMASt3R, ends up using the defaults from croco that are not compatible).

with --model_name MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric, it will look for the model in https://huggingface.co/naver/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric

so either you are using an older version of huggingface_hub that cannot load the safetensors, or you cannot connect to it. you can try updating huggingface_hub, or manually downloading the checkpoints weights wget https://download.europe.naverlabs.com/ComputerVision/MASt3R/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric.pth -P checkpoints/ and using --weights checkpoints/MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric.pth instead of using --model_name MASt3R_ViTLarge_BaseDecoder_512_catmlpdpt_metric

Loping151 commented 1 month ago

Done that. Thank u for your instant response and kind help.