在运行YOLO以测试自定义对象cfg文件路径错误时,路径是正确的,即使显示此错误

时间:2018-07-27 00:46:55

标签: python yolo darkflow

此代码用于运行我训练有素的砝码,该文件夹ckpt包含1050步训练数据,并且该文件位于darkflow主文件夹中cfg文件夹之外。

import cv2
from darkflow.net.build import TFNet
import numpy as np
import time

options = { 'model': 'cfg/tiny-yolo-voc-1c.cfg', 'load': 1050, 'threshold': 0.2, 'gpu': 1.0 }

在下面的原子编辑器中运行此代码后显示错误
Parsing cfg//tiny-yolo-voc-1c.cfg
Traceback (most recent call last):
File "C:\Users\amard\Desktop\Hotel\darkflow\test.py", line 13, in <module> tfnet = TFNet(options)
File "C:\Users\amard\Desktop\Hotel\darkflow\darkflow\net\build.py", line 58, in __init__
darknet = Darknet(FLAGS) File "C:\Users\amard\Desktop\Hotel\darkflow\darkflow\dark\darknet.py", line 17, in __init__
src_parsed = self.parse_cfg(self.src_cfg, FLAGS)
File "C:\Users\amard\Desktop\Hotel\darkflow\darkflow\dark\darknet.py", line 68, in parse_cfg
for i, info in enumerate(cfg_layers):
File "C:\Users\amard\Desktop\Hotel\darkflow\darkflow\utils\process.py", line 66, in cfg_yielder
layers, meta = parser(model); yield meta; File "C:\Users\amard\Desktop\Hotel\darkflow\darkflow\utils\process.py", line 17, in parser
with open(model, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: 'cfg//tiny-yolo-voc-1c.cfg'
[Finished in 4.298s]

1 个答案:

答案 0 :(得分:0)

通常我也习惯于得到与此错误类似的东西

我的第一个错误是没有在保存这些文件夹的目录中打开Jupyter笔记本 因此,尝试从该目录打开笔记本

(在Windows中,只需在shift +右键单击位置栏上输入cmd)

(在MacOS中,首先启用一些设置,然后右键单击该文件夹)

后来我使用了此选项

options={
    'model':'cfg/yolo.cfg',
    'load':'bin/yolov2.weights',
    'threshold':0.3,
    'gpu':1.0
}

tfNet = TFNet(选项)

一切都会按预期进行

希望这会对您有所帮助