GithubHelp home page GithubHelp logo

Comments (5)

leejaeyong7 avatar leejaeyong7 commented on August 26, 2024 44

I've found that the bug is caused by timm version.
If you install older version of timm, it will work.

FYI, I've used timm==0.6.7

from zoedepth.

palol avatar palol commented on August 26, 2024 4

I was able to get it to work by reverting to timm=0.6.13. See the original discussion on the MiDaS repo: isl-org/MiDaS#215

from zoedepth.

charliememory avatar charliememory commented on August 26, 2024 1

FYI, you can also modify the source code in beit.py according to timm.models.beit.py without downgrade the timm version, i.e. change the variable names drop_path to drop_path1 and drop_path2
image

from zoedepth.

ntakouris avatar ntakouris commented on August 26, 2024

That's a problem that MiDaS models have (that carries over to ZoeDepth)

from zoedepth.

Connah-rs avatar Connah-rs commented on August 26, 2024

FYI, you can also modify the source code in beit.py according to timm.models.beit.py without downgrade the timm version, i.e. change the variable names drop_path to drop_path1 and drop_path2 image

Following on from @charliememory's comment - you can set the appropriate names on MiDaS fetched from torch.hub with something along the lines of:

def block_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tensor] = None):
    """
    Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes.
    """
    if self.gamma_1 is None:
        x = x + self.drop_path1(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias))
        x = x + self.drop_path1(self.mlp(self.norm2(x)))
    else:
        x = x + self.drop_path2(self.gamma_1 * self.attn(self.norm1(x), resolution,
                                                        shared_rel_pos_bias=shared_rel_pos_bias))
        x = x + self.drop_path2(self.gamma_2 * self.mlp(self.norm2(x)))
    return x

midas = torch.hub.load(
    "intel-isl/MiDaS", 'DPT_BEiT_L_384',
    pretrained=True, 
    force_reload=True, trust_repo=True,
)
for block in midas.pretrained.model.blocks:
    block.forward = types.MethodType(block_forward, block)

Works for me with timm==0.9.2.

from zoedepth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.