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: expect 44948596 bytes, found 44948600 #802

Open
zef1611 opened this issue Jun 10, 2018 · 20 comments
Open

AssertionError: expect 44948596 bytes, found 44948600 #802

zef1611 opened this issue Jun 10, 2018 · 20 comments

Comments

@zef1611
Copy link

zef1611 commented Jun 10, 2018

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

@ideaRunner
Copy link

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

@ideaRunner
Copy link

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

@zef1611
Copy link
Author

zef1611 commented Jun 16, 2018

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

@Rabiah86
Copy link

Rabiah86 commented Jun 16, 2018

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

@derekwong66
Copy link

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

@dudqls1994
Copy link

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

@carlchandev
Copy link

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

@seek-ing
Copy link

@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

@SuperStriker
Copy link

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

@AbanoubMamdouh
Copy link

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!

@danFromTelAviv
Copy link

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

@shalin51
Copy link

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 )

@danFromTelAviv
Copy link

face palm*
thanks @shalin51

@mpky
Copy link

mpky commented Mar 15, 2019

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

@chenminhua
Copy link

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.

@540ul4rm6
Copy link

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)

@santarone
Copy link

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!

@rammanoj
Copy link

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

@TDA1JU
Copy link

TDA1JU commented Feb 19, 2020

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

@senkumartup
Copy link

senkumartup commented May 23, 2020

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

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