Skip to content

AltCLIP has no effect on CIFAR10 after finetune #561

Description

@youyuge34

Description

I trained AltCLIP using official demo code with dataset CIFAR10. However, after 3 epochs, the finetuned weight has no effect on cifar10 images. I wonder if my way to load weight is wrong or not.

使用了官方的代码在cifar10上finetune后,对cifar中的动物图片识别反而完全失效了,想问下原因,是否是我加载权重的方式有问题?推理代码是用的demo里的。

import os
import torch
from PIL import Image
from flagai.auto_model.auto_loader import AutoLoader

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

loader = AutoLoader(
    task_name="txt_img_matching",
    model_name="AltCLIP-XLMR-L",   # Load the checkpoints from Modelhub(model.baai.ac.cn/models)
    model_dir="./checkpoints/"
)

model = loader.get_model()


tokenizer = loader.get_tokenizer()
transform = loader.get_transform()

weight_file = './checkpoints/cifar_altclip_9k/AltCLIP-XLMR-L/pytorch_model.bin'
model.load_state_dict(torch.load(weight_file, map_location='cpu')['module'])

model.eval()
model.to(device)
tokenizer = loader.get_tokenizer()

Alternatives

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions