GithubHelp home page GithubHelp logo

Comments (5)

heilaw avatar heilaw commented on June 20, 2024 7

I just saw your another post.

The size match happens in the convolution layers for tl_heats and br_heats. The sizes of weights and biases in the pretrained model are [80, 256, 1, 1] and [80], which do not match your new dataset.

To prepare the model for fine-tuning on a different datasets, you can do the followings.

  1. In train.py, add nnet.save_params(0) after line 114. This forces the code to save a randomly initialized model with correct sizes before the training starts. After the model is saved, terminate the code by Ctrl + c.
  2. Replace the weights and biases in the trained model with the ones in the randomly initialized model. A PyTorch model is a dictionary, where the keys are the parameter names and values are the parameters. They can be loaded with torch.load. After loading, the parameters can be replaced by newmodel['param_name'] = oldmodel['param_name']. The parameter names you are looking for are:
  • 'module.tl_heats.0.1.weight'
  • 'module.tl_heats.0.1.bias'
  • 'module.tl_heats.1.1.weight'
  • 'module.tl_heats.1.1.bias'
  • 'module.br_heats.0.1.weight'
  • 'module.br_heats.0.1.bias'
  • 'module.br_heats.1.1.weight'
  • 'module.br_heats.1.1.bias'
  1. Save the model.
  2. Remove nnet.save_params(0) in step 1.
  3. Add "pretrain": "/path/to/the/pretrained/model" in the system section of the configuration file.

from cornernet.

heilaw avatar heilaw commented on June 20, 2024

All you need to do is add "pretrain": "/path/to/the/pretrained/model" in the system section of the configuration file. The code will load the pretrained file before it starts training.

from cornernet.

YiLiangNie avatar YiLiangNie commented on June 20, 2024

Hi heilaw,
I find this function in /models/CornerNet.py, and I want to know what does the n=5 means? thank you.

class model(kp):
def init(self, db):
n = 5
dims = [256, 256, 384, 384, 384, 512]
modules = [2, 2, 2, 2, 2, 4]
out_dim = 80
super(model, self).init(
n, 2, dims, modules, out_dim,
make_tl_layer=make_tl_layer,
make_br_layer=make_br_layer,
make_pool_layer=make_pool_layer,
make_hg_layer=make_hg_layer,
kp_layer=residual, cnv_dim=256
)

from cornernet.

heilaw avatar heilaw commented on June 20, 2024

The number of downsamplings in each hourglass module.

from cornernet.

YiLiangNie avatar YiLiangNie commented on June 20, 2024

Hi heilaw,
If I want to change the project to python2.7, what files need to be modified? thx!

from cornernet.

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.