예제 #1
0
파일: videos.py 프로젝트: wade1990/glow-2
def get_mixs(name1, name2, points=46):
    img1 = align(name1)
    img2 = align(name2)
    z1 = encode(img1)
    z2 = encode(img2)
    imgs, _ = mix_range(z1, z2, points)
    return imgs
예제 #2
0
파일: videos.py 프로젝트: chinatian/glow
def get_mixs(name1, name2, points=46):
    img1 = align(name1)
    img2 = align(name2)
    z1 = encode(img1)
    z2 = encode(img2)
    imgs, _ = mix_range(z1, z2, points)
    return imgs
예제 #3
0
def encode(input_path):
	img = Image.open(input_path)
	img = align_face.align(input_path)
	img = np.reshape(img, [1,256,256,3])

	t = time.time()
	eps = model.encode(img)
	print("Encoding latency {} sec/img".format(time.time() - t))
	return eps
def get_encodings(model, image, get_box=False):

    face, box = af.align(image)
    emb = []

    if len(face) > 1:
        for f in face:
            f = cv2.resize(f, dsize=(96, 96), interpolation=cv2.INTER_CUBIC)
            #f = f[...,::-1]
            f = np.array(
                [np.around(np.transpose(f, [2, 0, 1]) / 255.0, decimals=12)])
            emb.append(model.predict_on_batch(f))
    else:
        face = cv2.resize(face[0],
                          dsize=(96, 96),
                          interpolation=cv2.INTER_CUBIC)
        face = np.array(
            [np.around(np.transpose(face, [2, 0, 1]) / 255.0, decimals=12)])
        emb.append(model.predict_on_batch(face))

    if get_box:
        return emb, box

    return emb
예제 #5
0
def align_image(input_path, output_path):
	img = align_face.align(input_path)
	img = Image.fromarray(img).convert('RGB')
	img.save(output_path)
예제 #6
0
파일: videos.py 프로젝트: wade1990/glow-2
def get_manipulations(name, typ, points=46, scale=1.0):
    img = align(name)
    z = encode(img)
    imgs, _ = manipulate_range(z, typ, points, scale)
    return imgs
예제 #7
0
파일: videos.py 프로젝트: chinatian/glow
def get_manipulations(name, typ, points=46, scale=1.0):
    img = align(name)
    z = encode(img)
    imgs, _ = manipulate_range(z, typ, points, scale)
    return imgs