Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv::dnn::readNetFromDarknet() error in reading configutaion files #10160

Closed
DGKmaster opened this issue Nov 25, 2017 · 8 comments
Closed

cv::dnn::readNetFromDarknet() error in reading configutaion files #10160

DGKmaster opened this issue Nov 25, 2017 · 8 comments

Comments

@DGKmaster
Copy link

@DGKmaster DGKmaster commented Nov 25, 2017

System information (version)
  • OpenCV => 3.3.1
  • Operating System / Platform => Ubuntu MATE 16.04.3 LTS (Xenial Xerus) (on Oracle VM for Windows, version 5.1.24 r117012 (Qt5.6.2))
  • Compiler => GCC (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
Detailed description

I use sample code to load YOLO model and classify objects and it failes on reading net configuration.

Exact output:
OpenCV Error: Parsing error (Failed to parse NetParameter file: ~/Documents/HunterCV/pyway/cfg/yolo.cfg) in ReadNetParamsFromCfgFileOrDie, file /home/dgk/Pictures/opencv/modules/dnn/src/darknet/darknet_io.cpp, line 612
terminate called after throwing an instance of 'cv::Exception'
what(): /home/dgk/Pictures/opencv/modules/dnn/src/darknet/darknet_io.cpp:612: error: (-212) Failed to parse NetParameter file: ~/Documents/HunterCV/pyway/cfg/yolo.cfg in function ReadNetParamsFromCfgFileOrDie

Steps to reproduce
  1. Download sample for YOLO use
    https://github.com/opencv/opencv/blob/master/samples/dnn/yolo_object_detection.cpp
  2. Download darknet from official site and install it
    https://pjreddie.com/darknet/install/
  3. Download YOLO model and its configuration
  4. Set yolo.cfg as net cfg
  5. Set yolo.weights as net model
@dkurt

This comment has been minimized.

Copy link
Member

@dkurt dkurt commented Nov 26, 2017

@DGKmaster, please try to use absolute paths to files.

@DGKmaster

This comment has been minimized.

Copy link
Author

@DGKmaster DGKmaster commented Nov 26, 2017

@dkurt Thank you! I tried this before but in incorrect way I think.

@DGKmaster DGKmaster closed this Nov 26, 2017
@alalek alalek added the invalid label Nov 26, 2017
@jbeale1

This comment has been minimized.

Copy link

@jbeale1 jbeale1 commented Feb 25, 2018

I have this "ReadNetParamsFromCfgFileOrDie" problem, even with an absolute path to the .cfg file, maybe it's the wrong file?

./example_dnn-yolo_object_detection --cfg /home/pi/OCV/darknet/cfg/tiny-yolo.cfg --model /home/pi/dn/tiny-yolo.weights --class_names /home/pi/OCV/darknet/data/coco.names --source space_shuttle.jpg
OpenCV Error: Parsing error (Failed to parse NetParameter file: true) in ReadNetParamsFromCfgFileOrDie, file /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp, line 612
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp:612: error: (-212) Failed to parse NetParameter file: true in function ReadNetParamsFromCfgFileOrDie

ll /home/pi/OCV/darknet/cfg/tiny-yolo.cfg
-rw-r--r-- 1 pi pi 1488 Feb 24 16:49 /home/pi/OCV/darknet/cfg/tiny-yolo.cfg

@dkurt

This comment has been minimized.

Copy link
Member

@dkurt dkurt commented Feb 25, 2018

@jbeale1, try the same without spaces between command line keys and values

./example_dnn-yolo_object_detection --cfg=/home/pi/OCV/darknet/cfg/tiny-yolo.cfg --model=/home/pi/dn/tiny-yolo.weights --class_names=/home/pi/OCV/darknet/data/coco.names --source=space_shuttle.jpg

Otherwise they are interpreted as boolean flags:

what(): /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp:612: error: (-212) Failed to parse NetParameter file: true in function ReadNetParamsFromCfgFileOrDie

@kakri

This comment has been minimized.

Copy link

@kakri kakri commented Nov 15, 2018

I have this "ReadNetParamsFromCfgFileOrDie" problem, even with an absolute path to the .cfg file, maybe it's the wrong file?

./example_dnn-yolo_object_detection --cfg /home/pi/OCV/darknet/cfg/tiny-yolo.cfg --model /home/pi/dn/tiny-yolo.weights --class_names /home/pi/OCV/darknet/data/coco.names --source space_shuttle.jpg
OpenCV Error: Parsing error (Failed to parse NetParameter file: true) in ReadNetParamsFromCfgFileOrDie, file /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp, line 612
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp:612: error: (-212) Failed to parse NetParameter file: true in function ReadNetParamsFromCfgFileOrDie

ll /home/pi/OCV/darknet/cfg/tiny-yolo.cfg
-rw-r--r-- 1 pi pi 1488 Feb 24 16:49 /home/pi/OCV/darknet/cfg/tiny-yolo.cfg

Did you find the solution to your problem? i am also facing the same problem. Can you help me out in solving the problem.

@DGKmaster

This comment has been minimized.

Copy link
Author

@DGKmaster DGKmaster commented Nov 15, 2018

I have this "ReadNetParamsFromCfgFileOrDie" problem, even with an absolute path to the .cfg file, maybe it's the wrong file?
./example_dnn-yolo_object_detection --cfg /home/pi/OCV/darknet/cfg/tiny-yolo.cfg --model /home/pi/dn/tiny-yolo.weights --class_names /home/pi/OCV/darknet/data/coco.names --source space_shuttle.jpg
OpenCV Error: Parsing error (Failed to parse NetParameter file: true) in ReadNetParamsFromCfgFileOrDie, file /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp, line 612
terminate called after throwing an instance of 'cv::Exception'
what(): /home/pi/OCV/opencv-3.4.0/modules/dnn/src/darknet/darknet_io.cpp:612: error: (-212) Failed to parse NetParameter file: true in function ReadNetParamsFromCfgFileOrDie
ll /home/pi/OCV/darknet/cfg/tiny-yolo.cfg
-rw-r--r-- 1 pi pi 1488 Feb 24 16:49 /home/pi/OCV/darknet/cfg/tiny-yolo.cfg

Did you find the solution to your problem? i am also facing the same problem. Can you help me out in solving the problem.

Yes I've found it. As I said I made absolute paths to the config file and it works. Here is my example code, which I modified for my laptop:
https://gitlab.com/DGKmaster/HunterCV/blob/master/CLcpp/Net/Net.cpp

@Vellimakhlooq

This comment has been minimized.

Copy link

@Vellimakhlooq Vellimakhlooq commented Dec 6, 2019

@DGKmaster, please try to use absolute paths to files.

kindly explain what is absolute path how to use it am aslo getting this error

@DGKmaster

This comment has been minimized.

Copy link
Author

@DGKmaster DGKmaster commented Dec 8, 2019

@Vellimakhlooq you need set path from root catalogue, not from current directory:
Wrong way:
_net_cfg_path = "cfg/yolo.cfg";
_net_cfg_path = "yolo.cfg";

Right way:
_net_cfg_path = "/home/user/yolo/cfg/yolo.cfg";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants
You can’t perform that action at this time.