Как исправить объект 'str' не имеет атрибута 'seek' ошибка в pytorch? - PullRequest
0 голосов
/ 10 октября 2019

Я пытаюсь реализовать этот код https://github.com/eriklindernoren/PyTorch-YOLOv3 и обучить его своему собственному набору данных, но я всегда сталкиваюсь с приведенной ниже ошибкой при попытке ее проверить

---- Evaluating Model ----
Detecting objects:   0%|                                                                                                                                                              | 0/1 [00:00<?, ?it/s]Traceback (most recent call last):
  File "train.py", line 160, in <module>
    batch_size=8,
  File "/home/harshvardhan/PyTorch-YOLOv3/test.py", line 36, in evaluate
    for batch_size, (imgs, targets) in enumerate(tqdm.tqdm(dataloader, desc="Detecting objects")):
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/tqdm/std.py", line 1081, in __iter__
    for obj in iterable:
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 819, in __next__
    return self._process_data(data)
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 846, in _process_data
    data.reraise()
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/_utils.py", line 369, in reraise
    raise self.exc_type(msg)
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/PIL/Image.py", line 2770, in open
    fp.seek(0)
AttributeError: 'str' object has no attribute 'seek'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/harshvardhan/PyTorch-YOLOv3/utils/datasets.py", line 86, in __getitem__
    img = transforms.ToTensor()(Image.open(img_path).convert('RGB'))
  File "/home/harshvardhan/.conda/envs/pytorch/lib/python3.6/site-packages/PIL/Image.py", line 2772, in open
    fp = io.BytesIO(fp.read())
AttributeError: 'str' object has no attribute 'read'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...