Beckschen / ViTamin

[CVPR 2024] Official implementation of "ViTamin: Designing Scalable Vision Models in the Vision-language Era"
Apache License 2.0
161 stars 5 forks source link

field conv_cfg is not allowed #10

Closed Leaderzhangyi closed 3 weeks ago

Leaderzhangyi commented 1 month ago

Hello Beckschen, when I tried to pull your model from huggingface, a dataclass check error occurred. This error can be easily fixed by modifying the source code, but this problem also exists when pulling on huggingface. How to solve it? Thanks

https://github.com/Beckschen/ViTamin/blob/24f74754792b3448e922c275023e0f80a27b2d19/ViTamin/models/vitamin.py#L82

fix:

conv_cfg: VitConvCfg = field(default_factory=VitConvCfg) 

env:

python-3.11 timm-1.0.7

code:

import torch
from PIL import Image
from transformers import AutoModel, CLIPImageProcessor
device = "cuda:0" if torch.cuda.is_available() else "cpu"

# obtained 69.1% zero-shot ImageNet score
model = AutoModel.from_pretrained(
    'jienengchen/ViTamin-S',
    trust_remote_code=True).to(device).eval()

error:

ValueError: mutable default <class 'transformers_modules.jienengchen.ViTamin-S.a33161305bb0c4154173fdb306de6a224440f616.vitamin.VitConvCfg'> for field conv_cfg is not allowed: use default_factory
Beckschen commented 1 month ago

Thank you for bringing this to my attention. I'm aware of the issue now. The timm code has fixed the field, and I can update the code in current repo.

Per your description: "This error can be easily fixed by modifying the source code, but this problem also exists when pulling on huggingface"

It seems that I need to correct the Hugging Face files. Please let me know if I'm mistaken.