使用YOLOv3进行目标检测

Github网址
https://github.com/qqwweee/keras-yolo3
安装 (Installation)
1. 克隆存储库
git clone https://github.com/qqwweee/keras-yolo3.git
测试 (Testing)
1. Download YOLOv3 weights from YOLO website(http://pjreddie.com/darknet/yolo/).
放置目录:keras-yolo3/
  wget https://pjreddie.com/media/files/yolov3.weights
2. Convert the Darknet YOLO model to a Keras model.
  python convert.py yolov3.cfg yolov3.weights model_data/yolo.h5

3. Run YOLO detection.
  python yolo_video.py [OPTIONS...] ‐‐image, for image detection mode, OR
python yolo_video.py [video_path] [output_path (optional)]
举例:
  python yolo_video.py ‐‐image
 
python yolo_video.py ‐‐input test_data/library1.mp4 ‐‐output test_data/library_detected.mp4

期间可能遇到的错误:

raise IOError("Couldn't open webcam or video")
OSError: Couldn't open webcam or video

使用YOLOv3进行目标检测_第1张图片

解决办法一:

查看python的OpenCV版本

安装"opencv"
  pip install opencv-python
查看版本
  import cv2
  cv2.__version__

如果还是出现:

raise IOError("Couldn't open webcam or video")
OSError: Couldn't open webcam or video

解决办法二:

hi, i had the same problem, to solve it i had to change the following code part in the yolo_video.py:
def detect_video(yolo, video_path, output_path=""):
import cv2
vid = cv2.VideoCapture(video_path)
if not vid.isOpened():

with this part:
def detect_video(yolo, video_path, output_path=""):
import cv2
import os

VIDEO_NAME = 'VIDEONAME.flv'
# Grab path to current working directory
CWD_PATH = os.getcwd()
PATH_TO_VIDEO = os.path.join(CWD_PATH,VIDEO_NAME)
vid = cv2.VideoCapture(PATH_TO_VIDEO)
if not vid.isOpened():

参考链接:https://github.com/qqwweee/keras-yolo3/issues/149

我是通过解决办法一解决了该问题,但出现了:

AttributeError: 'NoneType' object has no attribute '__array_interface__'

使用YOLOv3进行目标检测_第2张图片

暂时没有找到解决的办法。。。。。

使用YOLOv3进行目标检测_第3张图片

 

 

 

 

你可能感兴趣的:(深度学习)