pai-plznw4me / stamp_sign_segmentor

stamp sign 객체를 segmentation 하는 모델 입니다.
0 stars 0 forks source link

cv2.resize 시 사용시 에러 문제 #2

Open pai-plznw4me opened 3 years ago

pai-plznw4me commented 3 years ago
# dataprovider.py
            stamp_coords[:, [0, 2]] += offset_xs
            stamp_coords[:, [1, 3]] += offset_ys

            stamp_coords = np.array(stamp_coords)
            cropped_images = crop_images(docu, stamp_coords)
            cropped_masks = crop_images(mask, stamp_coords)

            for image, mask in zip(cropped_images, cropped_masks):
                image = cv2.resize(image, dsize=self.stamp_size)

                mask = cv2.resize(mask, dsize=(112, 112)) <- 에러 발생 줄
                batch_xs.append(image)
                batch_ys.append(mask)

        return batch_xs, batch_ys

위와 같은 코드에서 아래와 같은 에러가 발생,

Traceback (most recent call last):
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/pydevd.py", line 1434, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/Users/publicai/PycharmProjects/stamp_sign_segmentor/src/dataprovider.py", line 202, in <module>
    plot_images(batch_ys[0])
  File "/Users/publicai/PycharmProjects/stamp_sign_segmentor/src/dataprovider.py", line 190, in __getitem__
    batch_xs.append(image)
cv2.error: OpenCV(4.5.1) /private/var/folders/nz/vv4_9tw56nv9k3tkvyszvwg80000gn/T/pip-req-build-oe0iat4a/opencv/modules/imgproc/src/resize.cpp:3929: error: (-215:Assertion failed) func != 0 in function 'resize'
pai-plznw4me commented 3 years ago

원인 : cv2.resize 는 입력 백터의 dtype 이 항상 uint8, or float 으로 지정되어야 함