Giter Site home page Giter Site logo

Comments (1)

LeopoldACC avatar LeopoldACC commented on August 12, 2024

Maybe I solved it by edit the key name in pth file.

    model = build_vovnet_fpn_backbone(config,input_shape = ShapeSpec(channels=3, height=448, width=800, stride=None))
    pretrained_model_whole = torch.load('/data/CenterFusion0/models/vovnet99_dd3d15m.pth',map_location=torch.device('cpu'))
    pretrained_model =pretrained_model_whole['model']
    pretrained_model_with_new_key = OrderedDict([])
    
    keys2del = ["fpn_lateral2.norm.num_batches_tracked", "fpn_output2.norm.num_batches_tracked", "fpn_lateral3.norm.num_batches_tracked", "fpn_output3.norm.num_batches_tracked", "fpn_lateral4.norm.num_batches_tracked", "fpn_output4.norm.num_batches_tracked", "fpn_lateral5.norm.num_batches_tracked", "fpn_output5.norm.num_batches_tracked", "top_block.p6.weight", "top_block.p6.bias"]
    for key in pretrained_model:
        if 'backbone.' in key:
            new_key = key.replace('backbone.','')
            pretrained_model_with_new_key[new_key] = pretrained_model[key]
    for key in keys2del:
        del pretrained_model_with_new_key[key]
    # missing_keys, unexpected_keys  = model.load_state_dict(pretrained_model)
    missing_keys, unexpected_keys  = model.load_state_dict(pretrained_model_with_new_key)
    
    print("[missing_keys]:", *missing_keys, sep="\n")
    print("[unexpected_keys]:", *unexpected_keys, sep="\n")

from dd3d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.