#!/usr/bin/env python3

from align import FaceAlign
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import numpy as np

fa = FaceAlign('models/landmarks.dat')
test_img = mpimg.imread('HBTN/LauraVasquezBernal5.jpg')
anchors = np.array([[0.194157, 0.16926692], [0.7888591, 0.15817115], [0.4949509, 0.5144414]], dtype=np.float32)
aligned = fa.align(test_img, np.array([36, 45, 33]), anchors, 96)
print(aligned.shape)
plt.imshow(aligned)
ax = plt.gca()
for anchor in anchors:
    ax.add_patch(Circle(anchor * 96, 1))
plt.show()
Esempio n. 2
0
#!/usr/bin/env python3

from align import FaceAlign
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

fa = FaceAlign('models/landmarks.dat')
test_img = mpimg.imread('HBTN/LauraVasquezBernal7.jpg')
box = fa.detect(test_img)
print(type(box))
plt.imshow(test_img)
ax = plt.gca()
rect = Rectangle((box.left(), box.top()),
                 box.width(),
                 box.height(),
                 fill=False)
ax.add_patch(rect)
plt.show()
Esempio n. 3
0
#!/usr/bin/env python3

from align import FaceAlign
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
from matplotlib.patches import Circle

fa = FaceAlign('models/landmarks.dat')
test_img = mpimg.imread('HBTN/KirenSrinivasan.jpg')
box = fa.detect(test_img)
landmarks = fa.find_landmarks(test_img, box)
print(type(landmarks), landmarks.shape)
plt.imshow(test_img)
ax = plt.gca()
for landmark in landmarks:
    ax.add_patch(Circle(landmark))
plt.show()
Esempio n. 4
0
#!/usr/bin/env python3

from align import FaceAlign
import matplotlib.pyplot as plt
import numpy as np
import os
from utils import load_images, save_images

fa = FaceAlign('models/landmarks.dat')
images, filenames = load_images('HBTN', as_array=False)
anchors = np.array(
    [[0.194157, 0.16926692], [0.7888591, 0.15817115], [0.4949509, 0.5144414]],
    dtype=np.float32)
aligned = []
count = 0
for image in images:
    count = count + 1
    print(count)
    aligned.append(fa.align(image, np.array([36, 45, 33]), anchors, 96))
aligned = np.array(aligned)
print(aligned.shape)
if not os.path.isdir('HBTNaligned'):
    print(save_images('HBTNaligned', aligned, filenames))
    os.mkdir('HBTNaligned')
print(save_images('HBTNaligned', aligned, filenames))
print(os.listdir('HBTNaligned'))
image = plt.imread('HBTNaligned/KirenSrinivasan.jpg')
plt.imshow(image)
plt.show()