In [ ]:
%matplotlib inline
%pylab inline
In [ ]:
repeat = 1
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'
test_images = []
for i in mio.import_images(path + 'PhD/DataBases/faces/cofw/testset/', 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')
test_images.append(i)
In [ ]:
from menpo.visualize import visualize_images
visualize_images(test_images)
In [ ]:
from alabortcvpr2015.utils import pickle_load
clm = pickle_load(path + 'PhD/Models/clm_cofw_fast_dsift')
In [ ]:
from alabortcvpr2015.clm import CLMFitter, RLMS
from alabortcvpr2015.utils import pickle_dump
from alabortcvpr2015.result import SerializableResult
fitter = CLMFitter(clm, algorithm_cls=RLMS, n_shape=[3, 12])
fitter_results = []
for seed in xrange(repeat):
np.random.seed(seed=seed)
for j, i in enumerate(test_images):
gt_s = i.landmarks[group].lms
s = fitter.perturb_shape(gt_s, noise_std=0.05)
fr = fitter.fit(i, s, gt_shape=gt_s, max_iters=20, prior=False)
fitter_results.append(fr)
fr.downscale = 0.5
print 'Image: ', j
print fr
results = [SerializableResult('none', fr.shapes(), fr.n_iters, 'RLMS', fr.gt_shape)
for fr in fitter_results]
pickle_dump(results, path + 'PhD/Results/clm_rlms_cofw_fast_dsift')
In [ ]:
np.mean([fr.final_error(error_type='rmse') for fr in fitter_results])
In [ ]:
from menpofit.visualize import visualize_fitting_results
visualize_fitting_results(fitter_results)