# Path: src/e2eflow/core/augment.py
# def random_crop(tensors, size, seed=None, name=None):
#     """Randomly crops multiple tensors (of the same shape) to a given size.
# 
#     Each tensor is cropped in the same way."""
#     with tf.name_scope(name, "random_crop", [size]) as name:
#         size = tf.convert_to_tensor(size, dtype=tf.int32, name="size")
#         if len(tensors) == 2:
#             shape = tf.minimum(tf.shape(tensors[0]), tf.shape(tensors[1]))
#         else:
#             shape = tf.shape(tensors[0])
# 
#         limit = shape - size + 1
#         offset = tf.random_uniform(
#            tf.shape(shape),
#            dtype=size.dtype,
#            maxval=size.dtype.max,
#            seed=seed) % limit
#         results = []
#         for tensor in tensors:
#             result = tf.slice(tensor, offset, size)
#             results.append(result)
#         return results


import os
import random
import numpy as np
import tensorflow as tf
from .augment import random_crop
                    fn2 = os.path.join(dir_path, files[i + 1])
                    filenames.append((fn1, fn2))

        random.seed(seed)
        random.shuffle(filenames)
        print("Training on {} frame pairs.".format(len(filenames)))

        filenames_extended = []
        for fn1, fn2 in filenames:
            filenames_extended.append((fn1, fn2))
            if swap_images:
                filenames_extended.append((fn2, fn1))

        shift = shift % len(filenames_extended)
        filenames_extended = list(np.roll(filenames_extended, shift))


        filenames_1, filenames_2 = zip(*filenames_extended)
        filenames_1 = list(filenames_1)
        filenames_2 = list(filenames_2)

        with tf.variable_scope('train_inputs'):
            image_1 = read_png_image(filenames_1)
            image_2 = read_png_image(filenames_2)

            if needs_crop:
                #if center_crop:
                #    image_1 = tf.image.resize_image_with_crop_or_pad(image_1, height, width)
                #    image_2 = tf.image.resize_image_with_crop_or_pad(image_1, height, width)
                #else:

# Path: src/e2eflow/core/augment.py
# def random_crop(tensors, size, seed=None, name=None):
#     """Randomly crops multiple tensors (of the same shape) to a given size.
# 
#     Each tensor is cropped in the same way."""
#     with tf.name_scope(name, "random_crop", [size]) as name:
#         size = tf.convert_to_tensor(size, dtype=tf.int32, name="size")
#         if len(tensors) == 2:
#             shape = tf.minimum(tf.shape(tensors[0]), tf.shape(tensors[1]))
#         else:
#             shape = tf.shape(tensors[0])
# 
#         limit = shape - size + 1
#         offset = tf.random_uniform(
#            tf.shape(shape),
#            dtype=size.dtype,
#            maxval=size.dtype.max,
#            seed=seed) % limit
#         results = []
#         for tensor in tensors:
#             result = tf.slice(tensor, offset, size)
#             results.append(result)
#         return results


# Path: src/e2eflow/core/input.py
import os
import random
import numpy as np
import tensorflow as tf
from .augment import random_crop

                    fn2 = os.path.join(dir_path, files[i + 1])
                    filenames.append((fn1, fn2))

        random.seed(seed)
        random.shuffle(filenames)
        print("Training on {} frame pairs.".format(len(filenames)))

        filenames_extended = []
        for fn1, fn2 in filenames:
            filenames_extended.append((fn1, fn2))
            if swap_images:
                filenames_extended.append((fn2, fn1))

        shift = shift % len(filenames_extended)
        filenames_extended = list(np.roll(filenames_extended, shift))


        filenames_1, filenames_2 = zip(*filenames_extended)
        filenames_1 = list(filenames_1)
        filenames_2 = list(filenames_2)

        with tf.variable_scope('train_inputs'):
            image_1 = read_png_image(filenames_1)
            image_2 = read_png_image(filenames_2)

            if needs_crop:
                #if center_crop:
                #    image_1 = tf.image.resize_image_with_crop_or_pad(image_1, height, width)
                #    image_2 = tf.image.resize_image_with_crop_or_pad(image_1, height, width)
                #else:

                image_1, image_2 = random_crop([image_1, image_2], [height, width, 3])