How can I run cv2.dnn.readNetFromDarknet command

Question:

model=cv2.dnn.readNetFromDarknet("C://Users//deniz//Desktop//yolofiles//yolov3-coco_directory//yolov3.cfg","C://Users//deniz//Desktop//yolofiles//yolov3-coco_directory//yolov3.weights")

here is my code but whenever i wrote this code it returns as error cv2.error: OpenCV(4.6.0) D:aopencv-pythonopencv-pythonopencvmodulesdnnsrcdarknetdarknet_importer.cpp:210: error: (-212:Parsing error) Failed to open NetPara
When i write the command to terminal I also got this error(cv2.dnn.readNetFromDarknet : The term ‘cv2.dnn.readNetFromDarknet’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.)
I use VC, Yolov3 and python 3.11

Asked By: bulletproofspirit

||

Answers:

I believe the file’s path is incorrect. In my case, I never found such an error. You can store the path of the file in a variable. This is my code sample.

cfgModel = "yolov3.cfg";
weightsModel = "yolov3.weights";
 
net = cv.dnn.readNetFromDarknet(cfgModel, weightsModel);

I hope this can help you.

Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.