usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the foll

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_33642342/article/details/89316422

usage: yolo_opencv.py [-h] -i IMAGE -c CONFIG -w WEIGHTS -cl CLASSES yolo_opencv.py: error: the following arguments are required: -i/--image, -c/--config, -w/--weights, -cl/--classes


yolo_opencv.py: error: the following arguments are required: -i/–image, -c/–config, -w/–weights, -cl/–classes)

笔者在pycharm中使用
https://github.com/arunponnusamy/object-detection-opencv
的例程yolo_opencv.py时出现了上述问题,原因好像是argparse不适合在windows上使用(希望有大神指出真正的原因),我就将:

ap = argparse.ArgumentParser()
ap.add_argument('-i', '--image', required=True,
                help = 'path to input image')
ap.add_argument('-c', '--config', required=True,
                help = 'path to yolo config file')
ap.add_argument('-w', '--weights', required=True,
                help = 'path to yolo pre-trained weights')
ap.add_argument('-cl', '--classes', required=True,
                help = 'path to text file containing class names')
args = ap.parse_args()

改成了:

class args:
    image = 'E:/object-detection-opencv-master/test_1.jpg'#自行替换文件
    config = 'E:/object-detection-opencv-master/yolov3.cfg'
    weights = 'E:/object-detection-opencv-master/yolov3.weights'
    classes = 'E:/object-detection-opencv-master/yolov3.txt'

其中文件路径自己定,yolov3.weights文件要自己另外下载:
https://pjreddie.com/media/files/yolov3.weights

亲测可用。

此处看出YOLO对相互靠的很近的物体,检测效果不好
在这里插入图片描述

展开阅读全文

没有更多推荐了,返回首页