In [ ]:
%matplotlib inline
%pylab inline
In [ ]:
import menpo.io as mio
from menpo.landmark import labeller, lfpw_face
from menpofast.utils import convert_from_menpo
path = '/data/'
group = 'lfpw_face'
training_images = []
for i in mio.import_images(path + 'PhD/DataBases/faces/cofw/trainset/',
verbose=True, max_images=None):
# convert the image from menpo Image to menpofast Image (channels at front)
i = convert_from_menpo(i)
labeller(i, 'PTS', eval(group))
i.crop_to_landmarks_proportion_inplace(0.5, group=group)
i = i.rescale_landmarks_to_diagonal_range(200, group=group)
if i.n_channels == 3:
i = i.as_greyscale(mode='average')
training_images.append(i)
In [ ]:
from menpo.visualize import visualize_images
visualize_images(training_images)
In [ ]:
from menpofast.feature import no_op, fast_dsift
from alabortcvpr2015.aam import PartsAAMBuilder
unified = PartsAAMBuilder(parts_shape=(21, 21),
features=fast_dsift,
diagonal=100,
normalize_parts=False,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=500).build(training_images,
group=group,
verbose=True)
In [ ]:
from menpofast.image import Image
Image(unified.appearance_models[0].mean().pixels[18, 0]).view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(unified, path + 'PhD/Models/aam_cofw_fast_dsift')