Skip to content

Commit

Permalink
doc for prefetch. brightnessadd -> brightness
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Apr 21, 2016
1 parent 3e87659 commit 27ea283
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/ResNet/cifar10_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def get_data(train_or_test):
imgaug.CenterPaste((40, 40)),
imgaug.RandomCrop((32, 32)),
imgaug.Flip(horiz=True),
#imgaug.BrightnessAdd(20),
#imgaug.Brightness(20),
#imgaug.Contrast((0.6,1.4)),
imgaug.MapImage(lambda x: x - pp_mean),
]
Expand Down
2 changes: 1 addition & 1 deletion examples/ResNet/svhn_resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_data(train_or_test):
imgaug.CenterPaste((40, 40)),
imgaug.RandomCrop((32, 32)),
#imgaug.Flip(horiz=True),
imgaug.BrightnessAdd(10),
imgaug.Brightness(10),
imgaug.Contrast((0.8,1.2)),
imgaug.GaussianDeform( # this is slow
[(0.2, 0.2), (0.2, 0.8), (0.8,0.8), (0.8,0.2)],
Expand Down
2 changes: 1 addition & 1 deletion examples/cifar10_convnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def get_data(train_or_test):
augmentors = [
imgaug.RandomCrop((30, 30)),
imgaug.Flip(horiz=True),
imgaug.BrightnessAdd(63),
imgaug.Brightness(63),
imgaug.Contrast((0.2,1.8)),
imgaug.GaussianDeform(
[(0.2, 0.2), (0.2, 0.8), (0.8,0.8), (0.8,0.2)],
Expand Down
2 changes: 1 addition & 1 deletion examples/svhn_digit_convnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def get_config():

augmentors = [
imgaug.Resize((40, 40)),
imgaug.BrightnessAdd(30),
imgaug.Brightness(30),
imgaug.Contrast((0.5,1.5)),
imgaug.GaussianDeform( # this is slow
[(0.2, 0.2), (0.2, 0.8), (0.8,0.8), (0.8,0.2)],
Expand Down
5 changes: 4 additions & 1 deletion tensorpack/dataflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def size(self):

def reset_state(self):
"""
Reset state of the dataflow (usually the random seed)
Reset state of the dataflow,
for example, RNG **HAS** to be reset here if used in the DataFlow.
Otherwise it may not work well with prefetching, because different
processes will have the same RNG state.
"""
pass

Expand Down
4 changes: 2 additions & 2 deletions tensorpack/dataflow/imgaug/imgproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from .base import ImageAugmentor
import numpy as np

__all__ = ['BrightnessAdd', 'Contrast', 'MeanVarianceNormalize']
__all__ = ['Brightness', 'Contrast', 'MeanVarianceNormalize']

class BrightnessAdd(ImageAugmentor):
class Brightness(ImageAugmentor):
"""
Random adjust brightness.
"""
Expand Down
1 change: 1 addition & 0 deletions tensorpack/dataflow/prefetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(self, ds, queue):
self.queue = queue

def run(self):
# reset RNG of ds so each process will produce different data
self.ds.reset_state()
while True:
for dp in self.ds.get_data():
Expand Down

0 comments on commit 27ea283

Please sign in to comment.