darknet icon indicating copy to clipboard operation
darknet copied to clipboard

Cannot load image "./darknet/dataset/z1.jpg" STB Reason: can't fopen

Open Mps24-7uk opened this issue 5 years ago • 18 comments

Cannot load image “./darknet/dataset/z115.jpg” STB Reason: can't fopen

The darknet directory contains the following:

  • dataset directory: It includes all the annotated data. annotated image text format for yolo

  • obj.data file: It contains obj data

  • obj.names file: It contains obj name

  • train.txt file: It contains train obj test

When I am runing this command: ./darknet detector train obj.data yolov3-tiny.cfg darknet53.conv.74

The Error is generated: Cannot load image "./darknet/dataset/z115.jpg" STB Reason: can't fopen images cant load

The images are present in the dataset but not open.

Please me help with this @antnh6 @sachindesh @TheMikeyR @pjryan513 @BasketJace @jesuisthanos @futureZG @Fnajjar @kylynf @PeterQuinn925 @ahsan856jalal @romass12 @zboinek @BasketJace @Broham

Mps24-7uk avatar Apr 04 '19 18:04 Mps24-7uk

do you use GPU=1 in your Makefile ?

koutini avatar Apr 22 '19 15:04 koutini

You have to use exact path, for example /home/jesuisthanos/darknet/.... Relative paths like yours won't work. Change them

sythanhho avatar Apr 22 '19 15:04 sythanhho

image @jesuisthanos i use the exact path and i get this error

koutini avatar Apr 22 '19 15:04 koutini

Be careful when you save the file, it should be utf-8. It's really easy to face this problem on Windows due to file saving, unlike Linux

sythanhho avatar Apr 22 '19 15:04 sythanhho

@jesuisthanos so what should I do ?

koutini avatar Apr 22 '19 15:04 koutini

@jesuisthanos
image

koutini avatar Apr 22 '19 15:04 koutini

Can you show me your Save As dialog box?

sythanhho avatar Apr 22 '19 15:04 sythanhho

@jesuisthanos I'm also dealing the same problem (cannot load image "*****.txt") an mention it that we should save the file as UTF8 format, do you mean train.txt by that ??

hakS07 avatar Apr 24 '19 08:04 hakS07

I had a similar problem: https://github.com/AlexeyAB/Yolo_mark/issues/132

Arktius avatar Apr 29 '19 12:04 Arktius

@jesuisthanos I am getting the following error.It was working well in a windows machine but when I tried to run on Google colab which is a linux machine I got errors.Any help???

shivu1998 avatar May 09 '19 15:05 shivu1998

I solved this issue by converting the txt files which were created in windows to unix like using the following script which I found here https://stackoverflow.com/questions/36422107/how-to-convert-crlf-to-lf-on-a-windows-machine-in-python

Code:

WINDOWS_LINE_ENDING = b'\r\n' UNIX_LINE_ENDING = b'\n'

sou=r"/content/darknet/cfg/my-yolo2.cfg" file_path = sou

with open(file_path, 'rb') as open_file: content = open_file.read()

content = content.replace(WINDOWS_LINE_ENDING, UNIX_LINE_ENDING)

with open(file_path, 'wb') as open_file: open_file.write(content)

shivu1998 avatar May 09 '19 17:05 shivu1998

Same here; the solution proposed by @shivu1998 did not work for me.

My Software Stack:

OS: Windows 10 Version 1809 (64-bit)
Python: 3.7.3
torch: 1.1.0

talhakabakus avatar May 19 '19 22:05 talhakabakus

In google colab, PATH is different from PC environment, so PATH is required in your drive.

You can check with pwd. In train.txt and test.txt, (/ content / drive / [your PATH] ... / ~ .jpg or .png) and you need to rewrite.

ex) train.txt /content/drive/.../~0.jpg /content/drive/.../~1.jpg ...

piyomatu avatar Sep 15 '19 18:09 piyomatu

Can you show me your Save As dialog box?

thanks, simply by save as..., select unicode, and replace. then it works

aaron-wang-de avatar Sep 28 '19 13:09 aaron-wang-de

Below code worked for me, i have converted the windows train.txt file to Linux file format and i can run the model after that. Thanks to shivu1998

replacement strings

WINDOWS_LINE_ENDING = b'\r\n' UNIX_LINE_ENDING = b'\n'

relative or absolute file path, e.g.:

file_path = r"C:\Users\rkamat\Desktop\YOLO\2\yolo-custom-object-detector-master\python\train.txt"

with open(file_path, 'rb') as open_file: content = open_file.read()

content = content.replace(WINDOWS_LINE_ENDING, UNIX_LINE_ENDING)

with open(file_path, 'wb') as open_file: open_file.write(content)

kamat-roopesh avatar Oct 04 '19 12:10 kamat-roopesh

to linux format

dos2unix train.txt
dos2unix val.txt

postor avatar Oct 29 '19 07:10 postor

Hi, I don't think its with line endings only. I am using Ubuntu. I checked the encoding as UTF8. Still I get the same error. Most importantly not the same image file creating error everytime. Each time its a different image file being reported. Thanks

arnabseacom avatar May 02 '21 18:05 arnabseacom

@arnabseacom I have the same issue, were you able to solve it?

Maithilishetty avatar Mar 20 '22 05:03 Maithilishetty