AssertionError while generating anchors
JonasBoukamp opened this issue · 4 comments
Hi,
I´m training a volov3 using a custom dataset and ran into the error where an assertion is triggered. I´m using the same code with another dataset without any problems so I asume, I made an error creating this dataset. Does anybody know what type of mistakes in a dataset could trigger the shown assertion. Until now I couldn´t find any differences in the annotation files of the two datasets.
All annotation files are generated by a self written script. The following example shows one of the files:
18 0.21185185185185185 0.19555555555555557 0.08 0.12
19 0.5488888888888889 0.5944444444444444 0.07111111111111111 0.10666666666666667
16 0.7037037037037037 0.14 0.08 0.12
4 0.7844444444444445 0.37 0.044444444444444446 0.06666666666666667
26 0.29185185185185186 0.22 0.07111111111111111 0.10666666666666667
26 0.09037037037037038 0.88 0.08888888888888889 0.13333333333333333
16 0.35555555555555557 0.7755555555555556 0.07111111111111111 0.10666666666666667
Traceback (most recent call last):
File "C:\Users\jonas\OneDrive\Hochschule\Master\Master Arbeit\Python\testFramework\yolo.py", line 86, in
y.train(dataDirectory="syntheticDataset/temp/out", baseModelPath="syntheticDataset/yolov3.pt")
File "C:\Users\jonas\OneDrive\Hochschule\Master\Master Arbeit\Python\testFramework\yolo.py", line 80, in train
trainer.trainModel()
File "C:\Users\jonas\AppData\Roaming\Python\Python311\site-packages\imageai\Detection\Custom_init_.py", line 229, in trainModel
self.__set_training_param(self._epochs, accumulate)
File "C:\Users\jonas\AppData\Roaming\Python\Python311\site-packages\imageai\Detection\Custom_init.py", line 62, in __set_training_param
self.__anchors = generate_anchors(
^^^^^^^^^^^^^^^^^
File "C:\Users\jonas\AppData\Roaming\Python\Python311\site-packages\imageai\Detection\Custom\yolo\custom_anchors.py", line 59, in generate_anchors
assert len(k) == n, f'ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}'
^^^^^^^^^^^
AssertionError: ERROR: scipy.cluster.vq.kmeans requested 9 points but returned only 7
A similar problem
A small random change in the width and height fields helped me. Previously, I set the constant numbers as field data, and this error occurred.
i have same problem. how to fix it
i have same problem. how to fix it
As I empirically understood, such an error is related to the uniformity of input parameters, whether width or height, that interfere with successful learning. On my part, I personally generated a constant height and width, which is why I always got this error. The solution for me was a small randomization of width and height, literally by ~0.01 values.
I do not exclude that there may be other reasons for this error, but so far I have had only one such case.