Open robertc-git opened 5 years ago
Hi robert @robertc-git I met the same problem of wrong weights as you. And I didnot solve it with ur solution. Can u give me more advice? Thank you so much.
Hi @Enshall ,
Since the vgg-16 weights file seems to have other numbers where the major and minor values should be stored, the above fix worked for me because when the code was run, the interpreted values of major and minor happened to both be over 1000. Perhaps due to differences in platforms or compilers, your compiled code interpreted those as other values, perhaps negative. You can check that by debugging or printing the values of major and minor. For this vgg-16.weights file only, perhaps the following workaround would work for you:
Change:
if ((major * 10 + minor) >= 2) {
to:
if(0) {
In case you'd like to make sure you're using the same vgg-16.weights file that I used, here's the md5sum for my file: c967493c6bdaa5908cce3d9e6b57afdb vgg-16.weights
Hi robert @robertc-git I make it. I found the reason is that the params of fc need to be transposed which I didnt. It is your previous infos that give me the clue, Thank u so much !!
Hello, I downloaded and compiled a fresh copy of darknet from this repository, but when using the command: ./darknet classifier predict cfg/imagenet1k.data cfg/vgg-16.cfg vgg-16.weights data/eagle.jpg
I get the following unusual results:
data/eagle.jpg: Predicted in 0.035000 seconds. cassette: 0.001880 pinwheel: 0.001735 beacon: 0.001707 Band Aid: 0.001673 macaque: 0.001625
If instead I run it with other networks, such as darknet, darknet19, and AlexNet, with their corresponding cfg and weight files, I get the expected results, e.g. bald eagle: 0.671525 with the darknet network.
I tested this on both Linux (with and without GPU and OpenCV) and on Windows, and the results were the same. However, when running the same exact command using the executable compiled from the pjreddie darknet repository, the classification works fine. For all runs, I used weights downloaded from the pjreddie website. Do you know if there's something more that I need to do to get darknet from here working with VGG-16?
Edit: I also tried removing the [cost] type=sse entry at the end of vgg-16.cfg, but the problem still persists.
Thanks in advance for any help!
Edit: (Please let me know if I should add a new comment rather than include updated information in this one). It looks like the vgg-16.weights file may be missing some header information. The first three integers in the file should store a major, minor, and revision number, but the first three integers of the vgg-16.weights file are: 925353388 1063675494 973279855. In contrast, the first three integers of most of the other weight files are 0 1 0 or 0 2 0. There also appears to be a potentially related post for the original darknet here https://github.com/pjreddie/darknet/issues/267 , although the current vgg-16.weights file seemed to work fine for me on that version of darknet. Perhaps there's something different about how that version and this version of darknet interpret the files, although I haven't looked into that yet.
Edit with workaround: There's a difference between the pjreddie and AlexeyAB software in load_weights_upto() in parser.c, which allows the pjreddie version to work properly with the seemingly corrupt header in vgg-16.weights. The AlexeyAB software will work as well, if the following change is made near line 1246 of parser.c:
Change: if ((major 10 + minor) >= 2) { to: if ((major 10 + minor) >= 2 && major < 1000 && minor < 1000) {