bubbliiiing / yolov8-pytorch

这是一个yolov8-pytorch的仓库,可以用于训练自己的数据集。
GNU General Public License v3.0
678 stars 80 forks source link

invalid literal for int() with base 10: '300.6600000000001' #72

Open purples123 opened 1 week ago

purples123 commented 1 week ago

你好,我咋训练时出现以下报错,但是不知道是哪里的值应该从int改为float,请问这种情况应该怎么解决?

发生异常: ValueError
Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/zwf/.conda/envs/sod/lib/python3.12/site-packages/torch/utils/data/_utils/worker.py", line 351, in _worker_loop
    data = fetcher.fetch(index)  # type: ignore[possibly-undefined]
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/zwf/.conda/envs/sod/lib/python3.12/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
            ~~~~~~~~~~~~^^^^^
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/utils/dataloader.py", line 53, in __getitem__
    image, box      = self.get_random_data(self.annotation_lines[index], self.input_shape, random = self.train)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/utils/dataloader.py", line 106, in get_random_data
    box     = np.array([np.array(list(map(int,box.split(',')))) for box in line[1:]])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '300.6600000000001'
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/utils/utils_fit.py", line 16, in fit_one_epoch
    for iteration, batch in enumerate(gen):
                            ^^^^^^^^^^^^^^
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/train.py", line 569, in <module>
    fit_one_epoch(model_train, model, ema, yolo_loss, loss_history, eval_callback, optimizer, epoch, epoch_step, epoch_step_val, gen, gen_val, UnFreeze_Epoch, Cuda, fp16, scaler, save_period, save_dir, local_rank)
ValueError: Caught ValueError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/zwf/.conda/envs/sod/lib/python3.12/site-packages/torch/utils/data/_utils/worker.py", line 351, in _worker_loop
    data = fetcher.fetch(index)  # type: ignore[possibly-undefined]
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/zwf/.conda/envs/sod/lib/python3.12/site-packages/torch/utils/data/_utils/fetch.py", line 52, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
            ~~~~~~~~~~~~^^^^^
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/utils/dataloader.py", line 53, in __getitem__
    image, box      = self.get_random_data(self.annotation_lines[index], self.input_shape, random = self.train)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/zwf/Downloads/small_object_detection/yolov8-main_densenet/utils/dataloader.py", line 106, in get_random_data
    box     = np.array([np.array(list(map(int,box.split(',')))) for box in line[1:]])
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '300.6600000000001'