darkflow icon indicating copy to clipboard operation
darkflow copied to clipboard

AssertionError: expect 44948596 bytes, found 44948600

Open zef1611 opened this issue 7 years ago • 20 comments

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

zef1611 avatar Jun 10 '18 15:06 zef1611

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

ideaRunner avatar Jun 14 '18 07:06 ideaRunner

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

ideaRunner avatar Jun 16 '18 05:06 ideaRunner

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

zef1611 avatar Jun 16 '18 12:06 zef1611

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

Rabiah86 avatar Jun 16 '18 16:06 Rabiah86

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

derekwong66 avatar Aug 16 '18 09:08 derekwong66

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

dudqls1994 avatar Aug 22 '18 07:08 dudqls1994

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!!

carlchandev avatar Sep 23 '18 10:09 carlchandev

@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

seek-ing avatar Nov 23 '18 15:11 seek-ing

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

SuperStriker avatar Dec 06 '18 00:12 SuperStriker

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!

AbanoubMamdouh avatar Dec 16 '18 16:12 AbanoubMamdouh

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

danFromTelAviv avatar Feb 12 '19 12:02 danFromTelAviv

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 )

shalin51 avatar Feb 12 '19 21:02 shalin51

face palm* thanks @shalin51

danFromTelAviv avatar Feb 13 '19 08:02 danFromTelAviv

@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?

mpky avatar Mar 15 '19 12:03 mpky

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.

chenminhua avatar Jul 19 '19 06:07 chenminhua

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)

540ul4rm6 avatar Jul 26 '19 07:07 540ul4rm6

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!

santarone avatar Oct 21 '19 02:10 santarone

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!!

rammanoj avatar Nov 10 '19 06:11 rammanoj

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!!

TDA1JU avatar Feb 19 '20 04:02 TDA1JU

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

senkumartup avatar May 23 '20 18:05 senkumartup