Tianxiaomo / pytorch-YOLOv4

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

Image or batch without any objects #259

Open amanjas opened 3 years ago

amanjas commented 3 years ago

Hello. Thank you for your work and share it! I try to train my own data that contains images without any objects. It appear the next error:

Epoch 1/100: 0%| | 0/38484 [00:00<?, ?img/s] Traceback (most recent call last): File "train.py", line 635, in device=device, ) File "train.py", line 376, in train for i, batch in enumerate(train_loader): File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 345, in next data = self._next_data() File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 856, in _next_data return self._process_data(data) File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 881, in _process_data data.reraise() File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/_utils.py", line 394, in reraise raise self.exc_type(msg) cv2.error: Caught error in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop data = fetcher.fetch(index) File "/home/usuaris/imatge/amanjabacas/virtenvs/fish/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/usuaris/imatge/amanjabacas/virtenvs/fish/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/usuaris/imatge/amanjabacas/workspace/pytorch-YOLOv4/dataset.py", line 297, in getitem img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) cv2.error: OpenCV(4.2.0) /io/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

I think this error is due the images without any objects. Is it possible make it work with images without any object? (similar issue in Pythorch-YOLOv3)

Thanks a lot.

aleenakvk commented 3 years ago

I have also had the same problem. I have resolved it by checking the path. Even though the path that we are given is right, check the path we have provided in the coco_annotations.py. First, print the path used in dataset.py. In my case, it was the problem of the path I have used in coco_annotation.py.

aleenakvk commented 3 years ago

Thank you

On Wed, 17 Mar 2021 at 11:17 AM, Florian Vahl @.***> wrote:

This part of the code has been updated. I, therefore, close this issue now. Feel free to reopen for further discussion.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Tianxiaomo/pytorch-YOLOv4/issues/259#issuecomment-800964254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARIHLCRU5RDNSGI26YSVXBDTEB6TTANCNFSM4QS2PT6Q .

-- Thanks and regards, Aleena K Varghese

ESIGELEC

Technopôle du Madrillet

Avenue Galilée - BP 10024

76801 Saint Etienne du Rouvray Cedex

FRANCE

*: @.***

@: [www.esigelec.fr]www.esigelec.fr

zrion commented 2 years ago

@amanjas I'm having the exact problem. With images where there is no object the code returns the same error (checked both path, image, and label). I'm very confused why imread could return None when there's no object, Did you manage to solve this problem? It would be good to know, thanks.