jbwang1997 / BboxToolkit

BboxToolkit is a tiny library of special bounding boxes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DecompressionBombError when using img_split.py

vpeopleonatank opened this issue · comments

When use img_split.py with my own dataset, I get error as below. After add Image.MAX_IMAGE_PIXELS = None to DOTAio.py, the error has gone. Do you think is there any cons when adding this line?

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "BboxToolkit/tools/img_split.py", line 316, in <module>
    main()
  File "BboxToolkit/tools/img_split.py", line 268, in main
    nproc=args.nproc)
  File "/obbdetection/BboxToolkit/BboxToolkit/datasets/DOTAio.py", line 34, in load_dota
    contents = pool.map(_load_func, os.listdir(img_dir))
  File "/opt/conda/lib/python3.7/multiprocessing/pool.py", line 268, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/opt/conda/lib/python3.7/multiprocessing/pool.py", line 657, in get
    raise self._value
PIL.Image.DecompressionBombError: Image size (625847040 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.

The Pillow can not load huge image information. Instead, I use a new function, named imsize to replace it. You can update BboxToolkit and test.

I will try it, I 'm using old commit, I get another opencv error when using img_split.py

Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/multiprocessing/pool.py", line 121, in worker
    result = (True, func(*args, **kwds))
  File "/opt/conda/lib/python3.7/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "BboxToolkit/tools/img_split.py", line 207, in single_split
    padding_value, filter_empty, save_dir, img_ext)
  File "BboxToolkit/tools/img_split.py", line 157, in crop_and_save_img
    img = cv2.imread(osp.join(img_dir, info['filename']))
cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-3129w7z7/opencv/modules/imgcodecs/src/loadsave.cpp:77: error: (-215:Assertion failed) pixels <= CV_IO_MAX_IMAGE_PIXELS in function 'validateInputImageSize'

It works. Thank you :D