raccoon_dataset icon indicating copy to clipboard operation
raccoon_dataset copied to clipboard

Unable to create tfrecord

Open Atul997 opened this issue 8 years ago • 20 comments

hi, i created train_labels.csv and test_labels.csv files and when i run the script generate_tfrecord.py it throws me error- Traceback (most recent call last): File "gentf.py", line 99, in <module> tf.app.run() File "/home/atul/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "gentf.py", line 90, in main tf_example = create_tf_example(group, path) File "gentf.py", line 45, in create_tf_example encoded_jpg = fid.read() File "/home/atul/anaconda2/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 118, in read self._preread_check() File "/home/atul/anaconda2/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 78, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "/home/atul/anaconda2/lib/python2.7/contextlib.py", line 24, in __exit__ self.gen.next() File "/home/atul/anaconda2/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status pywrap_tensorflow.TF_GetCode(status)) tensorflow.python.framework.errors_impl.NotFoundError: /home/atul/ob/images/car49

I checked for that file but it is available there, then i run script deleting that row from csv file and same error came for car48.

How can i resolve this?

Atul997 avatar Aug 30 '17 11:08 Atul997

Hi @Atul997,

The script is taking the folder from where you are running generate_tfrecord.py, in this case, seems to be /home/atul/ob/. Try creating a folder images an put all the images there.

It worked for me, but what I did was to modify the script to accept a parameter for the images folder.

Hope this helps.

rabarona avatar Nov 16 '17 22:11 rabarona

Thanks for ur reply, but i reslove this earlier at my end 😊

-Atul

On 17-Nov-2017 4:29 AM, "Ricardo Barona" [email protected] wrote:

Hi @Atul997 https://github.com/atul997,

The script is taking the folder from where you are running generate_tfrecord.py, in this case, seems to be /home/atul/ob/. Try creating a folder images an put all the images there.

It worked for me, but what I did was to modify the script to accept a parameter for the images folder.

Hope this helps.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datitran/raccoon_dataset/issues/12#issuecomment-345090603, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrs6sjOjRn5xVtcDAVRw81pd6uNMDOyks5s3L5ZgaJpZM4PHPy7 .

Atul997 avatar Nov 17 '17 05:11 Atul997

hi @Atul997 could you explain how you solve this problem?

hanaskuliah avatar Nov 27 '17 04:11 hanaskuliah

Traceback (most recent call last): File "generate_tfrecord.py", line 100, in tf.app.run() File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "generate_tfrecord.py", line 91, in main tf_example = create_tf_example(group, path) File "generate_tfrecord.py", line 46, in create_tf_example encoded_jpg = fid.read() File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 119, in read self._preread_check() File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/lib/io/file_io.py", line 79, in _preread_ch eck compat.as_bytes(self._name), 1024 * 512, status) File "/home/ec2-user/anaconda3/envs/JupyterSystemEnv/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in e xit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.NotFoundError: /home/ec2-user/sample-notebooks/object-detection/image/IMG_20171211_133838 - Copy; No suc h file or directory sh-4.2$ python3 xml my images have been annotated iam able to create csv file but not able to create tfrecords

NagrajSrivatsa avatar Dec 14 '17 09:12 NagrajSrivatsa

Any help will be appreciated.Thankyou

NagrajSrivatsa avatar Dec 14 '17 09:12 NagrajSrivatsa

Hi @Atul997 ,

I have similar issue. How did you resolve it? My images are placed in folder my script is running from. And yet it isn't accessed!

yash-bhat avatar Jan 25 '18 06:01 yash-bhat

What exact problem u r facing ??

On 25-Jan-2018 12:20 PM, "Yashaswini Bhat" [email protected] wrote:

Hi @Atul997 https://github.com/atul997 ,

I have similar issue. How did you resolve it? My images are placed in folder my script is running from. And yet it isn't accessed!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datitran/raccoon_dataset/issues/12#issuecomment-360377270, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrs6qtd3BioEI9fF-vGIScS-C8W_SbVks5tOCQpgaJpZM4PHPy7 .

Atul997 avatar Jan 25 '18 07:01 Atul997

@Atul997 Hello, I fixed the issue. The extension of the training images are not specified when 'xml_to_csv' is done. (.png in my case) My dataset is smaller so I just changed it in the csv file manually and rerun ... andit worked! This may have to be incorporated in the 'xml_to_csv' script. Anyway, Thank you:)

yash-bhat avatar Jan 25 '18 12:01 yash-bhat

@Atul997 i am having this issue...aplease help in sorting this out

Traceback (most recent call last): File "F:/Object_detection/generate_tfrecord.py", line 98, in tf.app.run() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run _sys.exit(main(argv)) File "F:/Object_detection/generate_tfrecord.py", line 89, in main tf_example = create_tf_example(group, path) File "F:/Object_detection/generate_tfrecord.py", line 44, in create_tf_example encoded_jpg = fid.read() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 120, in read self._preread_check() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\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: NewRandomAccessFile failed to Create/Open: F:\Object_detection\images\pic3.jpeg : The system cannot find the file specified. ; No such file or directory

Technebby avatar Jul 11 '18 18:07 Technebby

Pls chk that image is inside the specified folder or not. Keep all the images inside a folder and then re-run the code. Hope it helps.

On Wed, Jul 11, 2018, 11:48 PM Technebby [email protected] wrote:

@Atul997 https://github.com/Atul997 i am having this issue...aplease help in sorting this out

Traceback (most recent call last): File "F:/Object_detection/generate_tfrecord.py", line 98, in tf.app.run() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 126, in run _sys.exit(main(argv)) File "F:/Object_detection/generate_tfrecord.py", line 89, in main tf_example = create_tf_example(group, path) File "F:/Object_detection/generate_tfrecord.py", line 44, in create_tf_example encoded_jpg = fid.read() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 120, in read self._preread_check() File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 80, in _preread_check compat.as_bytes(self.__name), 1024 * 512, status) File "C:\Users\Harjeet\AppData\Local\Programs\Python\Python35\lib\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: NewRandomAccessFile failed to Create/Open: F:\Object_detection\images\pic3.jpeg : The system cannot find the file specified. ; No such file or directory

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datitran/raccoon_dataset/issues/12#issuecomment-404263957, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrs6jmuAdW3k7cfY7quBu-QQkNsFZr_ks5uFkF_gaJpZM4PHPy7 .

Atul997 avatar Jul 11 '18 19:07 Atul997

@Atul997 thanks for the valuable comment, i was doing it wrong all together. it worked for me

thanks once again for the help.

Technebby avatar Jul 14 '18 07:07 Technebby

Your welcome☺️

On Sat, Jul 14, 2018, 1:22 PM Technebby [email protected] wrote:

@Atul997 https://github.com/Atul997 thanks for the valuable comment, i was doing it wrong all together. it worked for me

thanks once again for the help.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/datitran/raccoon_dataset/issues/12#issuecomment-405006652, or mute the thread https://github.com/notifications/unsubscribe-auth/ASrs6kfNRxGO2s556ErjC_2iD9tGsvOjks5uGaMqgaJpZM4PHPy7 .

Atul997 avatar Jul 14 '18 07:07 Atul997

While running Generat_tfrecord.py, it says some images are not found in the directory even I using raccoon images and the same steps done by datitran. Pls help me to solve this

Hashirroshan avatar Jul 19 '18 16:07 Hashirroshan

yeah!! it was because the csv file didnt had some image names with extension(jpg in my case), so manually edited the csv file and it worked. Thanks

M1thun avatar Jan 11 '19 19:01 M1thun

Guys make sure your csv file contain file name with extension .jpg if still there is error you can follow code below, thats how I solved this problem

python3 generate_tf_record.py --csv_input=data/train_labels.csv --output_path=train.record python3 generate_tf_record.py --csv_input=data/test_labels.csv --output_path=test.record

all the images were in one folder i.e images and flags were as below

flags.DEFINE_string('csv_input', '','data/train_labels.csv') flags.DEFINE_string('output_path','', 'train.record') flags.DEFINE_string('image_dir', '', 'images')

I saved record file in main folder and later copied it to data folder

BasitJaved avatar May 05 '19 23:05 BasitJaved

@Atul997 Hello, I fixed the issue. The extension of the training images are not specified when 'xml_to_csv' is done. (.png in my case) My dataset is smaller so I just changed it in the csv file manually and rerun ... andit worked! This may have to be incorporated in the 'xml_to_csv' script. Anyway, Thank you:)

can u explain how did u do it?

saikaushik0410 avatar Feb 06 '20 09:02 saikaushik0410

Create train data:

python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record --image_dir=images/train/

Create test data:

python generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record --image_dir=images/test/

try this, worked for me

joel1895 avatar May 18 '20 12:05 joel1895

Create train data:

python generate_tfrecord.py --csv_input=data/train_labels.csv --output_path=data/train.record --image_dir=images/train/

Create test data:

python generate_tfrecord.py --csv_input=data/test_labels.csv --output_path=data/test.record --image_dir=images/test/

try this, worked for me

Hey where we have to write this code?

vishaymalhotra avatar Apr 25 '22 19:04 vishaymalhotra

i solved this issue by rename correctly the xml file (inside of it) and the image file. both have to be in same name otherwise you can't generate tfrecord.

HridoyHazard avatar Jul 03 '22 06:07 HridoyHazard

I solved this issue by rewrite the XML file

for xml_file in glob.glob(path + '/*.xml'): file_names = xml_file.split('\')[1] tree = ET.parse(xml_file) root = tree.getroot() filename = root.find('filename').text+'.JPEG' root.find('filename').text = filename root.insert(2,ET.fromstring(f'{os.path.join(path,filename)}')) tree.write(file_names)

alrappie avatar Jun 01 '23 18:06 alrappie