Python Examples

The following are 2 code examples for showing how to use These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module , or try the search function .

Example 1
Project: Colorization.tensorflow   Author: shekkizh   File:    License: MIT License 5 votes vote down vote up
def save_image(image, save_dir, name):
    Save image by unprocessing and converting to rgb.
    :param image: iamge to save
    :param save_dir: location to save image at
    :param name: prefix to save filename
    image = color.lab2rgb(image)
    io.imsave(os.path.join(save_dir, name + ".png"), image) 
Example 2
Project: VisualizingNDF   Author: Nicholasli1995   File:    License: MIT License 5 votes vote down vote up
def main():
    args = get_args()
    output_path = args.output
    img_size = args.img_size

    mypath = '../data/CACD2000'
    isPlot = False
    onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
#    landmark_list = []
#    for i in tqdm(range(len(onlyfiles))):
#        landmark_list.append(get_landmarks(onlyfiles[i], args))

    landmark_ref = np.matrix(np.load('../data/CACD_mean_face.npy', allow_pickle=True))
    # Points used to line up the images.
    ALIGN_POINTS = list(range(16))

    for i in tqdm(range(len(onlyfiles))):

        img_name = onlyfiles[i]        
        input_img = cv2.imread(mypath+'/'+img_name)
        input_img = cv2.cvtColor(input_img, cv2.COLOR_BGR2RGB)
        img_h, img_w, _ = np.shape(input_img)

        landmark = get_landmarks(img_name, args)[0]
        M = transformation_from_points(landmark_ref[ALIGN_POINTS], 
        input_img = warp_im(input_img, M, (256, 256, 3))
        io.imsave(args.output +'/'+ img_name, input_img)