Tianxiaomo / pytorch-YOLOv4

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

如何設定Train.txt中的bounding box #304

Open cihao opened 4 years ago

cihao commented 4 years ago

依照code說明的train.txt設定格式

train.txt

image_path1 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ... ... 所以目前在設定自已影像集的train.txt檔案內容如下: C:/Users/USER/Desktop/pytorch-YOLOv4-master/dataset/trainImage/1.jpg 599,614,152,166,2 C:/Users/USER/Desktop/pytorch-YOLOv4-master/dataset/trainImage/2.jpg 99,108,99,107,1

但執行train.py會出現如下錯誤,需設定Bounding box在0~1,那位高手可以幫忙說明如何正確設定bounding box RuntimeError: Assertion `x >= 0. && x <= 1.' failed. input value should be between 0~1, but got -nan(ind) at C:\w\1\s\windows\pytorch\aten\src\THNN/generic/BCECriterion.c:53

MrYu001 commented 3 years ago

The format is Xmin, Ymin, Xmax, Ymax, the_class_type

sharoseali commented 3 years ago

HI I want to train my own custom data. I make the train.txt file in thıs way /home/sharoze/Downloads/darknet-master/VisDrone2018-DET-train/VisDrone2018-DET-train/data/9999964_00000_d_0000032.jpg 1104.9997,751.9995,1242.9991,940.9994999999999,5 1049.0004,638.0004749999999,1141.0,752.0000249999999,5 1014.0004,525.9996,1084.9999999999998,609.0,5 942.9994,387.0006,983.9997999999999,430.0002,5 1125.9997,291.00014999999996,1186.9991,317.99985,5 1202.0001,299.00010000000003,1269.9995,325.99980000000005,5 204.00030000000004,618.999675,325.0009,726.999525,5 314.0004,539.999775,404.00079999999997,615.999825,5 387.99949999999995,477.99937500000004,460.9997,542.999625,5 461.00039999999996,420.99960000000004,516.0008,467.9997,5 512.9999,377.00039999999996,559.9993000000001,419.0004,5 like in this format image_path '' x1,y1,x2,y2,id '' x1,y1,x2,y2,id x1,y1,x2,y2,id python code: fw.write('image_name ' + '{},{},{},{},{} '.format(float(x1), float(y1), float(x2), float(y2), int(label[0])))

But after data loading, I am getting this error in bounding boxes

Traceback (most recent call last): File "train.py", line 623, in <module> train(model=model, File "train.py", line 370, in train for i, batch in enumerate(train_loader): File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 345, in __next__ data = self._next_data() File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data return self._process_data(data) File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data data.reraise() File "/home/sharoze/.local/lib/python3.8/site-packages/torch/_utils.py", line 394, in reraise raise self.exc_type(msg) IndexError: Caught IndexError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/sharoze/.local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/sharoze/Downloads/pytorch-YOLOv4-master/dataset.py", line 368, in __getitem__ truth, min_w_h = fill_truth_detection(bboxes, self.cfg.boxes, self.cfg.classes, flip, pleft, ptop, swidth, File "/home/sharoze/Downloads/pytorch-YOLOv4-master/dataset.py", line 54, in fill_truth_detection bboxes[:, 0] -= dx IndexError: too many indices for array Need anyone,s help, please !!!