Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is main source code out of sync with weights provided? #279

Open
devinvenable opened this issue Dec 21, 2024 · 1 comment
Open

Is main source code out of sync with weights provided? #279

devinvenable opened this issue Dec 21, 2024 · 1 comment

Comments

@devinvenable
Copy link

--output_path output
/home/devin/src/2024/python/games/venv/lib/python3.12/site-packages/timm/models/layers/init.py:48: FutureWarning: Importing from timm.models.layers is deprecated, please import via timm.layers
warnings.warn(f"Importing from {name} is deprecated, please import via timm.layers", FutureWarning)
Initialize
Device: cpu
/home/devin/src/2024/python/games/MiDaS/midas/base_model.py:11: FutureWarning: You are using torch.load with weights_only=False (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only will be flipped to True. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals. We recommend you start setting weights_only=True for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
parameters = torch.load(path, map_location=torch.device('cpu'))
Traceback (most recent call last):
File "/home/devin/src/2024/python/games/MiDaS/run.py", line 276, in
run(args.input_path, args.output_path, args.model_weights, args.model_type, args.optimize, args.side, args.height,
File "/home/devin/src/2024/python/games/MiDaS/run.py", line 126, in run
model, transform, net_w, net_h = load_model(device, model_path, model_type, optimize, height, square)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/devin/src/2024/python/games/MiDaS/midas/model_loader.py", line 50, in load_model
model = DPTDepthModel(
^^^^^^^^^^^^^^
File "/home/devin/src/2024/python/games/MiDaS/midas/dpt_depth.py", line 163, in init
self.load(path)
File "/home/devin/src/2024/python/games/MiDaS/midas/base_model.py", line 16, in load
self.load_state_dict(parameters)
File "/home/devin/src/2024/python/games/venv/lib/python3.12/site-packages/torch/nn/modules/module.py", line 2584, in load_state_dict
raise RuntimeError(
RuntimeError: Error(s) in loading state_dict for DPTDepthModel:
Unexpected key(s) in state_dict: "pretrained.model.blocks.0.attn.relative_position_index", "pretrained.model.blocks.1.attn.relative_position_index", "pretrained.model.blocks.2.attn.relative_position_index", "pretrained.model.blocks.3.attn.relative_position_index", "pretrained.model.blocks.4.attn.relative_position_index", "pretrained.model.blocks.5.attn.relative_position_index", "pretrained.model.blocks.6.attn.relative_position_index", "pretrained.model.blocks.7.attn.relative_position_index", "pretrained.model.blocks.8.attn.relative_position_index", "pretrained.model.blocks.9.attn.relative_position_index", "pretrained.model.blocks.10.attn.relative_position_index", "pretrained.model.blocks.11.attn.relative_position_index", "pretrained.model.blocks.12.attn.relative_position_index", "pretrained.model.blocks.13.attn.relative_position_index", "pretrained.model.blocks.14.attn.relative_position_index", "pretrained.model.blocks.15.attn.relative_position_index", "pretrained.model.blocks.16.attn.relative_position_index", "pretrained.model.blocks.17.attn.relative_position_index", "pretrained.model.blocks.18.attn.relative_position_index", "pretrained.model.blocks.19.attn.relative_position_index", "pretrained.model.blocks.20.attn.relative_position_index", "pretrained.model.blocks.21.attn.relative_position_index", "pretrained.model.blocks.22.attn.relative_position_index", "pretrained.model.blocks.23.attn.relative_position_index".

@Augustus2011
Copy link

@devinvenable hey i face the same issue, to fix it just install the correct version of dependencies

    pip install opencv-python==4.6.0.66 imutils==0.5.4 timm==0.6.12 einops==0.6.0 numpy=1.23.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants