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

CFS #3

Open
jazzseow opened this issue Jan 5, 2022 · 6 comments
Open

CFS #3

jazzseow opened this issue Jan 5, 2022 · 6 comments

Comments

@jazzseow
Copy link

jazzseow commented Jan 5, 2022

May I know which part of the code includes the CFS ?

@michuanhaohao
Copy link
Collaborator

We uploaded the filtered result of the CFS. You can directly use our results to save time. We didn't upload the code and many intermediate models because it is a copy process of the pre-training and fine-tuning. We tested many times and found that CFS was robust. The performance can be easily reproduced.

For the reference, here is the original code of CFS. We didn't clear it.

import torch
from model import make_model
from config import cfg
import torchvision.transforms as T
from torchvision.datasets import ImageFolder
from torch.utils.data import DataLoader
from tqdm import tqdm
import numpy as np
import pickle

if __name__ == "__main__":
    cfg.MODEL.NAME = 'transformer'
    cfg.MODEL.TRANSFORMER_TYPE = 'deit_small_patch16_224_TransReID'
    cfg.MODEL.PRETRAIN_PATH = './model/vit_small_cfs_lup_20ep.pth'
    cfg.INPUT.SIZE_TRAIN = cfg.INPUT.SIZE_TEST = [256,128]
    cfg.TEST.NECK_FEAT = 'before'
    model = make_model(cfg, num_class=1, camera_num=0, view_num = 0)
    model2 = make_model(cfg, num_class=1, camera_num=0, view_num = 0)
    model2.load_param('./log/transreid/vit_small/lup_dino_20ep_mm/transformer_120.pth')
    model = model.cuda()
    model = model.eval()
    model2 = model2.cuda()
    model2 = model2.eval()
    val_transforms = T.Compose([
        T.Resize([256,128]),
        T.ToTensor(),
        T.Normalize(mean=[0.5,0.5,0.5], std=[0.5,0.5,0.5])
        ])

    test_set = ImageFolder(root='./datasets/LUP',transform=val_transforms)
    test_loader = DataLoader(test_set, batch_size=2048, num_workers=4, shuffle=False)
    forget_score = []
    for n_iter, (img, type_id) in enumerate(tqdm(test_loader)):
        with torch.no_grad():
            img = img.cuda()
            feat1 = model(img)
            feat2 = model2(img)
            forget_score.extend(torch.nn.functional.cosine_similarity(feat1,feat2))
    forget_score = torch.tensor(forget_score)
    sorted, indices = torch.sort(forget_score,descending=True)
    save_list = []
    for i in indices:
        save_list.append(test_set.imgs[i][0])
    pickle.dump(save_list, open("./save/cfs_list.pkl", "wb"))

@michuanhaohao
Copy link
Collaborator

michuanhaohao commented Jan 5, 2022

vit_small_cfs_lup_20ep.pth: pre-train ViT-S on full LUP with 20 epochs.
transformer_120.pth: finetune the pre-trained model on Market and MSMT17.

@jazzseow
Copy link
Author

jazzseow commented Jan 5, 2022

Thank you for your explanation.

I have realised you do not use SIE. Is it because SIE is not suitable for cross domain evaluation?

@michuanhaohao
Copy link
Collaborator

Thank you for your explanation.

I have realised you do not use SIE. Is it because SIE is not suitable for cross domain evaluation?

SIE can improve the performance, but using SIE is not fair to compare with other methods. Additionally, SIE is not the contribution of this paper.

@hh23333
Copy link

hh23333 commented Mar 15, 2022

Very solid work! I want to use it as a strong baseline, but using the pretrained model with CFS seems not fair to compare with other works in my task. So, may I ask for the pretrained model w/o CFS or with Imagenet pretraining? Thanks!

@siyuch-fdu
Copy link

siyuch-fdu commented May 19, 2022

vit_small_cfs_lup_20ep.pth: pre-train ViT-S on full LUP with 20 epochs. transformer_120.pth: finetune the pre-trained model on Market and MSMT17.

In CFS section, can I use the fully pre-trained model you provided(such as vit_base_ics_384) as model1, and use model1 to finetune in our own dataset as model2, then use model1 and model2 to generate cfs list?

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

4 participants