mlfoundations / open_clip

An open source implementation of CLIP.
Other
9.93k stars 959 forks source link

[doc bug?] timm version #709

Closed RunsenXu closed 11 months ago

RunsenXu commented 11 months ago

Hi Open CLIP team,

I am using timm 0.4.12 and the latest version of the open clip, but the codes below will make timm = None since import timm.models.layers.attention_pool2d causes an error ModuleNotFoundError: No module named 'timm.models.layers.attention_pool2d'. I think your requirements.txt may specify the timm version?

try:
    import timm
    from timm.models.layers import Mlp, to_2tuple
    try:
        # old timm imports < 0.8.1
        from timm.models.layers.attention_pool2d import RotAttentionPool2d
        from timm.models.layers.attention_pool2d import AttentionPool2d as AbsAttentionPool2d
    except ImportError:
        # new timm imports >= 0.8.1
        from timm.layers import RotAttentionPool2d
        from timm.layers import AttentionPool2d as AbsAttentionPool2d
except ImportError:
    timm = None

Thanks for your great work!

Best, Runsen

rsomani95 commented 11 months ago

@RunsenXu probably best to upgrade your timm version. latest ver of openclip requires >= 0.9.8 my guess is that try except block was relevant for previous versions of timm but not anymore?

rwightman commented 11 months ago

it's a bit more complicated than 'requires' as if you don't use the models that need the latest timm you can e.g. use the normal 'ViT' models, etc. However, 0.4.12 is way old.

I've been on the fence re forcing the ver in requirements.txt up to the latest or leaving it slack for people to figure out as they need to reduce dep conflicts. requirements-training.txt always up to the latest needed to support all models.

RunsenXu commented 11 months ago

Yeah, you are right. People should check the requirements-training.txt if needed.