Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.46k stars 1.49k forks source link

YOLOV4 training error with only 1 class #509

Open blackHorz opened 2 years ago

blackHorz commented 2 years ago

My dataset consist of only 1 class. I encounter following error, File "/home/fftai/working/pytorch/pytorch-YOLOv4/dataset.py", line 78, in fill_truth_detection min_w_h = np.array([bboxes[:, 2] - bboxes[:, 0], bboxes[:, 3] - bboxes[:, 1]]).min() File "/home/fftai/anaconda3/lib/python3.8/site-packages/numpy/core/_methods.py", line 43, in _amin return umr_minimum(a, axis, None, out, keepdims, initial, where) ValueError: zero-size array to reduction operation minimum which has no identity

This comes by dataset class at this point, min_w_h = np.array([bboxes[:, 2] - bboxes[:, 0], bboxes[:, 3] - bboxes[:, 1]]).min()

I further debugged the code and found this line which is not clear to me, bboxes = bboxes[np.where((bboxes[:, 4] < classes) & (bboxes[:, 4] >= 0))[0]]

this lines makes bboxes = []

vacutice commented 2 years ago

please refer to issue #217