MicrocontrollersAndMore / TensorFlow_Tut_3_Object_Detection_Walk-through

TensorFlow Tutorial 3: Object Detection Walk-through
21 stars 20 forks source link

2_generate_tfrecords.py - tensorflow.python.framework.errors_impl.NotFoundError: no such file #1

Closed Insertfunnylogin closed 6 years ago

Insertfunnylogin commented 6 years ago

hello thank you for the tutorials, great job, however I just caught an error. I was trying to run 2_generate_tfrecords.py to generate tfrecords csv files were done successfully from xml (I used labelimg 1.6 for win)

my current system: Ubuntu 16.04 CUDA 9.0 cudNN 7 tensorflow-gpu 1.7 from pip python 3.5.2 GPU quadro m4000 (if matters) the only thing I changed in the code - added second class and renamed classes as they were named in labelimg

object detection generally works (using genuine object_detection_tutorial.ipynb)

here's the error I get every time I run the script

$ python3 2_generate_tfrecords.py Traceback (most recent call last): File "2_generate_tfrecords.py", line 185, in main() File "2_generate_tfrecords.py", line 36, in main trainTfRecordFileWriteSuccessful = writeTfRecordFile(TRAIN_CSV_FILE_LOC, TRAIN_TFRECORD_FILE_LOC, TRAIN_IMAGES_DIR) File "2_generate_tfrecords.py", line 63, in writeTfRecordFile tfExample = createTfExample(singleFileData, imagesDir) File "2_generate_tfrecords.py", line 118, in createTfExample tensorFlowImage = tensorFlowImageFile.read() File "/home/nissan/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 120, in read self._preread_check() File "/home/nissan/.local/lib/python3.5/site-packages/tensorflow/python/lib/io/file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "/home/nissan/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py", line 516, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: /home/nissan/models/research/object_detection/TensorFlow_Tut_3_Object_Detection_Walk-through-master/training_images/IMG_10.jpg; No such file or directory

of course, file IMG_10.JPG is there it belongs, on this very path. there's also img's with numbers 1-9, and 11-175, and their respective xmls, but they seem to produce no problem.

do you have any idea what it may be about? thank you in advance.

MicrocontrollersAndMore commented 6 years ago

Very strange that one particular file would not be recognized when the others are.

That said, if you use the configuration I did and follow the steps as shown in the video and described in the walk-through document, I'm confident it would work for you as it did for me, so the error must be caused by either your setup to begin with or one of the steps you have performed slightly differently. Here are at least a few ideas I could throw out there:

1) My tutorial was for Windows, there may be some substantial differences in Ubuntu that I'm not aware of. If you have a Windows 10 machine available, try the same steps on that and see if you get the same error. If you only have 1 computer you could try a Windows 10 / Ubuntu dual-boot (my configuration at both home and work, if you install Windows first, then Ubuntu, the Ubuntu installer makes setting up a dual-boot very easy).

2) I see you're using Python 3.5.x. Some users have reported unusual errors when using a recent version of TensorFlow with Python 3.5. When Ubuntu 18.04 is released later this month it will ship stock with Python 3.6.x, so I would suggest trying that when it's released. From what I understand upping Ubuntu 14.04 or 16.04 to Python 3.6.x is a !@#$% of a job and may mess up other stuff on your computer, it's up to you if this is something you'd like to take on or wait for 18.04.

3) Are you sure that file is ok? Sometimes images can be viewable in a typical image viewer but not open in OpenCV or TensorFlow b/c the formatting is not quite right (or worse yet, the image may open and show a warning on the command line that you may not notice, then the jacked image causes something else to crash later). I would try opening that image in an OpenCV stand-alone test app and verify it opens without error or warning. Also, you could try saving that image to bitmap, then re-saving it as a jpeg.

Without being there in person and seeing how your computer is set up and the steps you've performed I can't really offer much more than the above.

Insertfunnylogin commented 6 years ago

Thank you for the quick response! You seem to be right about the "bad picture", there something was definitely wrong with it. I deleted it from the folder, and then your tfrecord script worked.

However, (it may be interesting for you) after deleting the picture, I also deleted the training_data folder and ran the csv script to generate data anew And after the tfrecord script returned the same error, I opened the train_labels.csv and deleted all the IMG.10 strings manually (there were 4 strings because of 4 labels)

Then it actually worked.

I wonder where those strings came from?

Speaking of ubuntu/win differences, I believe your tutorials should work on linux as well (after some minor changes like paths mb), since the whole thing considered to be cross-platform. I'll try to round up my trials this week, then report back if it's successful.

spomroy commented 5 years ago

In case it's helpful, I had the same error and the reason was the bounding boxes for some images were too small as I noted here.