Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
68981b66
Commit
68981b66
authored
Mar 03, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[dump lmdb] add write frequency option
parent
73c8dd32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
tensorpack/dataflow/dftools.py
tensorpack/dataflow/dftools.py
+3
-2
No files found.
tensorpack/dataflow/dftools.py
View file @
68981b66
...
...
@@ -41,7 +41,7 @@ def dump_dataset_images(ds, dirname, max_count=None, index=0):
cv2
.
imwrite
(
os
.
path
.
join
(
dirname
,
"{}.jpg"
.
format
(
i
)),
img
)
def
dump_dataflow_to_lmdb
(
ds
,
lmdb_path
):
def
dump_dataflow_to_lmdb
(
ds
,
lmdb_path
,
write_frequency
=
5000
):
"""
Dump a Dataflow to a lmdb database, where the keys are indices and values
are serialized datapoints.
...
...
@@ -51,6 +51,7 @@ def dump_dataflow_to_lmdb(ds, lmdb_path):
Args:
ds (DataFlow): the DataFlow to dump.
lmdb_path (str): output path. Either a directory or a mdb file.
write_frequency (int): the frequency to write back data to disk.
"""
assert
isinstance
(
ds
,
DataFlow
),
type
(
ds
)
isdir
=
os
.
path
.
isdir
(
lmdb_path
)
...
...
@@ -73,7 +74,7 @@ def dump_dataflow_to_lmdb(ds, lmdb_path):
try
:
while
True
:
with
db
.
begin
(
write
=
True
)
as
txn
:
for
_
in
range
(
1000
):
for
_
in
range
(
write_frequency
):
idx
+=
1
dp
=
next
(
itr
)
txn
.
put
(
u'{}'
.
format
(
idx
)
.
encode
(
'ascii'
),
dumps
(
dp
))
...
...
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