Skip to content

Instantly share code, notes, and snippets.

@TomoshibiAkira
Created March 3, 2019 18:42
Show Gist options
  • Save TomoshibiAkira/8d79a4ef336c14cc91b1e8e83761ae88 to your computer and use it in GitHub Desktop.
Save TomoshibiAkira/8d79a4ef336c14cc91b1e8e83761ae88 to your computer and use it in GitHub Desktop.
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