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

YOLOv3 - OpenCV error in function 'warpAffine': Argument 'borderMode' is required to be an integer #176

Open
calebee310 opened this issue Apr 15, 2024 · 0 comments

Comments

@calebee310
Copy link

I run the "train.py" and found the following error.

$ py train.py

  0%|                                                                        | 0/518 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/calebee/DL/Machine-Learning-Collection/ML/Pytorch/object_detection/YOLOv3/train.py", line 114, in <module>
    main()
  File "/home/calebee/DL/Machine-Learning-Collection/ML/Pytorch/object_detection/YOLOv3/train.py", line 83, in main
    train_fn(train_loader, model, optimizer, loss_fn, scaler, scaled_anchors)
  File "/home/calebee/DL/Machine-Learning-Collection/ML/Pytorch/object_detection/YOLOv3/train.py", line 31, in train_fn
    for batch_idx, (x, y) in enumerate(loop):
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/tqdm/std.py", line 1178, in __iter__
    for obj in iterable:
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 631, in __next__
    data = self._next_data()
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1346, in _next_data
    return self._process_data(data)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/dataloader.py", line 1372, in _process_data
    data.reraise()
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/_utils.py", line 722, in reraise
    raise exception
cv2.error: Caught error in DataLoader worker process 0.
Original Traceback (most recent call last):
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/_utils/worker.py", line 308, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/torch/utils/data/_utils/fetch.py", line 51, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "/home/calebee/DL/Machine-Learning-Collection/ML/Pytorch/object_detection/YOLOv3/dataset.py", line 56, in __getitem__
    augmentations = self.transform(image=image, bboxes=bboxes)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/core/composition.py", line 210, in __call__
    data = t(**data)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/core/composition.py", line 326, in __call__
    data = t(force_apply=True, **data)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/core/transforms_interface.py", line 118, in __call__
    return self.apply_with_params(params, **kwargs)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/core/transforms_interface.py", line 131, in apply_with_params
    res[key] = target_function(arg, **dict(params, **target_dependencies))
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/augmentations/geometric/transforms.py", line 657, in apply
    return F.warp_affine(
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/augmentations/utils.py", line 122, in wrapped_function
    result = func(img, *args, **kwargs)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/augmentations/geometric/functional.py", line 560, in warp_affine
    tmp = warp_fn(image)
  File "/home/calebee/miniconda3/lib/python3.10/site-packages/albumentations/augmentations/utils.py", line 208, in __process_fn
    img = process_fn(img, **kwargs)
cv2.error: OpenCV(4.9.0) :-1: error: (-5:Bad argument) in function 'warpAffine'
> Overload resolution failed:
>  - Argument 'borderMode' is required to be an integer
>  - Argument 'borderMode' is required to be an integer

It seems that "test transofrms = A.Compose(" in Line 68 of "config.py" has a problem, but I don't know how to solve the problem.

test_transforms = A.Compose(
    [
        A.LongestMaxSize(max_size=IMAGE_SIZE),
        A.PadIfNeeded(
            min_height=IMAGE_SIZE, min_width=IMAGE_SIZE, border_mode=cv2.BORDER_CONSTANT
        ),
        A.Normalize(mean=[0, 0, 0], std=[1, 1, 1], max_pixel_value=255,),
        ToTensorV2(),
    ],
    bbox_params=A.BboxParams(format="yolo", min_visibility=0.4, label_fields=[]),
)

Could you help me to solve the error?
Thank you in advance.

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