1. python2 兩個int整數相除,結果仍舊是整數,例如
3/4
0
因爲自己clone的工程中需要用兩個int相除得到float型的數,而自己的conda環境又是python2.7的,所以只能尋求其他解決方案。
解決路徑如下
解決方法:
在代碼的第一行加入如下語句(注意一定是代碼的第一行,不然會報錯)即可:
from __future__ import division
2. 跑yolo v3,識別視頻,可以正常識別但是無法存儲
報錯信息如下:
Traceback (most recent call last):
File "yolo_video.py", line 75, in <module>
detect_video(YOLO(**vars(FLAGS)), FLAGS.input, FLAGS.output)
File "/home/sjt/Tensorflow/keras-yolo3/yolo.py", line 195, in detect_video
image = Image.fromarray(frame)
File "/home/sjt/anaconda2/envs/tf/lib/python2.7/site-packages/PIL/Image.py", line 2483, in fromarray
arr = obj.__array_interface__
AttributeError: 'NoneType' object has no attribute '__array_interface__'
我使用的是keras-yolo-v3,工程地址如下:
在issue中找到了解決方案,鏈接如下:
具體爲:
I had the same two problems. To fix it, I made the following changes to yolo.py:
On line 177, change:
video_FourCC = int(vid.get(cv2.CAP_PROP_FOURCC))
to
video_FourCC = cv2.VideoWriter_fourcc(*"mp4v")
This definitely works with .mp4 and .mov file types, possibly other types too.
Immediately after line 190, add:if not return_value: break
注意,我檢測的視頻格式是.mp4的,所以video_FourCC
處對應的是 *‘mp4v’
,如果是其他格式請自行google/百度