Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError with four byte size difference when converting #421

Open
sunsided opened this issue Nov 3, 2017 · 17 comments
Open

AssertionError with four byte size difference when converting #421

sunsided opened this issue Nov 3, 2017 · 17 comments

Comments

@sunsided
Copy link

sunsided commented Nov 3, 2017

I'm getting a rather weird error trying to convert a darknet trained Tiny YOLO (adjusted model, transfer learned using a custom dataset) using flow --savepb, which complains about finding an unexpected file size. The size difference appears to be exactly four bytes though:

Traceback (most recent call last):
  File "./flow", line 6, in <module>
    cliHandler(sys.argv)
  File "/home/mmayer/dev/ml/darkflow/darkflow/cli.py", line 22, in cliHandler
    tfnet = TFNet(FLAGS)
  File "/home/mmayer/dev/ml/darkflow/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "/home/mmayer/dev/ml/darkflow/darkflow/dark/darknet.py", line 27, in __init__
    self.load_weights()
  File "/home/mmayer/dev/ml/darkflow/darkflow/dark/darknet.py", line 82, in load_weights
    wgts_loader = loader.create_loader(*args)
  File "/home/mmayer/dev/ml/darkflow/darkflow/utils/loader.py", line 105, in create_loader
    return load_type(path, cfg)
  File "/home/mmayer/dev/ml/darkflow/darkflow/utils/loader.py", line 19, in __init__
    self.load(*args)
  File "/home/mmayer/dev/ml/darkflow/darkflow/utils/loader.py", line 77, in load
    walker.offset, walker.size)
AssertionError: expect 63184556 bytes, found 63184560

I was trying it with different versions of TensorFlow, specifically 1.0.1 and 1.3.1, but that didn't change anything.
Does anyone have an idea what could trigger this issue?

@sunsided
Copy link
Author

sunsided commented Nov 3, 2017

This comment on #107 suggests that training from scratch might solve this issue. I retrained the network using darknet an converted it again, but do still receive the same error.

@sunsided
Copy link
Author

sunsided commented Nov 3, 2017

This comment suggests to change self.offset = 16 to self.offset = 20 in utils/loader.py's weights_walker.__init__() method. If I do that the error disappears but I have no idea if that is a smart thing to do.

@QueenJuliaZxx
Copy link

I meet this problems too,I think it is caused by the unpair between .weight and .cfg , maybe it is a little cue, but I have no idea to solve it,so sorry

@shangliy
Copy link

Modify loader.py under darkflow/utils may help.
Change the line 121 from self.offset = 16 to self.offset = 20~~~
This work for me, hope help~

@QueenJuliaZxx
Copy link

QueenJuliaZxx commented Nov 17, 2017 via email

@wingerboy
Copy link

i have Changed the line 121 from self.offset = 16 to self.offset = 20! but the same error not disappear!

@wingerboy
Copy link

why should we change this number "self.offset" value

@ttorkar
Copy link

ttorkar commented Jan 5, 2018

My guess is that the offset that deals with the difference between c and python but I could be wrong. Can you try reduce the offset to 12 to keep the expected bytes equal to the actual bytes. Let me know how that goes.

@wingerboy
Copy link

This is my training output used darkflow, please tell me, what is the format of the file, why not get the .CKPT format file! How can I generate the required weight file for tensorflow?(.ckpt)
image

@ttorkar
Copy link

ttorkar commented Jan 5, 2018

@yw455801125 how did you get it working? You can convert it by using --savepb or something similar. It is in the Readme.

@shangliy
Copy link

shangliy commented Jan 5, 2018

@yw455801125 The weights I used to transform are from Darknet not darkflow. The weights storage format from Darkflow and Darknet are different. So, I guess my solution may not work on your case.

@nicolefinnie
Copy link

nicolefinnie commented Jan 23, 2018

@yw455801125 I think it's because the size of the header of the most up-to-date yolo v2 weights changed from 16 bytes to 20 bytes, so the weights_walker doesn't reach the end of the file because it expects an older header size. If I hit the same problem, I'd try to change the self.offset from 16 to file size - expected size, in case the weight files change again.

@fbadaud
Copy link

fbadaud commented May 16, 2018

@yw455801125 in case you have not solved this issue yet or for others , you need to upgrade your darkflow installation after your modification of darkflow/utils/loader.py
you can use: pip install . --upgrade
anyway i got another error now with labels mismatches:
/anaconda2/lib/python2.7/site-packages/darkflow/net/yolo/init.py", line 24, in constructor
).format(meta['model'])
AssertionError: labels.txt and ../darknet/cfg/yolov2-tiny.cfg indicate inconsistent class numbers

@hsgaurav
Copy link

go the same error
AssertionError: labels.txt and ../darknet/cfg/yolov2-tiny.cfg indicate inconsistent class numbers
please someone have any answer REPLY

@fbadaud
Copy link

fbadaud commented Jun 20, 2018

@hsgaurav
to fix error in labels i just link the labels.txt to the corresponding file with list of label used on the dataset on which the network as been trained.
for example for yolov2-voc I linked to darknet/data/voc.names
etc...

@adhi-thirumala
Copy link

@fbadaud how do you link a file

@DigvijaySingh7720
Copy link

Error :- AssertionError: expect 63184556 bytes, found 63184560

Solution : " ./darkflow/utils/loader.py" at line 121, you will find self.offset= 16 or 20.
update to be done : - found 63184560 - expect 63184556 = 4, then add 4 to self.offset = add this 4 (or any other value) diff to 16 or 20 and then run your command again.

Best of Luck, it work for me, hope it may work for you as well, keep helping other.

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

No branches or pull requests

10 participants