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

Confusion between large/base with depth anything v1/v2 #17

Open
JonathannJacobs opened this issue Mar 6, 2025 · 1 comment
Open

Confusion between large/base with depth anything v1/v2 #17

JonathannJacobs opened this issue Mar 6, 2025 · 1 comment

Comments

@JonathannJacobs
Copy link

In the actual infer.py we can read :

Load model

if arch_name == 'depthanything-large':
    model = DepthAnything(**model_kwargs['vitl']).to(device)
elif arch_name == 'depthanything-base':
    model = DepthAnythingV2(**model_kwargs['vitb']).to(device)

This made me very confused because it's suggesting using the large model actually is depth anything v1 large while i was expecting the v2 large.
Is that correct ?

If it is correct i suggest renaming arch names for including v1 or v2 in it.

@shuiyued
Copy link
Collaborator

shuiyued commented Mar 7, 2025

Hello,

The difference lies in the naming convention of the model key names.

Both are v2 models, but the network key names were modified during development.

In fact, you can achieve the conversion between our two models("DepthAnything", DepthAnythingV2) by using the following code:

# load large model
model_weights = load_file(checkpoint_path)
for key in model_weights :
  new_key = key.replace('backbone.blocks.0.', 'pretrained.blocks.').replace('backbone.', 'pretrained.')
  ckpt_new[new_key] = model_weights[key]

model_kwargs = dict(
            vitl=dict(
                encoder="vitl", 
                features=256, 
                out_channels=[256, 512, 1024, 1024], 
            ),
        )
model = DepthAnythingV2(**model_kwargs['vitl']).to(device)
model.load_state_dict(ckpt_new)

I will fix it—it’s clearly a misunderstanding.

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