Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError in yolov5_augment.py #5

Open
huihui308 opened this issue Sep 25, 2023 · 0 comments
Open

AttributeError in yolov5_augment.py #5

huihui308 opened this issue Sep 25, 2023 · 0 comments

Comments

@huihui308
Copy link

I had a AttributeError when I trained rtcdet_p on my own dataset.

Traceback (most recent call last):
  File "train.py", line 189, in <module>
    train()
  File "train.py", line 180, in train
    trainer.train(model)
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/engine.py", line 857, in train
    self.train_one_epoch(model)
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/engine.py", line 937, in train_one_epoch
    for iter_i, (images, targets) in enumerate(self.train_loader):
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 633, in __next__
    data = self._next_data()
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1345, in _next_data
    return self._process_data(data)
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1371, in _process_data
    data.reraise()
  File "/home/david/.local/lib/python3.8/site-packages/torch/_utils.py", line 644, in reraise
    raise exception
AttributeError: Caught AttributeError in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/david/.local/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/dataset/plate.py", line 86, in __getitem__
    return self.pull_item(index)
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/dataset/plate.py", line 187, in pull_item
    image, target = self.load_mosaic(index)
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/dataset/plate.py", line 160, in load_mosaic
    image, target = yolov5_mosaic_augment(
  File "/home/david/code/paper/PyTorch_YOLO_Tutorial/dataset/data_augment/yolov5_augment.py", line 143, in yolov5_mosaic_augment
    bboxes_i_ = bboxes_i.copy()
AttributeError: 'Tensor' object has no attribute 'copy'

bboxes_i's type sometime is tensor, not <class 'numpy.ndarray'>.
So, I add a code in order to judge bboxes_i's type, as following.

        # labels
        if torch.is_tensor(bboxes_i):
            bboxes_i = bboxes_i.numpy()
        bboxes_i_ = bboxes_i.copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant