Darkflow: AssertionError: expect 44948596 bytes, found 44948600

Created on 10 Jun 2018  ·  20Comments  ·  Source: thtrieu/darkflow

so when i use this command on cmd c:\dark\darkflow-master>python flow --model cfg/yolov2-tiny.cfg --load bin/yolov2-tiny.weights
and then this error appears
2018-06-10 1
please help me fix this

Most helpful comment

All 20 comments

Hi, I have this issue too.
same yolov2-tiny.
AssertionError: expect 63820056 bytes, found 63820060
Can anyone help us?

thank you for that link
and btw do you want to contact with me so we can help each other in this darkflow stuff?

I had the same error with yolo not with tiny-yolo,
try to reduce the width and height in the cfg file.it solved the problem for me .
keep in mind that width and height values should be a multiple of 32

I got the same problem. I modified yolov2.cfg with 3 classes and used yolov2.weights to train my own dataset.
I tried this method https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file to solve the problem. However, it doesn't work. I replaced the offset = 16 with offset = 20, even offset = 40.

zihang@derek:~/project/darkflow$ flow --model cfg/yolov2-3c.cfg --load bin/yolov2.weights --train --annotation train/Annotations --dataset train/Images --gpu 1.0

/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/dark/darknet.py:54: UserWarning: ./cfg/yolov2.cfg not found, use cfg/yolov2-3c.cfg instead
cfg_path, FLAGS.model))
Parsing cfg/yolov2-3c.cfg
Loading bin/yolov2.weights ...
Traceback (most recent call last):
File "/home/zihang/anaconda3/envs/tensorflow/bin/flow", line 6, in
cliHandler(sys.argv)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/cli.py", line 26, in cliHandler
tfnet = TFNet(FLAGS)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/net/build.py", line 58, in __init__
darknet = Darknet(FLAGS)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/dark/darknet.py", line 27, in __init__
self.load_weights()
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/dark/darknet.py", line 82, in load_weights
wgts_loader = loader.create_loader(args)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/utils/loader.py", line 105, in create_loader
return load_type(path, cfg)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/utils/loader.py", line 19, in __init__
self.load(
args)
File "/home/zihang/anaconda3/envs/tensorflow/lib/python3.6/site-packages/darkflow/utils/loader.py", line 77, in load
walker.offset, walker.size)
AssertionError: expect 202355760 bytes, found 203934260

I also same error.... I cannot solved it.....Anyone help me

Oh, Jesus!
Come to see what I have found here!
https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file

I don't understand why, but it works!!! thank you!!

@dudqls1994
1、首先,我们在ubuntu下先用anaconda2(版本是2还是3不影响)安装了tensorflow.
2、darkflow要求的安装环境是Python3,那么把anaconda2里的Python2升级到python3.5就行,Ubuntu系统默认是自带python2.7的,在使用darkflow时,用source activate py35进入Python3.5环境再使用flow命令就行。
3、接下来,你可以在任何地方安装darkflow,但是要在py35环境下安装,换Python环境source activate py35,然后安装好你会看到darkflow的文件夹,这个文件夹没用,在安装darkflow的时候会自动拷贝到anaconda2/envs/py34/lib/python3.5/site-packages/darkflow/utils(我Python3.5命名的时候手抖,弄成了py34),要改的是上述目录下loader.py第121行,把self.offset = 16改成self.offset = 20

Oh, Jesus!
Come to see what I have found here!
https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file

Thanks man, you are a life saver

Tried @ideaRunner solution, didn't completely work, displayed another error, so I reduced the gpu from 1.0 to 0.8 and it worked fine! Thanks @ideaRunner! Sorry for not attaching any screenshots, I would have to recreate the problem.
N.B: If you use the same gpu for your display, it might create a problem to use 0.8 of the gpu, so I recommend you reduce gpu usage to 0.7 and it will work fine!

Oh, Jesus!
Come to see what I have found here!
https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file

so we don't have to go into the link that may break one day :

The solution is very simple, let's modify the line self.offset = 16 in the ./darkflow/utils/loader.py file and replace with self.offset = 20.

For me it did not work. the difference between expect and found shrank a lot though

Oh, Jesus!
Come to see what I have found here!
https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file

so we don't have to go into the link that may break one day :

The solution is very simple, let's modify the line self.offset = 16 in the ./darkflow/utils/loader.py file and replace with self.offset = 20.

For me it did not work. the difference between expect and found shrank a lot though

I had same problem but it can be solved by correct self.offset

if 44948596 bytes, found 44948600

means the difference (44948600- 44948596 ) should be added to self.offset.

self.offset= self.offset + 4 difference (44948600- 44948596 )

face palm*
thanks @shalin51

@shalin51 Does that mean that new walk function should be:

def walk(self, size):
if self.eof: return None
end_point = self.offset + 4 * (44948600- 44948596 )
assert end_point <= self.size, \
'Over-read {}'.format(self.path)

Should we just delete the size parameter then?

Here is my solution:

  1. pip uninstall darkflow
  2. change the source code in ./darkflow/utils/loader.py, just delete the "assert statement" or replace it by a warning
  3. reinstall it by pip install -e .

It works for me.

Notice: You still have to figure out that whether your cfg file and weights and labels.txt match to each other.

I solved the problem.

http://tn00343140a.pixnet.net/blog/post/299895872-yolo%e9%81%8b%e8%a1%8cdarkflow%e6%99%82%2c-%e5%87%ba%e7%8f%beassertionerror%3a-expect-20392940

Find the file "loader.py" and change the value of "self.offset".
updated self.offset = old_offset_value + (found_value - expected_value)

I also solved.

im just changing self.offset value as '20' "loader.py" in ~/darkflow/utils

i don't know why this working. but it's work!

I've been trying all the above specified methods. But nothing of it seem to be working!!

Is there any other way to solve this issue up!!

Oh, Jesus!
Come to see what I have found here!
https://sites.google.com/view/tensorflow-example-java-api/complete-guide-to-train-yolo/convert-darknet-weights-to-pb-file

Honestly I do not know how does it work, but it solved my issue, great!!

diff --git a/darkflow/utils/loader.py b/darkflow/utils/loader.py
index 723560d..e2fdaea 100644
--- a/darkflow/utils/loader.py
+++ b/darkflow/utils/loader.py
@@ -118,7 +118,8 @@ class weights_walker(object):
shape = (), mode = 'r', offset = 0,
dtype = '({})i4,'.format(4))
self.transpose = major > 1000 or minor > 1000
- self.offset = 16
+ self.offset = 20

  def walk(self, size):
      if self.eof: return None
Was this page helpful?
0 / 5 - 0 ratings

Related issues

zenineasa picture zenineasa  ·  25Comments

johaq picture johaq  ·  29Comments

mothman1 picture mothman1  ·  27Comments

jiankang1991 picture jiankang1991  ·  22Comments

ramarajan09 picture ramarajan09  ·  35Comments