강의

멘토링

커뮤니티

Inflearn Community Q&A

hewun74274968's profile image
hewun74274968

asked

TensorFlow Object Detection API Guide Part 1 - Detecting Objects with 10 Lines of Code

이미지 사이즈 에러 발생

Written on

·

520

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을 실행하고 있는데 사이즈가 달라서 오류가 나는거 같습니다.
어떻게 해결해야 하나요?
tensorflow딥러닝cnn

Answer 2

0

hewun7427님의 프로필 이미지
hewun7427
Questioner

해결됐습니다.

감사합니다.

0

AISchool님의 프로필 이미지
AISchool
Instructor

안녕하세요~. 반갑습니다.

이미지가 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")

감사합니다.

hewun74274968's profile image
hewun74274968

asked

Ask a question