Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
1c16f6fb
There was a problem fetching the pipeline summary.
Commit
1c16f6fb
authored
7 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
Add a shuffle option
parent
eaa36161
No related branches found
No related tags found
1 merge request
!10
Add a script to convert dbs to tfrecords
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/script/db_to_tfrecords.py
+12
-3
12 additions, 3 deletions
bob/learn/tensorflow/script/db_to_tfrecords.py
with
12 additions
and
3 deletions
bob/learn/tensorflow/script/db_to_tfrecords.py
+
12
−
3
View file @
1c16f6fb
...
...
@@ -52,23 +52,29 @@ The config files should have the following objects totally:
## Optional objects:
# The groups that you want to create tfrecords for. It should be a list of
#
'
world
'
(
'
train
'
in bob.pad.base),
'
dev
'
, and
'
eval
'
values.
#
'
world
'
(
'
train
'
in bob.pad.base),
'
dev
'
, and
'
eval
'
values. [default:
#
'
world
'
]
groups = [
'
world
'
]
# you need a reader function that reads the preprocessed files.
# you need a reader function that reads the preprocessed files. [default:
# bob.bio.base.utils.load]
reader = Preprocessor().read_data
reader = Extractor().read_feature
# or
from bob.bio.base.utils import load as reader
# extension of the preprocessed files.
Usually
'
.hdf5
'
# extension of the preprocessed files.
[default:
'
.hdf5
'
]
data_extension =
'
.hdf5
'
# Shuffle the files before writing them into a tfrecords. [default: False]
shuffle = True
"""
from
__future__
import
absolute_import
from
__future__
import
division
from
__future__
import
print_function
import
random
import
tensorflow
as
tf
from
bob.io.base
import
create_directories_safe
...
...
@@ -107,6 +113,7 @@ def main(argv=None):
reader
=
getattr
(
config
,
'
reader
'
,
load
)
groups
=
getattr
(
config
,
'
groups
'
,
[
'
world
'
])
data_extension
=
getattr
(
config
,
'
data_extension
'
,
'
.hdf5
'
)
shuffle
=
getattr
(
config
,
'
shuffle
'
,
False
)
create_directories_safe
(
output_dir
)
if
not
isinstance
(
groups
,
(
list
,
tuple
)):
...
...
@@ -115,6 +122,8 @@ def main(argv=None):
for
group
in
groups
:
output_file
=
os
.
path
.
join
(
output_dir
,
'
{}.tfrecords
'
.
format
(
group
))
files
=
database
.
all_files
(
groups
=
group
)
if
shuffle
:
random
.
shuffle
(
files
)
n_files
=
len
(
files
)
with
tf
.
python_io
.
TFRecordWriter
(
output_file
)
as
writer
:
for
i
,
f
in
enumerate
(
files
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment