darknet_scripts icon indicating copy to clipboard operation
darknet_scripts copied to clipboard

Error in the gen_anchors.py script using Python 3.5.2 - 3.6.4 on Windows 7x64

Open AlexeyAB opened this issue 6 years ago • 3 comments

Hi @Jumabek

As stated in your manual

  1. Download and install Python for Windows: https://www.python.org/ftp/python/3.5.2/python-3.5.2-amd64.exe
  • If I use Python 2.7.14 then using gen_anchors.py I can get good result:
iter 1: dists = 3720.01823941
iter 2: dists = 1491.80522823
iter 3: dists = 653.572890569
iter 4: dists = 381.526341088
iter 5: dists = 284.587940623
iter 6: dists = 242.033800206
iter 7: dists = 155.795443854
iter 8: dists = 107.012408492
iter 9: dists = 57.3295218927
iter 10: dists = 31.8779793257
iter 11: dists = 10.0989472103
iter 12: dists = 3.2274733626
('Centroids = ', array([[0.0200242 , 0.02964734],
       [0.12974252, 0.12257372]]))
(2L, 2L)
('Anchors = ', array([[0.26031462, 0.38541545],
       [1.68665282, 1.59345842]]))
()
('centroids.shape', (2L, 2L))

  • But if I use Python 3.5.2 or Python 3.6.4 on Windows 7x64 then using gen_anchors.py I get an error:
Traceback (most recent call last):
  File "D:\Darknet2\darknet\build\darknet\x64\gen_anchors.py", line 165, in <mod
ule>
    main(sys.argv)
  File "D:\Darknet2\darknet\build\darknet\x64\gen_anchors.py", line 161, in main

    kmeans(annotation_dims,centroids,eps,anchor_file)
  File "D:\Darknet2\darknet\build\darknet\x64\gen_anchors.py", line 74, in kmean
s
    k,dim = centroids.shape
ValueError: not enough values to unpack (expected 2, got 1)

AlexeyAB avatar Feb 21 '18 15:02 AlexeyAB

Hi Alex

it works with Python 2.7.13 but it has this problem with Python 3.x apart from print parenthesis. I have made an issue before yours about this also.

MyVanitar avatar Feb 21 '18 21:02 MyVanitar

Besides, I have tested the generated anchors and it makes the results worse in both mAP and IoU. I mean the results are better using the original anchors. Why? I don't know. You can test also. keep everything identical just modify anchors.

MyVanitar avatar Feb 21 '18 21:02 MyVanitar

@VanitarNordic @AlexeyAB thanks for the catch. I fixed accordingly.

@VanitarNordic , I too noticed that anchors do not give improvement. Unfortunately I wasnt able to dig deeper than that.

Jumabek avatar Feb 25 '18 14:02 Jumabek