Darknet: Open file with white spaces

Created on 18 Jun 2019  Â·  11Comments  Â·  Source: pjreddie/darknet

I'm trying to open the train.txt and test.txt files with the following config file:

classes= 1  
train  = /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/data/nfpa/train.txt  
valid  = /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/data/nfpa/test.txt  
names = /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/obj.names  
backup = /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/backup/

The console show me the folowing error:

Couldn't open file: /content/gdrive/MyDrive/mrcnn_fire/yolo_files/yolo_first_example/data/nfpa/train.txt

I think the problem is related with the white space.
I'm using google colab with the google drive mount and I can't change that path.

Is that any way of fix this?

Most helpful comment

I encountered this issue too, could get it to work with Google Colab by creating a symlink to the desired folder(s). For example, to create a symlink named drive_yolo_files that links to /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/ you can do this in a cell:

!ln -s "/content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/" "/content/drive_yolo_files"

and then specify the paths as /content/drive_yolo_files/backup etc.

Hope this is helpful.

All 11 comments

Yes, I encountered a similar problem. I tried to change the paths to /content/gdrive/My\ Drive/...... However, it still gives report saying Couldn't open file: /content/gdrive/My\Drive/......

Have you solved this problem?

I found two ways to go around this problem. The first is to change Google Drive's default name "My Drive" to something without space. Another is to use shell command in Colab to copy training samples to /content/ folder. To save backup to drive, use another Colab notebook to run the following command.
while true; do cp -r /content/<path to backup>/. /content/gdrive/My\ Drive/<path to desired destination> ;date ; sleep 1800; done

I found two ways to go around this problem. The first is to change Google Drive's default name "My Drive" to something without space. Another is to use shell command in Colab to copy training samples to /content/ folder. To save backup to drive, use another Colab notebook to run the following command.
while true; do cp -r /content/<path to backup>/. /content/gdrive/My\ Drive/<path to desired destination> ;date ; sleep 1800; done

great idea! could you tell me how to change the default name ?I tried ,but not got the way

Actually I used the second method because otherwise I would need to change the path in .cfg file and .txt file. But I found (I did not really try) this website has a way to do this.

thanks Salamendrine

Did you solve this issue? @tanluren @fabioaraujopt

I encountered this issue too, could get it to work with Google Colab by creating a symlink to the desired folder(s). For example, to create a symlink named drive_yolo_files that links to /content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/ you can do this in a cell:

!ln -s "/content/gdrive/My Drive/mrcnn_fire/yolo_files/yolo_first_example/" "/content/drive_yolo_files"

and then specify the paths as /content/drive_yolo_files/backup etc.

Hope this is helpful.

Loading weights from darknet53.conv.74...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/train.txt
plesea, help me, I spent a lot of time for it

Loading weights from darknet53.conv.74...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/train.txt
plesea, help me, I spent a lot of time for it

I encountered the same problem and I tried this:

!ln -s "/content/drive/My\ Drive/darknet" ./darknet detector train custom/darknet.data custom/yolov3.cfg darknet53.conv.74

How ever, I get this error now:
ln: target 'darknet53.conv.74' is not a directory

I have tried an option from https://stackoverflow.com/questions/56640534/cannot-open-train-txt-with-white-space-my-drivehe, but still, the problem persists.
I'll be glad to receive your guidance

I encountered the same problem and I tried this:

!ln -s "/content/drive/My\ Drive/darknet" ./darknet detector train custom/darknet.data custom/yolov3.cfg darknet53.conv.74

How ever, I get this error now:
ln: target 'darknet53.conv.74' is not a directory

I have tried an option from https://stackoverflow.com/questions/56640534/cannot-open-train-txt-with-white-space-my-drivehe, but still, the problem persists.
I'll be glad to receive your guidance

@koojoi, if I understand it correctly, in the example that you bring there is no need to create a symlink since your files are already in a folder whose name does not contain spaces (custom/*). Is the darknet executable in your current directory?
Please provide your directory structure so that we can help.

hey, do u get the solution ? @iibrahimli @koojoi

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gpsmit picture gpsmit  Â·  3Comments

ghost picture ghost  Â·  4Comments

MaverickLoneshark picture MaverickLoneshark  Â·  3Comments

cadip92 picture cadip92  Â·  3Comments

spaul13 picture spaul13  Â·  3Comments