Created
March 3, 2019 18:42
-
-
Save TomoshibiAkira/8d79a4ef336c14cc91b1e8e83761ae88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorpack | |
from tensorpack.dataflow import (FakeData, MultiThreadMapData, MultiProcessMapData, imgaug, BatchData) | |
import numpy as np | |
import time | |
def test(x): | |
# simulate heavy workload | |
time.sleep(0.01) | |
x[0], _prms = aug.augment_return_params(x[0]) | |
print (_prms) | |
return x | |
ds = FakeData([[10, 10, 3]]) | |
aug = imgaug.Gamma() | |
ds = MultiProcessMapData(ds, 4, test) | |
ds = BatchData(ds, 4) | |
ds.reset_state() | |
for i, dp in enumerate(ds): | |
if (i+1) % 2 == 0: | |
exit(0) | |
# output: | |
# | |
# -0.43118484206945873 | |
# -0.43118484206945873 | |
# -0.43118484206945873 | |
# -0.43118484206945873 | |
# -0.45425744974768434 | |
# -0.45425744974768434 | |
# -0.45425744974768434 | |
# -0.45425744974768434 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment