0

yolov3.cfg我正在尝试通过yolov3.weights使用darkflow. 但是,当我尝试运行时tfnet = TFNet(history),它会引发“未定义退出”的错误。

我已darkflow按以下步骤安装:

在 Anaconda 提示中:

git clone https://github.com/thtrieu/darkflow.git
cd darkflow
python3 setup.py build_ext –inplace
pip install

然后:

%matplotlib inline

import matplotlib.pyplot as plt

import numpy as np


import cv2

from darkflow.net.build import TFNet

history = {"model": "C:/Users/Business Intelli/Desktop/Object-Detection/Dataset/yolov3.cfg",

           "load": "C:/Users/Business Intelli/Desktop/Object-Detection/Dataset/yolov3.weights",

           "batch": 8,

           "epoch": 50,

           "gpu": 1.0,

           "train": True,

           "annotation": "C:/Users/Business Intelli/Desktop/Object-Detection/Dataser/Stumps",

           "dataset": "C:/Users/Business Intelli/Desktop/Object-Detection/Dataser/Stumps"}


tfnet = TFNet(history)

Parsing C:/Users/Business Intelli/Desktop/Object-Detection/Dataset/yolov3.cfg
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-10-6f6b945047c5> in <module>
----> 1 tfnet = TFNet(history)

~\Anaconda3\lib\site-packages\darkflow\net\build.py in __init__(self, FLAGS, darknet)

     56 
     57                 if darknet is None:

---> 58                         darknet = Darknet(FLAGS)

     59                         self.ntrain = len(darknet.layers)

     60 

~\Anaconda3\lib\site-packages\darkflow\dark\darknet.py in __init__(self, FLAGS)

     15 

     16         print('Parsing {}'.format(self.src_cfg))

---> 17         src_parsed = self.parse_cfg(self.src_cfg, FLAGS)

     18         self.src_meta, self.src_layers = src_parsed

     19 


~\Anaconda3\lib\site-packages\darkflow\dark\darknet.py in parse_cfg(self, model, FLAGS)

     66         cfg_layers = cfg_yielder(*args)

     67         meta = dict(); layers = list()

---> 68         for i, info in enumerate(cfg_layers):

     69             if i == 0: meta = info; continue

     70             else: new = create_darkop(*info)


~\Anaconda3\lib\site-packages\darkflow\utils\process.py in cfg_yielder(model, binary)

    314                 #-----------------------------------------------------

    315                 else:

--> 316                         exit('Layer {} not 
implemented'.format(d['type']))

    317 

    318                 d['_size'] = list([h, w, c, l, flat])


NameError: name 'exit' is not defined
4

1 回答 1

1

所以我遇到了同样的问题,问题出在 darkflow --> utils 文件夹中的 process.py 文件上。

显然 exit() 方法不是内置的,所以你必须在process.py中添加这一行

从系统导入退出

注意:如果您的代码达到这一点,则意味着模型无法读取图层。我为 yolov3 下载的权重文件给了我同样的麻烦,我找不到在暗流中工作的 yolov3 具有适当权重文件的链接。所以我不得不坚持使用 yolo.cfg 和 yolo.weights 。

于 2019-10-12T03:37:29.803 回答