def datagenerator_affine(gen,test = False):
    """ 
    Datagenerator for the affine network (both stages)

    Args:
        gen: an image generator, loading the image, indicator, loss placeholders and landmarks
        test: True in case we test the function

    Returns:
        generator to train the affine network using Keras
    """

    while True:
        X = next(gen)
        yield ([X[0]], [X[1], X[2]])
        if test == True:
            return [X[0], [X[1],X[2]]]