thtrieu / darkflow

Translate darknet to tensorflow. Load trained weights, retrain/fine-tune using tensorflow, export constant graph def to mobile devices
GNU General Public License v3.0
6.13k stars 2.08k forks source link

Error in cfg_yielder while trying to import yolo trained on coco #560

Open gauravspatil opened 6 years ago

gauravspatil commented 6 years ago

I downloaded the yolov2 608x608 .cfg and .weights files trained on the coco dataset from here and I'm running this code

from darkflow.net.build import TFNet options = options = {"model": "cfg/yolov2_608.cfg", "load": "bin/yolov2_608.weights", "threshold": 0.1, "gpu": 1.0} tfnet = TFNet(options)

I get this error

Parsing ./cfg/yolov2_608.cfg Traceback (most recent call last):

File "", line 3, in tfnet = TFNet(options)

File "C:\Users\CDS Lab\Downloads\darkflow-master\darkflow\net\build.py", line 58, in init darknet = Darknet(FLAGS)

File "C:\Users\CDS Lab\Downloads\darkflow-master\darkflow\dark\darknet.py", line 17, in init src_parsed = self.parse_cfg(self.src_cfg, FLAGS)

File "C:\Users\CDS Lab\Downloads\darkflow-master\darkflow\dark\darknet.py", line 68, in parse_cfg for i, info in enumerate(cfg_layers):

File "C:\Users\CDS Lab\Downloads\darkflow-master\darkflow\utils\process.py", line 316, in cfg_yielder exit('Layer {} not implemented'.format(d['type']))

NameError: name 'exit' is not defined

I have no idea what is causing this. I have successfully loaded and used the .cfg and .weights files trained on the voc dataset and they have worked fine.

raulincze commented 6 years ago

Hello,

Quite a strange error you've got there. If I'm not mistaken 'exit' should be a built-in constant. The reason it reaches there is because it didn't find an implementation for the layer in d['type']. Could you inspect the value of d['type'] before the exit?

There could be a workaround for all of this, if you say that you've successfully loaded the weights from command line:

  1. Export the model as a protobuff (.pb) file flow --model cfg/yolov2_608.cfg --load bin/yolov2_608.weights --savepb
  2. In your python code load the .pb and the .meta files from darkflow.net.build import TFNet options = {"metaLoad": "built_graph/yolov2_608.meta", "pbLoad": "built_graph/yolov2_608.pb", "threshold": 0.1, "gpu": 1.0} tfnet = TFNet(options)
glenn-jocher commented 6 years ago

I see the same error when trying to import yolov3:

options = {'model': path + 'darknet/cfg/yolov3.cfg', 'load': path + 'darknet/yolov3.weights', 'threshold': 0.6}
tfnet = TFNet(options)

File "/Users/glennjocher/Documents/PyCharmProjects/Velocity/venv/lib/python3.6/site-packages/darkflow/utils/process.py", line 316, in cfg_yielder
    exit('Layer {} not implemented'.format(d['type']))
NameError: name 'exit' is not defined

Attempting to produce a .pb for yolov3 likewise seems to fail. No error is sown, however I can't find a new *.pb anywhere:

$ flow --model /Users/glennjocher/darknet/cfg/yolov3.cfg --load /Users/glennjocher/darknet/yolov3.weights --savepb

Parsing ./cfg/yolov3.cfg
Layer [shortcut] not implemented 
Usamawahabkhan commented 6 years ago

Testing python flow --model cfg/yolov3.cfg --load bin/yolov3.weights --demo ./video.mp4 --gpu 1.0 --saveVideo and having this error Parsing ./cfg/yolov3.cfg Layer [shortcut] not implemented

oxanderv commented 6 years ago

Problem occurs when using Yolov3, change to Yolov2

aseembh2001 commented 5 years ago

I am facing the same issue, I have downloaded the weights file from https://pjreddie.com/media/files/yolo.weights

AbanoubMamdouh commented 5 years ago

Hello, Any fix for the error? I am going through the same issue for a custom trained tiny yolo v3 model.