-
카테고리
-
세부 분야
컴퓨터 비전
-
해결 여부
미해결
이미지 사이즈 에러 발생
21.07.13 01:48 작성 조회수 366
0
ValueError Traceback (most recent call last)
<ipython-input-36-bb063d6d7f72> in <module>() 1 image_dir = 'images_person/' 2 image_path = os.path.join(image_dir, 'person_picture:001.png') ----> 3 image_np = load_image_into_numpy_array(image_path) 4 5 # 이미지에 대한 예측을 수행합니다.
<ipython-input-35-aa041491b700> in load_image_into_numpy_array(path) 17 18 return np.array(image.getdata()).reshape( ---> 19 (im_height, im_width, 3)).astype(np.uint8)
ValueError: cannot reshape array of size 1344384 into shape (432,778,3)
제가 새로운 이미지파일로 object detection을 실행하고 있는데 사이즈가 달라서 오류가 나는거 같습니다.
어떻게 해결해야 하나요?
답변을 작성해보세요.
0
0
AISchool
지식공유자2021.07.14
안녕하세요~. 반갑습니다.
이미지가 RGB가 아니라 grayscale로 처리되어서 발생한 에러가 아닐까 의심됩니다.
load_image_into_numpy_array 함수안에 있는 아래 2줄을 아래와 같이 변경 해서 진행해보세요.
img_data = tf.io.gfile.GFile(path, 'rb').read()
image = Image.open(BytesIO(img_data))
->
image = Image.open(path).convert("RGB")
감사합니다.
답변 2