fredzzhang / upt

[CVPR'22] Official PyTorch implementation for paper "Efficient Two-Stage Detection of Human–Object Interactions with a Novel Unary–Pairwise Transformer"
https://fredzzhang.com/unary-pairwise-transformers
BSD 3-Clause "New" or "Revised" License
150 stars 24 forks source link

How to train the interaction head individually #49

Closed xiaoxiaoczw closed 2 years ago

xiaoxiaoczw commented 2 years ago

Hi Fred,

I would like to know that, how to freeze detector weights to train the interaction head individually? Thanks!

fredzzhang commented 2 years ago

Hi @xiaoxiaoczw,

The detector weights are in fact frozen already. We fine-tuned the object detector as a first stage and only train the interaction head next. The corresponding code is here.

    for p in upt.detector.parameters():
        p.requires_grad = False
    param_dicts = [{
        "params": [p for n, p in upt.named_parameters()
        if "interaction_head" in n and p.requires_grad]
    }]

Fred.

xiaoxiaoczw commented 2 years ago

Hi Fred,

Thanks for your quick feedback! By the way, which pretrained weights do I need to load if I want to train on my own dataset?

fredzzhang commented 2 years ago

To get the best performance, you would want to fine-tune the object detector on the custom dataset first, and then train the interaction head. But if the custom dataset has the same set of objects and you don't want to go through the trouble, you can just load the provided detector weights. You can choose amongst the pre-trained MS COCO weights, fine-tuned HICO-DET weights and the fine-tuned V-COCO weights. Which one works the best for you really depends on the dataset similarity. It would be hard to guess without running experiments.

Fred.

xiaoxiaoczw commented 2 years ago

Thanks for the suggestion!