deep-diver / Soccer-Ball-Detection-YOLOv2

YOLOv2 trained against custom dataset
116 stars 43 forks source link

correct cfg and weights #16

Closed Longbowman closed 4 years ago

Longbowman commented 4 years ago

Hi I think there is correct weight problem. when I downloaded the cfg from this repository and yolo.weights from the readme it gave exactly the error described in the previous issue https://github.com/deep-diver/Soccer-Ball-Detection-YOLOv2/issues/3 when I corrected filter of last convolutional filter to 425 (as it is in full yolo) it loaded correctly but then I can't train. Probably because last filters should be 30 or 35 for two classes you can see the error below

tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
  (0) Invalid argument: Input to reshape is a tensor with 153425 values, but the requested shape requires a multiple of 12635
         [[{{node Reshape}}]]
         [[mul_34/_121]]
  (1) Invalid argument: Input to reshape is a tensor with 153425 values, but the requested shape requires a multiple of 12635
         [[{{node Reshape}}]]

Can you help me to find the correct weights file and cfg file for this algorithm?

Ign0reLee commented 4 years ago

Hi I remember there was a cfg file I uploaded in previous issue #3
If you use this cfg file, but same error occurs, It is a problem with the weight file you used

You can see exactly why this is happening in the weight file by reading issue #3

See this link https://github.com/deep-diver/Soccer-Ball-Detection-YOLOv2/issues/3#issuecomment-492896884 This is why it happens.

follow that comments, and download yolo-v2 weight files

If it doesn't well, please show me your files you used and the error message again.

And again, if the weight file in this repository is downloaded through Original author's drive, that's wrong.

Longbowman commented 4 years ago

Ign0reLee There is still an error let me provide full error for you

it finishes loading only when I change last filter to 425 but it gives the error I mentioned before on training

WARNING: Logging before flag parsing goes to stderr.
W0815 20:36:32.872801 139944636380992 deprecation_wrapper.py:119] From /home/ec2-user/darkflow/darkflow/net/build.py:15: The name tf.train.RMSPropOptimizer is deprecated. Please use tf.compat.v1.train.RMSPropOptimizer instead.

W0815 20:36:32.873077 139944636380992 deprecation_wrapper.py:119] From /home/ec2-user/darkflow/darkflow/net/build.py:16: The name tf.train.AdadeltaOptimizer is deprecated. Please use tf.compat.v1.train.AdadeltaOptimizer instead.

W0815 20:36:32.873216 139944636380992 deprecation_wrapper.py:119] From /home/ec2-user/darkflow/darkflow/net/build.py:17: The name tf.train.AdagradOptimizer is deprecated. Please use tf.compat.v1.train.AdagradOptimizer instead.

W0815 20:36:32.873346 139944636380992 deprecation_wrapper.py:119] From /home/ec2-user/darkflow/darkflow/net/build.py:18: The name tf.train.AdagradDAOptimizer is deprecated. Please use tf.compat.v1.train.AdagradDAOptimizer instead.

W0815 20:36:32.873471 139944636380992 deprecation_wrapper.py:119] From /home/ec2-user/darkflow/darkflow/net/build.py:19: The name tf.train.MomentumOptimizer is deprecated. Please use tf.compat.v1.train.MomentumOptimizer instead.

/home/ec2-user/darkflow/darkflow/dark/darknet.py:54: UserWarning: ./cfg/yolov2.cfg not found, use cfg/yolo_custom.cfg instead
  cfg_path, FLAGS.model))
Parsing cfg/yolo_custom.cfg
Loading bin/yolov2.weights ...
Traceback (most recent call last):
  File "soccerball.py", line 15, in <module>
    tfnet = TFNet(options)
  File "/home/ec2-user/darkflow/darkflow/net/build.py", line 58, in __init__
    darknet = Darknet(FLAGS)
  File "/home/ec2-user/darkflow/darkflow/dark/darknet.py", line 27, in __init__
    self.load_weights()
  File "/home/ec2-user/darkflow/darkflow/dark/darknet.py", line 82, in load_weights
    wgts_loader = loader.create_loader(*args)
  File "/home/ec2-user/darkflow/darkflow/utils/loader.py", line 105, in create_loader
    return load_type(path, cfg)
  File "/home/ec2-user/darkflow/darkflow/utils/loader.py", line 19, in __init__
    self.load(*args)
  File "/home/ec2-user/darkflow/darkflow/utils/loader.py", line 77, in load
    walker.offset, walker.size)
AssertionError: expect 202335260 bytes, found 203934260
Ign0reLee commented 4 years ago

Hi, I realize the error message is exactly the same as #3 ,

What file did you use for the cfg file?

I'm not sure, but it might help to try the file I uploaded in #3 earlier,

you can download cfg file in this link https://github.com/deep-diver/Soccer-Ball-Detection-YOLOv2/issues/3#issuecomment-512165189

try it and tell me again if you get the same error

Longbowman commented 4 years ago

Ign0reLee

I use that cfg file with yolo weigths from author's directory and original too. I got same error both times.

Longbowman commented 4 years ago

Ign0reLee btw I compared in diff your uploaded config and original config and they were equal can you reupload your cfg file please?

Thanks

Ign0reLee commented 4 years ago

Sorry for the late response. I rested until yesterday and now I see it.

This is my cfg file, I hope it works well yolo_custom.zip

Ign0reLee commented 4 years ago

And probably the same file.

I don't know the exact cause, but there was nothing wrong with the cfg file in the previous solution. But I heard that I solved it with the file above.

If you get a parameter error, it would be appreciated if you could tell us the exact number of the parameter.

Also check the labels.txt file in the main folder, I remember that it also affected the parameters.

Longbowman commented 4 years ago

Ign0reLee Actually I have trained it using command

flow --model cfg/yolo_custom.cfg --train --dataset "~/Soccer-Ball-Detection-YOLOv2/images" --annotation "~/Soccer-Ball-Detection-YOLOv2/annotations" --gpu 1.0 --batch 4 --epoch 250

if you do not use pretrained weights it trains a lot slower but it works fine