Darknet: Couldn't open file: train.txt

Created on 25 Nov 2018  ·  36Comments  ·  Source: pjreddie/darknet

I am working on image classification using darknet and YOLO. While training it is giving me the following error:
30 detection
mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.0001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: train.txt
i have searched alot and try all the suggestion but failed. anyone please help me out to resolve this issue.

Most helpful comment

Hi, I solved the problem by rearranging the .data file as follows

`classes= 4

valid = custom/test.txt

names = custom/objects.names

backup = /ExternalData/BackupFerney

train = custom/train.txt`

I wrote the train path line at the end

All 36 comments

Do you have train.txt where your .data file says to find it?

Do you have train.txt where your .data file says to find it?

yes the path is correct.

yes the path is correct and train.txt and .data file are in same folder

check the path. Make sure it's got the right / or \ for the path in windows or unix. Try using a full path for it.

it works. thankyou

@ihafsa can you tell me how you solved this error?

@ihafsa can you tell me how you solved this error?

YES i simply copied the path of train.text file and paste it in .data file

try:
dos2unix data/train.txt
if you were using files created in windows

@zoranl the issue has been solved by giving the full path. and i am working on linux not windows.

@ihafsa well, I am working on both, windows and linux machines. In both machines there is no need for a full path, it works fine with relative paths. But when copying windows edited files to linux, there was an exactly same issue as this one.
So, its good that people that have same problem, could check both solutions.

I have tried all the above suggested solutions but i am still facing the same issue. I did try to convert the file to unix format using dos2unix like @zoranl suggested but i am still struggling with this problem.
Please help~

i had sove this problem :
one: make sure you use abs path
two: cat -v train.txt --> check each line endswith, if you found ^M in your line end , use dos2unix train.txt to transform

tried abs path and relative path, still not solved :(

Hi, I created obj.data file in my windows machine then copied it to linux VM to run darknet on google colab. Firstly, I had a similar issue and this is how I solved it. I simply replaced new lines from '\n' as follows and it worked for me.

content of obj.data
classes= 4'\n'train = /content/drive/My\ Drive/darknet/train.txt'\n'valid = /content/drive/My\ Drive/darknet/test.txt'\n'names = /content/drive/My\ Drive/darknet/obj.names'\n'backup = /content/drive/My\ Drive/darknet/backup

Hi, I solved the problem by rearranging the .data file as follows

`classes= 4

valid = custom/test.txt

names = custom/objects.names

backup = /ExternalData/BackupFerney

train = custom/train.txt`

I wrote the train path line at the end

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

@TanLocc would you solve that?!
I also have the same problem.

I was facing the same problem used the "dos2unix" train and test and didn't work!

Then used the "dos2unix" in the other files (obj.data, obj.names, yolov3.cfg) and it worked:

help me! How to use "dos2unix"? i don't convert train.txt
error: Loading weights from darknet53.conv.74...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: train.txt

help me! How to use "dos2unix"? i don't convert train.txt
error: Loading weights from darknet53.conv.74...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: train.txt

In my case I'm using Windows Subsystem Linux - Ubuntu, so you just need to install and use it:

sudo apt-get update
sudo apt-get install dos2unix
dos2unix /path/to/file

Just check your .data file and train.txt file are in same directory. worked for me

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

Hi, I created obj.data file in my windows machine then copied it to linux VM to run darknet on google colab. Firstly, I had a similar issue and this is how I solved it. I simply replaced new lines from '\n' as follows and it worked for me.

content of obj.data
classes= 4'\n'train = /content/drive/My\ Drive/darknet/train.txt'\n'valid = /content/drive/My\ Drive/darknet/test.txt'\n'names = /content/drive/My\ Drive/darknet/obj.names'\n'backup = /content/drive/My\ Drive/darknet/backup

hey , I'm trying to run my model on colab by but i'm unable to do so.Can you please help me out, i'm facing this error when i try put train on top but if I move to the bottom like @FerneyCordoba my backup files are not created.

@shouryasimha yo solucione el problema descargando nuevamente los archivos desde !git clone https://github.com/AlexeyAB/darknet, inicialmete estaba descargando los archivo desde !git clone https://github.com/pjreddie/darknet lo cual me generaba ese error.

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too

This isssue is because colab is built with Linux I guess , just try

!Sudo apt install dos2unix
!dos2unix (address of train.txt)

On Fri, Apr 24, 2020 at 9:50 PM hustzlb notifications@github.com wrote:

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619300982,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALKV2FZWDP2L2MOR5T3XY6DROI6VPANCNFSM4GGHA72Q
.

still not work

发自我的 iPhone

在 2020年4月25日,上午10:16,shouryasimha addepalli notifications@github.com 写道:

This isssue is because colab is built with Linux I guess , just try

!Sudo apt install dos2unix
!dos2unix (address of train.txt)

On Fri, Apr 24, 2020 at 9:50 PM hustzlb notifications@github.com wrote:

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619300982,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALKV2FZWDP2L2MOR5T3XY6DROI6VPANCNFSM4GGHA72Q
.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.

Try by Applying dos2unix to all your files , I.e. the .txt,.names and
.data files . This should do the trick and again please check your path and
see if there spaces in your.data file after the address.

On Fri, Apr 24, 2020 at 11:33 PM hustzlb notifications@github.com wrote:

still not work

发自我的 iPhone

在 2020年4月25日,上午10:16,shouryasimha addepalli notifications@github.com
写道:

This isssue is because colab is built with Linux I guess , just try

!Sudo apt install dos2unix
!dos2unix (address of train.txt)

On Fri, Apr 24, 2020 at 9:50 PM hustzlb notifications@github.com
wrote:

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619300982>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/ALKV2FZWDP2L2MOR5T3XY6DROI6VPANCNFSM4GGHA72Q

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619313140,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALKV2F66T6WT64Q6UIG2KSTROJKXNANCNFSM4GGHA72Q
.

the train.txt was generated by Colab ,i try to dos2unix trains.txt, but failed.

在 2020年4月25日,下午1:28,shouryasimha addepalli notifications@github.com 写道:

Try by Applying dos2unix to all your files , I.e. the .txt,.names and
.data files . This should do the trick and again please check your path and
see if there spaces in your.data file after the address.

On Fri, Apr 24, 2020 at 11:33 PM hustzlb notifications@github.com wrote:

still not work

发自我的 iPhone

在 2020年4月25日,上午10:16,shouryasimha addepalli notifications@github.com
写道:

This isssue is because colab is built with Linux I guess , just try

!Sudo apt install dos2unix
!dos2unix (address of train.txt)

On Fri, Apr 24, 2020 at 9:50 PM hustzlb notifications@github.com
wrote:

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619300982>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/ALKV2FZWDP2L2MOR5T3XY6DROI6VPANCNFSM4GGHA72Q

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619313140,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALKV2F66T6WT64Q6UIG2KSTROJKXNANCNFSM4GGHA72Q
.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/pjreddie/darknet/issues/1277#issuecomment-619324196, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTJQ55BTLWVYC54CIU2S4TROJYHRANCNFSM4GGHA72Q.

Did you check my repo : https://github.com/Shouryasimha

On Sat, Apr 25, 2020 at 4:31 AM hustzlb notifications@github.com wrote:

the train.txt was generated by Colab ,i try to dos2unix trains.txt, but
failed.

在 2020年4月25日,下午1:28,shouryasimha addepalli notifications@github.com
写道:

Try by Applying dos2unix to all your files , I.e. the .txt,.names and
.data files . This should do the trick and again please check your path
and
see if there spaces in your.data file after the address.

On Fri, Apr 24, 2020 at 11:33 PM hustzlb notifications@github.com
wrote:

still not work

发自我的 iPhone

在 2020年4月25日,上午10:16,shouryasimha addepalli <
[email protected]>
写道:

This isssue is because colab is built with Linux I guess , just try

!Sudo apt install dos2unix
!dos2unix (address of train.txt)

On Fri, Apr 24, 2020 at 9:50 PM hustzlb notifications@github.com
wrote:

mask_scale: Using default '1.000000'
Loading weights from darknet19_448.conv.23...Done!
Learning Rate: 0.001, Momentum: 0.9, Decay: 0.0005
Couldn't open file: /content/darknet/data/train.txt
I am working in google colab. help me

do u solve the issue? me too


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619300982
,
or unsubscribe
<

https://github.com/notifications/unsubscribe-auth/ALKV2FZWDP2L2MOR5T3XY6DROI6VPANCNFSM4GGHA72Q
>

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619313140>,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/ALKV2F66T6WT64Q6UIG2KSTROJKXNANCNFSM4GGHA72Q

.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub <
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619324196>,
or unsubscribe <
https://github.com/notifications/unsubscribe-auth/ANTJQ55BTLWVYC54CIU2S4TROJYHRANCNFSM4GGHA72Q
.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/pjreddie/darknet/issues/1277#issuecomment-619342746,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ALKV2F3UZJKKWPUYJ52LLLTROKNUPANCNFSM4GGHA72Q
.

mask_scale: Uso predeterminado '1.000000'
Cargando pesos desde darknet19_448.conv.23 ... ¡Listo!
Tasa de aprendizaje: 0.001, Momentum: 0.9, Decadencia: 0.0005
No se pudo abrir el archivo: /content/darknet/data/train.txt
Estoy trabajando en Google Colab. ayuadame

¿resuelves el problema? yo también

Hi, I solved the problem by downloading the repository from the main darknet page, I was trying to train YOLOV2 from this repository https://github.com/pjreddie/darknet, but it generated an error. then try to train YOLOV2 from this repository https://github.com/AlexeyAB/darknet, and everything works fine ..

I had this problem:
train="abs_path_in_quotes"
Worked with the following change :
train=abs_path_without_quotes

@shouryasimha Its working. Thanks for the solution.

Try by Applying dos2unix to all your files , I.e. the .txt,.names and .data files . This should do the trick and again please check your path and see if there spaces in your.data file after the address.

check your file is train.txt or train.txt.txt
just rename the file to "train"

Hi, I created obj.data file in my windows machine then copied it to linux VM to run darknet on google colab. Firstly, I had a similar issue and this is how I solved it. I simply replaced new lines from '\n' as follows and it worked for me.

content of obj.data
classes= 4'\n'train = /content/drive/My\ Drive/darknet/train.txt'\n'valid = /content/drive/My\ Drive/darknet/test.txt'\n'names = /content/drive/My\ Drive/darknet/obj.names'\n'backup = /content/drive/My\ Drive/darknet/backup

its works for me

thank you very much

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  ·  4Comments

bujingdexin picture bujingdexin  ·  3Comments

TheHidden1 picture TheHidden1  ·  3Comments

job2003 picture job2003  ·  3Comments

cadip92 picture cadip92  ·  3Comments