image_ops.py
def save_images(images, image_path):
    """Save images.

    Postconditions:
        saves to image file

    Args:
        images: list of images
        image_path: path to save image
    """
    # transform back from [-1,1] to [0,1]
    images = (images+1.)/2.

    # determine tiled image shape
    num_cols = int(ceil(sqrt(len(images))))
    num_rows = int(ceil(1.*len(images)/num_cols))

    # create new tiled image
    h, w = images.shape[1], images.shape[2]
    img = np.zeros((h * num_rows, w * num_cols, 3))
    for i, image in enumerate(images):
        c = i % num_cols
        r = i // num_cols
        img[r*h:r*h+h, c*w:c*w+w, :] = image

    # save image
    im = Image.fromarray(np.uint8(img*255))
    im.save(image_path)
Save images.

    Postconditions:
        saves to image file

    Args:
        images: list of images
        image_path: path to save image
    
Save images.
Postconditions:
saves to image file
Save images . Postconditions : saves to image file
def save_images(images, image_path):
    images = (images+1.)/2.
    num_cols = int(ceil(sqrt(len(images))))
    num_rows = int(ceil(1.*len(images)/num_cols))
    h, w = images.shape[1], images.shape[2]
    img = np.zeros((h * num_rows, w * num_cols, 3))
    for i, image in enumerate(images):
        c = i % num_cols
        r = i // num_cols
        img[r*h:r*h+h, c*w:c*w+w, :] = image
    im = Image.fromarray(np.uint8(img*255))
    im.save(image_path)
def save_images ( images , image_path ) : images = ( images + 1. ) / 2. num_cols = int ( ceil ( sqrt ( len ( images ) ) ) ) num_rows = int ( ceil ( 1. * len ( images ) / num_cols ) ) h , w = images . shape [ 1 ] , images . shape [ 2 ] img = np . zeros ( ( h * num_rows , w * num_cols , 3 ) ) for i , image in enumerate ( images ) : c = i % num_cols r = i // num_cols img [ r * h : r * h + h , c * w : c * w + w , : ] = image im = Image . fromarray ( np . uint8 ( img * 255 ) ) im . save ( image_path )
Save images.
Save images .
"""Save images.

    Postconditions:
        saves to image file

    Args:
        images: list of images
        image_path: path to save image
    """ # transform back from [-1,1] to [0,1] # determine tiled image shape # create new tiled image # save image
images
list of images
list of images
image_path
path to save image
path to save image