简体   繁体   English

NameError:未定义名称“退出” / tfnet / darkflow /自定义数据集对象检测

[英]NameError: name 'exit' is not defined/tfnet/darkflow/custom dataset object detection

I'm trying to train my custom dataset by creating yolov3.cfg file and yolov3.weights file with labelled annotations and images using darkflow . 我正在尝试通过使用darkflow创建带有标签注释和图像的yolov3.cfg文件和yolov3.weights文件来训练我的自定义数据集。 However when I'm trying to run tfnet = TFNet(history) , it throws an error of "exit not defined". 但是,当我尝试运行tfnet = TFNet(history) ,会引发“未定义退出”错误。

I have installed darkflow by the following steps: 我已通过以下步骤安装了darkflow

In Anaconda Prompt: 在Anaconda提示中:

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

then: 然后:

%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

So I faced the same problem and the issue is with the process.py file in darkflow --> utils folder. 所以我遇到了同样的问题,问题出在darkflow-> utils文件夹中的process.py文件中。

Apparently the exit() method is not in-built so you have to add this line in process.py 显然exit()方法不是内置的,因此您必须在process.py中添加此行

from sys import exit 从sys导入出口

Note : If your code is reaching this point it means the models can't read the layers. 注意:如果您的代码达到了这一点,则意味着模型无法读取图层。 The weights file that I downloaded for yolov3 gave me same trouble and I couldn't find a link that has a proper weight file for yolov3 that works in darkflow. 我为yolov3下载的权重文件给我带来了同样的麻烦,并且我找不到一个链接,该链接具有适用于darkflow的yolov3合适的权重文件。 So I had to stick to yolo.cfg and yolo.weights . 所以我不得不坚持yolo.cfg和yolo.weights。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM