Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
e7027fec
Commit
e7027fec
authored
Oct 14, 2022
by
A. Unique TensorFlower
Browse files
Internal change
PiperOrigin-RevId: 481251614
parent
6f521d91
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
official/core/file_writers.py
official/core/file_writers.py
+4
-3
official/core/file_writers_test.py
official/core/file_writers_test.py
+3
-2
No files found.
official/core/file_writers.py
View file @
e7027fec
...
@@ -33,13 +33,14 @@ def write_small_dataset(examples: Sequence[Union[tf.train.Example,
...
@@ -33,13 +33,14 @@ def write_small_dataset(examples: Sequence[Union[tf.train.Example,
examples: List of tf.train.Example or tf.train.SequenceExample.
examples: List of tf.train.Example or tf.train.SequenceExample.
output_path: Output path for the dataset.
output_path: Output path for the dataset.
file_type: A string indicating the file format, could be: 'tfrecord',
file_type: A string indicating the file format, could be: 'tfrecord',
'tfrecord_compressed', 'riegeli'.
'tfrecords', 'tfrecord_compressed', 'tfrecords_gzip', 'riegeli'. The
string is case insensitive.
"""
"""
file_type
=
file_type
.
lower
()
file_type
=
file_type
.
lower
()
if
file_type
==
'tfrecord'
:
if
file_type
==
'tfrecord'
or
file_type
==
'tfrecords'
:
_write_tfrecord
(
examples
,
output_path
)
_write_tfrecord
(
examples
,
output_path
)
elif
file_type
==
'tfrecord_compressed'
:
elif
file_type
==
'tfrecord_compressed'
or
file_type
==
'tfrecords_gzip'
:
_write_tfrecord
(
examples
,
output_path
,
_write_tfrecord
(
examples
,
output_path
,
tf
.
io
.
TFRecordOptions
(
compression_type
=
'GZIP'
))
tf
.
io
.
TFRecordOptions
(
compression_type
=
'GZIP'
))
elif
file_type
==
'riegeli'
:
elif
file_type
==
'riegeli'
:
...
...
official/core/file_writers_test.py
View file @
e7027fec
...
@@ -30,8 +30,9 @@ class FileWritersTest(tf.test.TestCase, parameterized.TestCase):
...
@@ -30,8 +30,9 @@ class FileWritersTest(tf.test.TestCase, parameterized.TestCase):
example_builder
.
add_bytes_feature
(
'foo'
,
'Hello World!'
)
example_builder
.
add_bytes_feature
(
'foo'
,
'Hello World!'
)
self
.
_example
=
example_builder
.
example
self
.
_example
=
example_builder
.
example
@
parameterized
.
parameters
(
'tfrecord'
,
'TFRecord'
,
'tfrecord_compressed'
,
@
parameterized
.
parameters
(
'tfrecord'
,
'TFRecord'
,
'tfrecords'
,
'TFRecord_Compressed'
)
'tfrecord_compressed'
,
'TFRecord_Compressed'
,
'tfrecords_gzip'
)
def
test_write_small_dataset_success
(
self
,
file_type
):
def
test_write_small_dataset_success
(
self
,
file_type
):
temp_dir
=
self
.
create_tempdir
()
temp_dir
=
self
.
create_tempdir
()
temp_dataset_file
=
os
.
path
.
join
(
temp_dir
.
full_path
,
'train'
)
temp_dataset_file
=
os
.
path
.
join
(
temp_dir
.
full_path
,
'train'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment