示例#1
0
# 5 feature spaces
normals = dict(zip(celebrity_subjects, [{}, {}, {}, {}, {}, {}, {}]))
for s in normals.values():
    s.update(zip(feature_spaces, [None] * len(feature_spaces)))

for i, subject_id in enumerate(celebrity_subjects):
    print "Running experiment for {0}".format(subject_id)

    subject_image = auto_import(
        '/home/pts08/research/sfs/celebrities/{0}.png'.format(subject_id))[0]

    # Choose the third image as the reconstruction candidate
    intensity_image = subject_image.as_greyscale()

    # Label with correct labels
    labeller([intensity_image], 'PTS', ibug_68_closed_mouth)

    # Constrain to mask
    intensity_image.constrain_mask_to_landmarks(
        group='ibug_68_closed_mouth', label='all')

    temp_texture = subject_image

    for k, feature_space in enumerate(feature_spaces):
        print "Running {0} for {1}".format(feature_space, subject_id)
        model_path = '/vol/atlas/pts08/cvpr/frgc_spring2003_sfs_tps_{0}_{1}.pkl'.format(subject_id, feature_space)
        with open(model_path, 'rb') as f:
            model = cPickle.load(f)

        normal_model = model['appearance_model']
        reference_frame = model['template']
示例#2
0
from pybug.image import MaskedNDImage
from pybug.io import auto_import
from pybug.landmark import labeller, ibug_68_closed_mouth
from landmarks import ibug_68_edge

sfs_index = 2
bej = auto_import("/vol/atlas/databases/alex_images/bej*.ppm")
# Create a 4 channel image where each channel is the greyscale of an image
ground_truth_images = MaskedNDImage(np.concatenate([im.as_greyscale().pixels for im in bej], axis=2))
intensity_image = bej[sfs_index].as_greyscale()

intensity_image.landmarks = bej[0].landmarks
ground_truth_images.landmarks["PTS"] = bej[0].landmarks["PTS"]

labeller([ground_truth_images, intensity_image], "PTS", ibug_68_closed_mouth)
# labeller([ground_truth_images, intensity_image], 'PTS', ibug_68_edge)

lights = np.array([[0.5, 0.4, 2], [-0.5, 0.4, 2], [-0.5, -0.4, 2], [0.5, -0.4, 2]])

# <codecell>

from pybug.transform.tps import TPS
from warp import build_similarity_transform

# tr = build_similarity_transform(intensity_image.landmarks['ibug_68_edge'].lms)
tr = TPS(reference_frame.landmarks["ibug_68_closed_mouth"].lms, intensity_image.landmarks["ibug_68_closed_mouth"].lms)

# <codecell>

from pybug.transform import SimilarityTransform
示例#3
0
from pybug.image import MaskedNDImage
from pybug.io import auto_import
from pybug.landmark import labeller, ibug_68_closed_mouth
from landmarks import ibug_68_edge

sfs_index = 2
bej = auto_import('/vol/atlas/databases/alex_images/bej*.ppm')
# Create a 4 channel image where each channel is the greyscale of an image
ground_truth_images = MaskedNDImage(
    np.concatenate([im.as_greyscale().pixels for im in bej], axis=2))
intensity_image = bej[sfs_index].as_greyscale()

intensity_image.landmarks = bej[0].landmarks
ground_truth_images.landmarks['PTS'] = bej[0].landmarks['PTS']

labeller([ground_truth_images, intensity_image], 'PTS', ibug_68_closed_mouth)
# labeller([ground_truth_images, intensity_image], 'PTS', ibug_68_edge)

lights = np.array([[0.5, 0.4, 2], [-0.5, 0.4, 2], [-0.5, -0.4, 2],
                   [0.5, -0.4, 2]])

# <codecell>

from pybug.transform.tps import TPS
from warp import build_similarity_transform
# tr = build_similarity_transform(intensity_image.landmarks['ibug_68_edge'].lms)
tr = TPS(reference_frame.landmarks['ibug_68_closed_mouth'].lms,
         intensity_image.landmarks['ibug_68_closed_mouth'].lms)

# <codecell>