darkflow icon indicating copy to clipboard operation
darkflow copied to clipboard

Assertion error: over-read yolo.weights

Open ramarajan09 opened this issue 9 years ago • 35 comments

I tried to run ./flow --test test/ --model cfg/yolo.cfg --load yolo.weights --gpu 1.0

I get loading yolo.weights .... and then assertion error: Over-read yolo.weights.

However, when I run the same command with tiny-yolo.cfg and tiny-yolo.weights it works. I downloaded the weights file from https://pjreddie.com/darknet/yolo/

ramarajan09 avatar Mar 28 '17 12:03 ramarajan09

i guess u had used wrong weights, it didn't match with cfg. i tried with yolo.cfg & yolo.weights it worked fine. however when i train yolo-voc.cfg with custom class, i get the same error message with my trained weights. i would appreciate if someone can explain what this error mean.

Prakash19921206 avatar Mar 28 '17 14:03 Prakash19921206

The .weights parser follow .cfg layer by layer, reading the corresponding chunk of bytes from .weights, but then there is still layer to read while the parser has already reach the end of .weights; that is when you have the assertion error.

Please give the command that leads to this error. If you want to custom your class, then there is a few places to make modifications:

  1. Number of filters in the last conv layer in .cfg
  2. class number in region layer
  3. labels.txt

Then run

./flow --model cfg/model.cfg --load bin/model.weights --train

thtrieu avatar Mar 28 '17 14:03 thtrieu

Try training your network from scratch, the latest weights https://pjreddie.com/darknet/yolo/ don't seem to align with the cfg file. I've run into the same problem with yolo.weights and yolo-voc.weights, however my custom trained network's weights work just fine

Dhruv-Mohan avatar Mar 29 '17 06:03 Dhruv-Mohan

Could you provide instructions to train using yolo.cfg file. Thanks

On Wed, Mar 29, 2017 at 12:20 PM, Dhruv-Mohan [email protected] wrote:

Try training your network from scratch, the latest weights https://pjreddie.com/darknet/yolo/ don't align with the cfg file. I've run into the same problem with yolo.weights and yolo-voc.weights, however my custom trained network's weights work just fine

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/thtrieu/darkflow/issues/107#issuecomment-289999490, or mute the thread https://github.com/notifications/unsubscribe-auth/AZgJMHWUgCDnwlS_s1HY5RcBNrVSAWusks5rqf9CgaJpZM4Mrj84 .

ramarajan09 avatar Mar 29 '17 08:03 ramarajan09

same problem. use readme instruction with yolo.cfg and v2 weights of http://pjreddie.com/media/files/yolo-voc.weights

kinhunt avatar Apr 02 '17 10:04 kinhunt

@kinhunt yolo.cfg and yolo-voc.weights don't match. Even the new yolo.weights does not match yolo.cfg, it seems the official YOLO site does not keep their files reliably.

thtrieu avatar Apr 03 '17 09:04 thtrieu

@thtrieu thank you to clear out. do you know where to find the matching files?

kinhunt avatar Apr 03 '17 10:04 kinhunt

@kinhunt i've hunted for many days and haven't found em. You're best best is to train from scratch

Dhruv-Mohan avatar Apr 03 '17 10:04 Dhruv-Mohan

I can upload mine. Wait for ~ 24 hours.

thtrieu avatar Apr 03 '17 10:04 thtrieu

@thtrieu good news. thank you

kinhunt avatar Apr 03 '17 10:04 kinhunt

@Dhruv-Mohan @kinhunt see updated README, I uploaded some of the weights file.

thtrieu avatar Apr 03 '17 14:04 thtrieu

got it thank you. it works

kinhunt avatar Apr 03 '17 17:04 kinhunt

@thtrieu could you provide the steps you followed to trainj on coco dataset to generate yolo.weights file. I would liketo repeat the same and generate weights file for yolov2 on coco dataset.

ramarajan09 avatar Apr 04 '17 10:04 ramarajan09

Hi @thtrieu, I have followed steps you mentioned to retrain the model with custom number of classes

[convolutional] size=1 stride=1 pad=1 filters=30 activation=linear

[region] anchors = 1.08,1.19, 3.42,4.41, 6.63,11.38, 9.42,5.11, 16.62,10.52 bias_match=1 classes=1 coords=4 num=5

I also have just one label in label.txt. But when i run this with the tiny weights file i downloaded from your google share [https://drive.google.com/drive/folders/0B1tW_VtY7onidEwyQ2FtQVplWEU tiny-yolo-voc.weights] , it fails with assertion error

AssertionError: expect 63082056 bytes, found 63471556

Can you help me understand what might be wrong here.

itsayush avatar May 15 '17 18:05 itsayush

I had a similar problem with a previously custom-trained weight from darknet, I copied the same .cfg file with the weight to try it on darkflow and got: AssertionError: expect 202314760 bytes, found 202314764 It only differs by 4 bytes so am I missing some settings?

deng1028 avatar Jul 03 '17 21:07 deng1028

@deng1028 have you solved your problem yet? I have the same problem.

helloGitHub1993 avatar Jul 21 '17 05:07 helloGitHub1993

@helloGitHub1993 have you solved your problem yet? I have the same problem.

beerboaa avatar Aug 04 '17 09:08 beerboaa

@helloGitHub1993 go into loader.py in utils folder ,then change self.offset = 20 on line 121

beerboaa avatar Aug 04 '17 09:08 beerboaa

@beerboaa i used another way. flow -model cfg/yolo-new.cfg(replace it with your training cfg) --load -1 --imgdir yourimgdir. It works for me and you can have a try.By the way, you dont need to train again.

helloGitHub1993 avatar Aug 05 '17 07:08 helloGitHub1993

@itsayush have you solved your problem yet? I also followed the same steps as you and have the same problem with training custom data (1 class). I tried changing self.offset = 1 in loader.py, it didn't work. My command: flow --train --model cfg/tiny-yolo-voc-1c.cfg --load bin/tiny-yolo-voc.weights --annotation train/Annotations/ --dataset train/Images/ --config cfg/ --gpu 0.9 But it works well with: flow --imgdir sample_img/ --model cfg/tiny-yolo-voc.cfg --load bin/tiny-yolo-voc.weights --gpu 0.9 AssertionError: expect 63471541 bytes, found 63471556

Can anyone help me?

ryan181810606 avatar Sep 05 '17 15:09 ryan181810606