In [ ]:
%matplotlib inline
%pylab inline
In [ ]:
import menpo.io as mio
from menpo.landmark import labeller, streetscene_car_view_1
from menpofast.utils import convert_from_menpo
path = '/data/'
group = 'streetscene_car_view_1'
training_images = []
for i in mio.import_images(path + 'PhD/DataBases/cars/cmu_car_data1/view1/',
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.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 [ ]:
training_images = training_images[::2]
In [ ]:
from menpo.visualize import visualize_images
visualize_images(training_images)
In [ ]:
img = training_images[0].copy()
img = img.rescale_to_diagonal(50)
img = img.as_masked()
img.build_mask_around_landmarks((15, 15), group=group)
img.view_widget()
In [ ]:
img2 = img.copy()
img2 = img2.rescale(0.5)
img2 = img2.as_masked()
img2.build_mask_around_landmarks((15, 15), group=group)
img2.view_widget()
In [ ]:
from menpofast.feature import no_op, fast_dsift
parts_shape = (15, 15)
features = fast_dsift
diagonal = 50
normalize_parts = False
covariance = 3
scales = (1, .5)
max_shape_components = 25
max_appearance_components = 500
In [ ]:
from alabortcvpr2015.aam import PartsAAMBuilder
parts_aam = PartsAAMBuilder(
parts_shape=parts_shape,
features=features,
diagonal=diagonal,
normalize_parts=normalize_parts,
scales=scales,
max_shape_components=max_shape_components,
max_appearance_components=max_appearance_components).build(training_images,
group=group,
verbose=True)
In [ ]:
from menpofast.image import Image
Image(parts_aam.appearance_models[1].mean().pixels[8, 0]).view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(parts_aam, path + 'PhD/Models/parts_aam_view1_fast_dsift')
In [ ]:
from alabortcvpr2015.aam import GlobalAAMBuilder
global_aam = GlobalAAMBuilder(
features=features,
diagonal=diagonal,
scales=scales,
max_shape_components=max_shape_components,
max_appearance_components=max_appearance_components).build(training_images,
group=group,
verbose=True)
In [ ]:
global_aam.appearance_models[1].mean().view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(global_aam, path + 'PhD/Models/global_aam_view1_fast_dsift')
In [ ]:
from alabortcvpr2015.clm import CLMBuilder
clm = CLMBuilder(
parts_shape=parts_shape,
features=features,
diagonal=diagonal,
normalize_parts=normalize_parts,
covariance=covariance,
scales=scales,
max_shape_components=max_shape_components).build(training_images,
group=group,
verbose=True)
In [ ]:
clm.parts_filters()[1][8].view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(clm, path + 'PhD/Models/clm_view1_fast_dsift')
In [ ]:
from alabortcvpr2015.unified import PartsUnifiedBuilder
parts_unified = PartsUnifiedBuilder(
parts_shape=parts_shape,
features=features,
diagonal=diagonal,
normalize_parts=normalize_parts,
covariance=covariance,
scales=scales,
max_shape_components=max_shape_components,
max_appearance_components=max_appearance_components).build(training_images,
group=group,
verbose=True)
In [ ]:
from menpofast.image import Image
Image(parts_unified.appearance_models[1].mean().pixels[8, 0]).view()
In [ ]:
parts_unified.parts_filters()[1][8].view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(parts_unified, path + 'PhD/Models/parts_unified_view1_fast_dsift')
In [ ]:
from menpofast.feature import no_op, fast_dsift, fast_daisy
from alabortcvpr2015.unified import GlobalUnifiedBuilder
global_unified = GlobalUnifiedBuilder(
parts_shape=parts_shape,
features=features,
diagonal=diagonal,
normalize_parts=normalize_parts,
covariance=covariance,
scales=scales,
max_shape_components=max_shape_components,
max_appearance_components=max_appearance_components).build(training_images,
group=group,
verbose=True)
In [ ]:
global_unified.appearance_models[1].mean().view()
In [ ]:
parts_unified.parts_filters()[1][8].view()
In [ ]:
from alabortcvpr2015.utils import pickle_dump
pickle_dump(global_unified, path + 'PhD/Models/global_unified_view1_fast_dsift')