wizyoung / YOLOv3_TensorFlow

Complete YOLO v3 TensorFlow implementation. Support training on your own dataset.
MIT License
1.55k stars 579 forks source link

ValueError: Sample larger than population or is negative #222

Closed pgirikishore closed 4 years ago

pgirikishore commented 4 years ago

2020-03-22 10:17:23.108068: W tensorflow/core/framework/op_kernel.cc:1639] Invalid argument: ValueError: Sample larger than population or is negative Traceback (most recent call last):

File "C:\Users\girik\Anaconda3\envs\prac\lib\site-packages\tensorflow_core\python\ops\script_ops.py", line 235, in call ret = func(*args)

File "C:\Users\girik\Desktop\Phase2\YOLOv3_TensorFlow-master\utils\data_utils.py", line 208, in get_batch_data mix_lines.append([line, random.sample(batch_line[:idx] + batch_line[idx+1:], 1)[0]])

File "C:\Users\girik\Anaconda3\envs\prac\lib\random.py", line 321, in sample raise ValueError("Sample larger than population or is negative")

ValueError: Sample larger than population or is negative

How to resolve this error?

aaron38 commented 4 years ago

This happens if your current batch is of size 1 (this is not only the case if you set batch_size to 1, but can also happen with the last batch of an epoch). I fixed this by skipping line 208 (EDIT: in data_utils.py) if len(batch_line) == 1

pgirikishore commented 4 years ago

Thanks a lot for you help!! Working now!