提示类似以下的信息
Downloading yolov3-tiny.cfg from https://github.com/pjreddie/darknet/raw/master/cfg/yolov3-tiny.cfg
Could not establish connection. Download failed
D:\Program Files\Python39\Lib\site-packages\cvlib\object_detection.py
中需要在线下载一些文件,但是国内下载会失败
yolov3-tiny.cfg
yolov3-tiny.weights
yolov3.cfg
yolov3.txt
yolov3.weights
yolov4-tiny.cfg
yolov4-tiny.weights
yolov4.cfg
yolov4.weights
提前把这些文件下载下来,并将代码中路径更改为文件存放的路径。
免费下载地址点击此处
下载后解压到代码文件所在位置,并修改
D:\Program Files\Python39\Lib\site-packages\cvlib\object_detection.py
中两处位置
def populate_class_labels():
# 命名不一致Bug
# class_file_name = 'yolov3_classes.txt'
class_file_name = 'yolov3.txt'
# 改为调用本地文件
# class_file_abs_path = dest_dir + os.path.sep + class_file_name
class_file_abs_path = "YolovConfig/" + class_file_name
# 改为调用本地文件
# config_file_abs_path = dest_dir + os.path.sep + config_file_name
# weights_file_abs_path = dest_dir + os.path.sep + weights_file_name
config_file_abs_path = "YolovConfig/" + config_file_name
weights_file_abs_path = "YolovConfig/" + weights_file_name
if not os.path.exists(config_file_abs_path):
download_file(url=cfg_url, file_name=config_file_name, dest_dir=dest_dir)
if not os.path.exists(weights_file_abs_path):
download_file(url=weights_url, file_name=weights_file_name, dest_dir=dest_dir)
也可根据代码文件中的下载地址自行进行下载。