Skip to content

Commit

Permalink
Re-enable xflip
Browse files Browse the repository at this point in the history
  • Loading branch information
desi-ivanov committed Nov 3, 2022
1 parent 10b3f67 commit 62777c4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions training/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self,
raw_shape, # Shape of the raw image data (NCHW).
max_size = None, # Artificially limit the size of the dataset. None = no limit. Applied before xflip.
use_labels = False, # Enable conditioning labels? False = label dimension is zero.
xflip = False, # Ignored for AE
xflip = False, # Artificially double the size of the dataset via x-flips. Applied after max_size.
random_seed = 0, # Random seed to use when applying max_size.
):
self._name = name
Expand All @@ -44,6 +44,9 @@ def __init__(self,

# Apply xflip.
self._xflip = np.zeros(self._raw_idx.size, dtype=np.uint8)
if xflip:
self._raw_idx = np.tile(self._raw_idx, 2)
self._xflip = np.concatenate([self._xflip, np.ones_like(self._xflip)])

def _get_raw_labels(self):
if self._raw_labels is None:
Expand Down Expand Up @@ -83,7 +86,6 @@ def __getitem__(self, idx):
image = self._load_raw_image(self._raw_idx[idx])
assert isinstance(image, np.ndarray)
assert list(image.shape) == self.image_shape
# assert image.dtype == np.uint8
if self._xflip[idx]:
assert image.ndim == 3 # CHW
image = image[:, :, ::-1]
Expand Down

0 comments on commit 62777c4

Please sign in to comment.