caodoanh2001 / upar_challenge

Official repository of the first-ranking solution for the UPAR2024 Challenge - Track 1.
20 stars 7 forks source link

Which model (backbone, classifier) is used for 'best_model.pth'? #1

Open GArs0N opened 6 months ago

caodoanh2001 commented 6 months ago

Hi,

In fact, if you initialize the model by using below lines:

https://github.com/caodoanh2001/upar_challenge/blob/fd31f39f6d7ed8175c5f876af5e3b7f863e8eab2/infer_upar_test_phase.py#L62C1-L71C49

It should be exactly matched with all keys in best_model.pth.

However, for more details, here is the implementation of the backbone C2T-Net that we discussed in the paper: https://github.com/caodoanh2001/upar_challenge/blob/fd31f39f6d7ed8175c5f876af5e3b7f863e8eab2/models/backbone/swin_transformer2.py#L1140

And here is the classifier: https://github.com/caodoanh2001/upar_challenge/blob/fd31f39f6d7ed8175c5f876af5e3b7f863e8eab2/models/base_block.py#L88-L110

Best

GArs0N commented 5 months ago

Thanks for your attention and such detailed answer! Now that's fine, I've merely mixed up configs. But I'm left with another question about Age classes, what ranges correspond to them (Age-Young, Age-Adault, Age-Old)?

caodoanh2001 commented 5 months ago

Hi mate,

What do you mean "ranges"? If you mean the order of age attributes, it is as same as you mentioned, that is: young, adult and old.

Hence, if you see in the annotation csv file, each row is binary attribute annotation. For instance, if one sample indicating person who is young, the annotation should be 1,0,0,.... For adult, it should be 0,1,0,....

More detail regarding to dataset description you could find here.

Best

GArs0N commented 5 months ago

I mean the age range, for instace, Young is considered up to 20, Adult - between 20 and 50, Old is over 50. Yes, I have been trying to find answer in dataset description, but couldn't.

Thanks in advance.

caodoanh2001 commented 5 months ago

Hi,

I am sorry for the late reply. It seems that the dataset provided by the organizer is the combination of previous existing datasets as training set, which are Market-1501, PETA, PA100K, and the testing set is collected from MEVID dataset. Perhaps you could find the information you mentioned in original studies for those datasets.

Best

AlexanderDashkov commented 5 months ago

Hi,

@caodoanh2001 thank you for your incredible work. However, I seem to be stuck with the same problem @GArs0N encountered. When I run inference script it shows that a large number of keys is missing, and I'm using default config and best_model.pth from docker image you provided.

@GArs0N thank you for raising this issue, please, let me know how you managed to resolve it. I didn't change anything in config files, but added the following line:

cfg.set_new_allowed(True)

in config/default.py (update_config) to prevent KeyError: 'Non-existent config key: DATASET.PHASE1_ROOT_PATH'

as a feature extractor pretrained weights I used file from here

https://github.com/microsoft/Swin-Transformer/tree/main

Swin-L | ImageNet-22K | 224x224 | 86.3 | 97.9 | 197M | 34.5G | 141

maybe there is something I need to change in the config?

Maybe there is something I'm missing, so @caodoanh2001 I would greatly appreciate if you could clarify the expected behavior for default config and using best_model.pth.

Thanks!

caodoanh2001 commented 5 months ago

Hi @AlexanderDashkov, can you show me which keys are supposed to be missing when you load the checkpoint I provided? Thank you

GArs0N commented 5 months ago

Hi,

@caodoanh2001 thank you for your incredible work. However, I seem to be stuck with the same problem @GArs0N encountered. When I run inference script it shows that a large number of keys is missing, and I'm using default config and best_model.pth from docker image you provided.

@GArs0N thank you for raising this issue, please, let me know how you managed to resolve it.

Good day, Alexander! In my case there was redundantly added 'module.' in each weights name. At the very bottom of the "upar_challenge/tools/function.py" file, I overwrited the loading weights on:


def get_reload_weight(model_path, model, pth='ckpt_max.pth'):
    model_path = os.path.join(model_path, pth)
    load_dict = torch.load(model_path, map_location=lambda storage, loc: storage)

    if isinstance(load_dict, OrderedDict):
        pretrain_dict = load_dict
    else:
        pretrain_dict = load_dict['state_dicts']
        print(f"best performance {load_dict['metric']} in epoch : {load_dict['epoch']}")

    pretrain_dict = OrderedDict((k.replace('module.', ''), v) for k, v in pretrain_dict.items())   # rename weights

    model.load_state_dict(pretrain_dict, strict=True)

    return model