0

I'm trying to train my custom dataset by creating yolov3.cfg file and yolov3.weights file with labelled annotations and images using darkflow. However when I'm trying to run tfnet = TFNet(history), it throws an error of "exit not defined".

I have installed darkflow by the following steps:

In Anaconda Prompt:

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
ash
  • 5,139
  • 2
  • 27
  • 39

1 Answers1

2

So I faced the same problem and the issue is with the process.py file in darkflow --> utils folder.

Apparently the exit() method is not in-built so you have to add this line in process.py

from sys import exit

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. So I had to stick to yolo.cfg and yolo.weights .