raccoon_dataset
raccoon_dataset copied to clipboard
How to use tf.python_io.TFRecordWriter in Tensorflow 2.0 (generate_tfrecord.py)
I get this error:
File "generate_tfrecord.py", line 102, in
What do i have to use instead?
use this :
tf.compat.v1.python_io
Or now that TF2 is out:
tf.io.TFRecordWriter
https://www.tensorflow.org/api_docs/python/tf/io/TFRecordWriter
use tf.compat.v1.python_io.TFRecordWriter instead of tf.python_io.TFRecordWriter tf.compat.v1.app.run() instead of tf.app.run() tf.compat.v1.app.flags instead of tf.app.flags
We need to make sure the py script follows the format for tf2: Brushing up @BookPlus2020 answer:
Open the generate_tfrecord.py file and make these changes:
- use tf.compat.v1.python_io.TFRecordWriter instead of tf.python_io.TFRecordWriter
- tf.compat.v1.app.run() instead of tf.app.run()
- tf.compat.v1.app.flags instead of tf.app.flags
- tf.gfile.GFile to tf.io.gfile.GFile
@chuasonglin I followed your revisions and keep getting this error:
$ python3 generate_tfrecord.py --csv_input=data/Train_labels.csv --output_path=data/train.record --image_dir=Camera pictures/Train/
Traceback (most recent call last):
File "generate_tfrecord.py", line 99, in
tf.compat.v1.app.run() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "generate_tfrecord.py", line 90, in main tf_example = create_tf_example(group, path) File "generate_tfrecord.py", line 45, in create_tf_example encoded_jpg = fid.read() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 116, in read self._preread_check() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 78, in _preread_check self._read_buf = _pywrap_file_io.BufferedInputStream( tensorflow.python.framework.errors_impl.NotFoundError: Camera/Camera-mount-and-Raspberry-Pi.png; No such file or directory
@chuasonglin I followed your revisions and keep getting this error: $ python3 generate_tfrecord.py --csv_input=data/Train_labels.csv --output_path=data/train.record --image_dir=Camera pictures/Train/ Traceback (most recent call last): File "generate_tfrecord.py", line 99, in tf.compat.v1.app.run() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/absl/app.py", line 299, in run _run_main(main, args) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/absl/app.py", line 250, in _run_main sys.exit(main(argv)) File "generate_tfrecord.py", line 90, in main tf_example = create_tf_example(group, path) File "generate_tfrecord.py", line 45, in create_tf_example encoded_jpg = fid.read() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 116, in read self._preread_check() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tensorflow/python/lib/io/file_io.py", line 78, in _preread_check self._read_buf = _pywrap_file_io.BufferedInputStream( tensorflow.python.framework.errors_impl.NotFoundError: Camera/Camera-mount-and-Raspberry-Pi.png; No such file or directory
fixed the set of errors?