Giter Club home page Giter Club logo

Comments (4)

catalinolaru1 avatar catalinolaru1 commented on July 27, 2024 2

Here, this should solve it. If there are any problems, let me know.

def save_weights(self, path, cutoff=-1):

    if cutoff:
        num_layers = len(self.module_list)
    else:
        num_layers = cutoff

    fp = open(path, 'wb')
    self.header_info[3] = self.seen
    self.header_info.tofile(fp)

    for i, (module_def, module) in enumerate(zip(self.module_defs[:cutoff], self.module_list[:cutoff])):
        if module_def['type'] == 'convolutional':
            conv_layer  = module[0]

            # If batch norm, load bn first
            if module_def['batch_normalize']:
                bn_layer    = module[1]

                bn_layer.bias.data.cpu().numpy().tofile(fp)
                bn_layer.weight.data.cpu().numpy().tofile(fp)
                bn_layer.running_mean.data.cpu().numpy().tofile(fp)
                bn_layer.running_var.data.cpu().numpy().tofile(fp)
            # Load conv bias
            else:
                conv_layer.bias.data.cpu().numpy().tofile(fp)

            # Load conv weights
            conv_layer.weight.data.cpu().numpy().tofile(fp)

    fp.close()

You should also add this to load_weights()
# added for saving weights
self.header_info = header

from pytorch-yolov3.

eriklindernoren avatar eriklindernoren commented on July 27, 2024

Thanks @catalinolaru1. Feel free to make a PR. :) If not I'll look into adding this.

from pytorch-yolov3.

catalinolaru1 avatar catalinolaru1 commented on July 27, 2024

Sure, i'll make a PR now.

from pytorch-yolov3.

SidHard avatar SidHard commented on July 27, 2024

thanks, @catalinolaru1 , I'll try it

from pytorch-yolov3.

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.