Skip to content

Conversation

@zjuyzj
Copy link

@zjuyzj zjuyzj commented Sep 8, 2023

Proposed changes

In the latest version 1.8.0, Darknet.save_darknet_weights() generates a problematic *.weights file, in which "minor" field is always 0, however the length of "seen" field is 8 bytes.

This may cause abnormal offset calculation when try to use official Darknet or other third-party Darknet-compatible repository (e.g. rknn-toolkit by Rockchip) to load the exported *.weights file, corrupting the whole weights and biases behind the header, then leading to totally wrong inference!

Reference to the read and write of *.weights header, from Darknet's official implementation:

Related issues

Resolves #292, and all other problems likewise caused by wrong exported *.weights are totally resolved.

However, saved module state_dict (*.pth file) does not contain the value of "seen" class member, which is 0 by default.
Convert a *.pth to *.weights will fill the "seen" field zero, losing the original "seen" from any pretrained *.weights, which is just a little problem and not related to inference BTW.

Necessary checks

  • Update poetry package version semantically
  • Write documentation
  • Create issues for future work
  • Test on your machine

…implementation under C++, saved by save_darknet_weights().
…and avoid appending to the end of existing *.cfg file by mistake.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

convert this project's .pth to darknet's .weights

1 participant