In [1]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Load training data


In [2]:
import menpo.io as mio
from menpo.landmark import labeller, streetscene_car_view_0
from menpofast.utils import convert_from_menpo

group = 'streetscene_car_view_0'

training_images = []
for i in mio.import_images('/data/PhD/DataBases/cars/cmu_car_data1/view0/',
                           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(1, 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)


- Loading 466 assets: [====================] 100%

In [9]:
training_images = training_images[::2]

In [10]:
from menpo.visualize import visualize_images

visualize_images(training_images)


Active Appearance Models

Build


In [15]:
from menpofast.feature import no_op, fast_dsift, fast_daisy
from alabortcvpr2015.aam import PartsAAMBuilder

aam = PartsAAMBuilder(parts_shape=(17, 17),
                 features=fast_dsift,
                 diagonal=100,
                 normalize_parts=False,
                 scales=(1, .5),
                 max_shape_components=25,
                 max_appearance_components=250).build(training_images,
                                                      group=group,
                                                      verbose=True)


- Building models
  - Level 0: Done
  - Level 1: Done

In [17]:
from menpofast.image import Image

Image(aam.appearance_models[0].mean().pixels[5, 0]).view()


Out[17]:
<menpo.visualize.viewmatplotlib.MatplotlibImageSubplotsViewer2d at 0x7faf141c2d90>

Save


In [18]:
from alabortcvpr2015.utils import pickle_dump

pickle_dump(aam, '/data/PhD/Models/aam_view0_fast_dsift')