In [2]:
%matplotlib inline
%pylab inline
In [3]:
import menpo.io as mio
from menpo.landmark import labeller, ibug_face_49
from menpofast.utils import convert_from_menpo
path = '/data/'
group = 'ibug_face_49'
training_images = []
for i in mio.import_images(path + 'PhD/DataBases/faces/lfpw/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='PTS')
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 [ ]:
for i in mio.import_images(path + 'PhD/DataBases/faces/helen/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='PTS')
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 [ ]:
for i in mio.import_images(path + 'PhD/DataBases/faces/ibug/',
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='PTS')
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 [4]:
from menpo.visualize import visualize_images
visualize_images(training_images)
In [5]:
from menpofast.feature import no_op, fast_dsift, fast_daisy
from alabortcvpr2015.clm import CLMBuilder
from alabortcvpr2015.clm.classifier import MCF
offsets = np.meshgrid(range(-0, 1, 1), range(-0, 1, 1))
offsets = np.asarray([offsets[0].flatten(), offsets[1].flatten()]).T
clm = CLMBuilder(parts_shape=(17, 17),
features=fast_dsift,
diagonal=100,
classifier=MCF,
normalize_parts=False,
covariance=3,
scales=(1, .5),
offsets=offsets).build(training_images,
group=group,
verbose=True)
In [6]:
clm.parts_filters()[1][37].view()
Out[6]:
In [7]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(clm, path + 'PhD/Models/clm_lfpw_fast_dsift')