def data_generator(path, batch_size=8, input_shape=96, scale=2):
    'data generator for fit_generator'
    fns = os.listdir(path)
    n = len(fns)
    i = 0
    while True:
        (lrs, hrs) = ([], [])
        for b in range(batch_size):
            if (i == 0):
                np.random.shuffle(fns)
            fn = fns[i]
            fn = os.path.join(path, fn)
            (lr, hr) = utils.pair(fn, input_shape, scale)
            lr = utils.normalization(lr)
            hr = utils.normalization(hr)
            lrs.append(lr)
            hrs.append(hr)
            i = ((i + 1) % n)
        lrs = np.array(lrs)
        hrs = np.array(hrs)
        (yield (lrs, hrs))
data generator for fit_generator
def data_generator(path, batch_size=8, input_shape=96, scale=2):
    
    fns = os.listdir(path)
    n = len(fns)
    i = 0
    while True:
        (lrs, hrs) = ([], [])
        for b in range(batch_size):
            if (i == 0):
                np.random.shuffle(fns)
            fn = fns[i]
            fn = os.path.join(path, fn)
            (lr, hr) = utils.pair(fn, input_shape, scale)
            lr = utils.normalization(lr)
            hr = utils.normalization(hr)
            lrs.append(lr)
            hrs.append(hr)
            i = ((i + 1) % n)
        lrs = np.array(lrs)
        hrs = np.array(hrs)
        (yield (lrs, hrs))