Keras-yolo3: AttributeError: 'NoneType' object has no attribute '__array_interface__' when running yolo_video.py

Created on 18 Jul 2018  Â·  2Comments  Â·  Source: qqwweee/keras-yolo3

When I run yolo_video.py, the following error occurs:

Traceback (most recent call last):
  File "yolo_video.py", line 14, in <module>
    detect_video(YOLO(), video_path, output_path)
  File "/home/wyf/PycharmProjects/keras-yolo3/yolo.py", line 179, in detect_video
    image = Image.fromarray(frame)
  File "/home/wyf/anaconda2/envs/tf14py3/lib/python3.5/site-packages/PIL/Image.py", line 2421, in fromarray
    arr = obj.__array_interface__
AttributeError: 'NoneType' object has no attribute '__array_interface__'

I think the problem occurs because the following code returns none. I wonder it's concerned about opencv. Here my environment is ubuntu16.04, tensorflow1.4 under Anaconda, python3.5, and opencv-python (3.4.1.15). I don't figure out how to solve it, can anyone help?
return_value, frame = vid.read()

Most helpful comment

first the problem could arise due to the codec: (in yolo.py)
change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')

another change can be made after reading the image in line 182: (in yolo.py)
return_value, frame = vid.read()
if not return_value:
break

this solves the issue with getting an empty frame and trying to save it.

All 2 comments

first the problem could arise due to the codec: (in yolo.py)
change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')

another change can be made after reading the image in line 182: (in yolo.py)
return_value, frame = vid.read()
if not return_value:
break

this solves the issue with getting an empty frame and trying to save it.

change video_FourCC = cv2.VideoWriter_fourcc(*'XVID')
*'xxxx' is decided by your video format, for me, I use *'FLV1' for .flv video

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ISSstone picture ISSstone  Â·  5Comments

OverFlow7 picture OverFlow7  Â·  4Comments

wingNine picture wingNine  Â·  5Comments

nseidl picture nseidl  Â·  3Comments

karanmartian picture karanmartian  Â·  4Comments