bubbliiiing / faster-rcnn-pytorch

这是一个faster-rcnn的pytorch实现的库,可以利用voc数据集格式的数据进行训练。
MIT License
1.6k stars 356 forks source link

关于train时的报错 #177

Open Notyour-Kai opened 1 year ago

Notyour-Kai commented 1 year ago

博主你好!我在使用VOC2007的数据集时,使用你的代码可以正常进行train.py的运行,我换到我的数据集时,首先运行了voc_annotation,py,这里可以正常运行,且同时会产生正确的2007train和2007val,丹是当我运行train.py时,他就会报错,大致错误为

Traceback (most recent call last): File "D:\PythonCode\Faster_RCNN\train.py", line 437, in fit_one_epoch(model, train_util, loss_history, eval_callback, optimizer, epoch, epoch_step, epoch_step_val, gen, gen_val, UnFreeze_Epoch, Cuda, fp16, scaler, save_period, save_dir) File "D:\PythonCode\Faster_RCNN\utils\utils_fit.py", line 19, in fit_one_epoch for iteration, batch in enumerate(gen): File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data\dataloader.py", line 521, in next data = self._next_data() File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data\dataloader.py", line 1203, in _next_data return self._process_data(data) File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data\dataloader.py", line 1229, in _process_data data.reraise() File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch_utils.py", line 434, in reraise raise exception FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0. Original Traceback (most recent call last): File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data_utils\worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\Anaconda\envs\PyTorch\lib\site-packages\torch\utils\data_utils\fetch.py", line 49, in data = [self.dataset[idx] for idx in possibly_batched_index] File "D:\PythonCode\Faster_RCNN\utils\dataloader.py", line 26, in getitem image, y = self.get_random_data(self.annotation_lines[index], self.input_shape[0:2], random = self.train) File "D:\PythonCode\Faster_RCNN\utils\dataloader.py", line 44, in get_random_data image = Image.open(line[0]) File "D:\Anaconda\envs\PyTorch\lib\site-packages\PIL\Image.py", line 3131, in open fp = builtins.open(filename, "rb") FileNotFoundError: [Errno 2] No such file or directory: 'D:\PythonCode\Faster_RCNN\VOCdevkit/VOC2007/JPEGImages/000287.jpg'

这似乎是一个未找到我的数据集中图片的错误,但是我确定这个位置有我的图片,而且后缀也为jpg并且代码中的路径全部改为了绝对路径,不过我的数据集只有单一的一类识别目标,请问这个错误的产生有哪些可能呢?谢谢!