In [1]:
%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 = '/Users/joan/'
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(150, 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(150, 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(150, 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 [3]:
from menpofit.transform import DifferentiablePiecewiseAffine
from menpofast.feature import no_op
from alabortijcv2015.aam import GlobalAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = GlobalAAMBuilder(transform=DifferentiablePiecewiseAffine,
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_global_pwa_int')
In [4]:
from menpofit.transform import DifferentiableThinPlateSplines
from menpofast.feature import no_op
from alabortijcv2015.aam import GlobalAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = GlobalAAMBuilder(transform=DifferentiableThinPlateSplines,
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_global_tps_int')
In [5]:
from menpofast.feature import no_op
from alabortijcv2015.aam import PatchAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = PatchAAMBuilder(patch_shape=(17, 17),
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_patch_int')
In [6]:
from menpofit.transform import DifferentiablePiecewiseAffine
from menpofast.feature import no_op
from alabortijcv2015.aam import LinearGlobalAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = LinearGlobalAAMBuilder(transform=DifferentiablePiecewiseAffine,
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_linear_global_pwa_int')
In [7]:
from menpofit.transform import DifferentiableThinPlateSplines
from menpofast.feature import no_op
from alabortijcv2015.aam import LinearGlobalAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = LinearGlobalAAMBuilder(transform=DifferentiableThinPlateSplines,
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_linear_global_tps_int')
In [8]:
from menpofast.feature import no_op
from alabortijcv2015.aam import LinearPatchAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = LinearPatchAAMBuilder(patch_shape=(17, 17),
features=no_op,
diagonal=120,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_linear_patch_int')
In [5]:
from menpofast.feature import no_op
from alabortijcv2015.aam import PartsAAMBuilder
from alabortijcv2015.utils import pickle_dump
aam = PartsAAMBuilder(parts_shape=(17, 17),
features=no_op,
diagonal=120,
normalize_parts=False,
scales=(1, .5),
max_shape_components=25,
max_appearance_components=250).build(training_images,
group=group,
verbose=True)
pickle_dump(aam, path + 'PhD/Models/ijcv2015/exp1_parts_int')