1

The darknet training command darknet.exe detector train data/obj.data yolo-obj.cfg yolov4.conv.137 produces the error: Couldn't open file: data/obj.data on my Windows 10 device.

I have followed the instructions in the AlexeyAB README file under "How to train (to detect your custom objects)".

The yolo-obj.cfg is configured accordingly. I have it in the darknet/cfg folder.

The darknet.exe has been built successfully.

I have my 10 custom classes in:

obj.data file (in the darknet/data folder)

classes= 10 
train = data/train.txt  
valid = data/train.txt  
names = data/obj.names  (I tried both relative and absolute path here)
backup = backup/ 

obj.names file (in the darknet/data folder)

Mug
Cathedral
Lake
Bear
Tree
Mountain
Baby
Rabbit
Person
Strawberry

I have my train.txt file in the darknet/data folder with contents:

data/image1.jpg.jpg (the repetition of jpg is there because I've named every image with a jpg extension)
data/image2.jpg.jpg
data/image3.jpg.jpg
data/image4.jpg.jpg
data/image5.jpg.jpg
data/image6.jpg.jpg
data/image7.jpg.jpg
data/image8.jpg.jpg
data/image9.jpg.jpg
data/image10.jpg.jpg

My yolov4 weights are in the main darknet folder.

I tried using both relative and absolute path in every single file, tried configuring everything in the build/darknet/x64 folder too (one of the Darknet developers that was advising regarding the issue on the Darknet discord actually told me that the darknet/data folder should be used and NOT the darknet/build/darknet/x64 folder when training your custom data!) - regardless of what I do, I always get the error:

Couldn't open file: data/obj.data

  • Should I add absolute paths in my train.txt file (although I did try that and it still didn't work);
  • My obj.data file is a normal txt file that I open with Notepad.

Anyone having the same issue or having some intuitions about what could be going wrong?

AK_KA
  • 73
  • 1
  • 10

1 Answers1

1

The problem was with the file extensions. For some reason, my obj.data file was not saved as a 'data' file but as a 'names' file, so I had to change that. I used relative paths in the obj.data file and absolute paths in the train.txt file. The command that did work out for me in the end was:

darknet.exe detector -dont_show -map train data/obj.data cfg/yolo-obj.cfg data/yolov4.conv.137

  • Where I specified the location of the cfg file, hence cfg/yolo-obj.cfg;
  • Where I also specified the location of the weights, hence data/yolov4.conv.137.
AK_KA
  • 73
  • 1
  • 10