In [1]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [2]:
repeat = 1

Load test data


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

path = '/data/'
group = 'ibug_face_49'

test_images = []
for i in mio.import_images(path + 'PhD/DataBases/faces/lfpw/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)


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

In [4]:
from menpo.visualize import visualize_images

visualize_images(test_images)


AAMs

Load


In [5]:
from alabortcvpr2015.utils import pickle_load

aam = pickle_load(path + 'PhD/Models/global_aam_lfpw_fast_dsift')

AIC


In [6]:
from alabortcvpr2015.aam import GlobalAAMFitter, AIC
                  
fitter = GlobalAAMFitter(aam, algorithm_cls=AIC, n_shape=[3, 12],
                        n_appearance=[25, 50], sampling_step=4)

In [7]:
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


Image:  0
Initial error: 0.1847
Final error: 0.0484
Image:  1
Initial error: 0.1086
Final error: 0.0126
Image:  2
Initial error: 0.0730
Final error: 0.0303
Image:  3
Initial error: 0.0574
Final error: 0.0202
Image:  4
Initial error: 0.0662
Final error: 0.0367
Image:  5
Initial error: 0.1399
Final error: 0.0706
Image:  6
Initial error: 0.0868
Final error: 0.0161
Image:  7
Initial error: 0.1125
Final error: 0.0373
Image:  8
Initial error: 0.0627
Final error: 0.0161
Image:  9
Initial error: 0.0298
Final error: 0.0200
Image:  10
Initial error: 0.1454
Final error: 0.0785
Image:  11
Initial error: 0.0880
Final error: 0.0169
Image:  12
Initial error: 0.1057
Final error: 0.0286
Image:  13
Initial error: 0.0356
Final error: 0.0133
Image:  14
Initial error: 0.0950
Final error: 0.0138
Image:  15
Initial error: 0.1339
Final error: 0.0170
Image:  16
Initial error: 0.0899
Final error: 0.0176
Image:  17
Initial error: 0.0720
Final error: 0.0299
Image:  18
Initial error: 0.0629
Final error: 0.0260
Image:  19
Initial error: 0.0592
Final error: 0.0270
Image:  20
Initial error: 0.1301
Final error: 0.0186
Image:  21
Initial error: 0.1056
Final error: 0.0232
Image:  22
Initial error: 0.0790
Final error: 0.0154
Image:  23
Initial error: 0.0511
Final error: 0.0185
Image:  24
Initial error: 0.0600
Final error: 0.0223
Image:  25
Initial error: 0.1091
Final error: 0.0253
Image:  26
Initial error: 0.1060
Final error: 0.0184
Image:  27
Initial error: 0.1797
Final error: 0.1262
Image:  28
Initial error: 0.0524
Final error: 0.0251
Image:  29
Initial error: 0.0953
Final error: 0.0161
Image:  30
Initial error: 0.0817
Final error: 0.0167
Image:  31
Initial error: 0.0857
Final error: 0.0145
Image:  32
Initial error: 0.0625
Final error: 0.0202
Image:  33
Initial error: 0.0688
Final error: 0.0247
Image:  34
Initial error: 0.0741
Final error: 0.0346
Image:  35
Initial error: 0.0680
Final error: 0.0220
Image:  36
Initial error: 0.1298
Final error: 0.0206
Image:  37
Initial error: 0.0789
Final error: 0.0178
Image:  38
Initial error: 0.0822
Final error: 0.0194
Image:  39
Initial error: 0.0792
Final error: 0.0590
Image:  40
Initial error: 0.0983
Final error: 0.0205
Image:  41
Initial error: 0.1618
Final error: 0.0262
Image:  42
Initial error: 0.0968
Final error: 0.0275
Image:  43
Initial error: 0.0800
Final error: 0.0626
Image:  44
Initial error: 0.0682
Final error: 0.0229
Image:  45
Initial error: 0.1432
Final error: 0.0284
Image:  46
Initial error: 0.0803
Final error: 0.0312
Image:  47
Initial error: 0.0908
Final error: 0.0143
Image:  48
Initial error: 0.0401
Final error: 0.0199
Image:  49
Initial error: 0.1610
Final error: 0.0207
Image:  50
Initial error: 0.0515
Final error: 0.0246
Image:  51
Initial error: 0.0543
Final error: 0.0314
Image:  52
Initial error: 0.0547
Final error: 0.0214
Image:  53
Initial error: 0.1048
Final error: 0.0711
Image:  54
Initial error: 0.1050
Final error: 0.0935
Image:  55
Initial error: 0.0816
Final error: 0.0225
Image:  56
Initial error: 0.0755
Final error: 0.0206
Image:  57
Initial error: 0.1143
Final error: 0.0183
Image:  58
Initial error: 0.0855
Final error: 0.0229
Image:  59
Initial error: 0.0919
Final error: 0.0165
Image:  60
Initial error: 0.0633
Final error: 0.0162
Image:  61
Initial error: 0.0770
Final error: 0.0565
Image:  62
Initial error: 0.0653
Final error: 0.0223
Image:  63
Initial error: 0.1445
Final error: 0.0231
Image:  64
Initial error: 0.1038
Final error: 0.0589
Image:  65
Initial error: 0.1567
Final error: 0.1429
Image:  66
Initial error: 0.0865
Final error: 0.0953
Image:  67
Initial error: 0.1748
Final error: 0.1443
Image:  68
Initial error: 0.0584
Final error: 0.0199
Image:  69
Initial error: 0.1486
Final error: 0.0725
Image:  70
Initial error: 0.0834
Final error: 0.0142
Image:  71
Initial error: 0.0859
Final error: 0.0369
Image:  72
Initial error: 0.0542
Final error: 0.0147
Image:  73
Initial error: 0.1554
Final error: 0.0209
Image:  74
Initial error: 0.0458
Final error: 0.0219
Image:  75
Initial error: 0.1024
Final error: 0.0186
Image:  76
Initial error: 0.0873
Final error: 0.0237
Image:  77
Initial error: 0.1316
Final error: 0.0177
Image:  78
Initial error: 0.0756
Final error: 0.0129
Image:  79
Initial error: 0.0315
Final error: 0.0202
Image:  80
Initial error: 0.0909
Final error: 0.0190
Image:  81
Initial error: 0.0870
Final error: 0.0199
Image:  82
Initial error: 0.0990
Final error: 0.0419
Image:  83
Initial error: 0.1552
Final error: 0.1091
Image:  84
Initial error: 0.1218
Final error: 0.0225
Image:  85
Initial error: 0.0552
Final error: 0.0406
Image:  86
Initial error: 0.0448
Final error: 0.0281
Image:  87
Initial error: 0.0861
Final error: 0.0155
Image:  88
Initial error: 0.0346
Final error: 0.0172
Image:  89
Initial error: 0.0908
Final error: 0.0259
Image:  90
Initial error: 0.0733
Final error: 0.0201
Image:  91
Initial error: 0.0553
Final error: 0.0244
Image:  92
Initial error: 0.0793
Final error: 0.0149
Image:  93
Initial error: 0.0526
Final error: 0.0133
Image:  94
Initial error: 0.0964
Final error: 0.0260
Image:  95
Initial error: 0.1957
Final error: 0.1703
Image:  96
Initial error: 0.1034
Final error: 0.0402
Image:  97
Initial error: 0.0916
Final error: 0.0215
Image:  98
Initial error: 0.0763
Final error: 0.0229
Image:  99
Initial error: 0.1203
Final error: 0.0199
Image:  100
Initial error: 0.0593
Final error: 0.0259
Image:  101
Initial error: 0.0919
Final error: 0.0326
Image:  102
Initial error: 0.0860
Final error: 0.0167
Image:  103
Initial error: 0.0853
Final error: 0.0451
Image:  104
Initial error: 0.1238
Final error: 0.0313
Image:  105
Initial error: 0.0939
Final error: 0.0163
Image:  106
Initial error: 0.1568
Final error: 0.0624
Image:  107
Initial error: 0.1161
Final error: 0.0649
Image:  108
Initial error: 0.0754
Final error: 0.0228
Image:  109
Initial error: 0.0615
Final error: 0.0191
Image:  110
Initial error: 0.0379
Final error: 0.0316
Image:  111
Initial error: 0.0810
Final error: 0.0227
Image:  112
Initial error: 0.0864
Final error: 0.0198
Image:  113
Initial error: 0.1303
Final error: 0.0268
Image:  114
Initial error: 0.0514
Final error: 0.0578
Image:  115
Initial error: 0.0537
Final error: 0.0128
Image:  116
Initial error: 0.1014
Final error: 0.0223
Image:  117
Initial error: 0.2082
Final error: 0.0858
Image:  118
Initial error: 0.0857
Final error: 0.0275
Image:  119
Initial error: 0.1389
Final error: 0.0235
Image:  120
Initial error: 0.1172
Final error: 0.0162
Image:  121
Initial error: 0.1187
Final error: 0.0486
Image:  122
Initial error: 0.0649
Final error: 0.0178
Image:  123
Initial error: 0.1760
Final error: 0.0598
Image:  124
Initial error: 0.0869
Final error: 0.0147
Image:  125
Initial error: 0.0677
Final error: 0.0186
Image:  126
Initial error: 0.1445
Final error: 0.0472
Image:  127
Initial error: 0.0794
Final error: 0.0580
Image:  128
Initial error: 0.0960
Final error: 0.0255
Image:  129
Initial error: 0.1203
Final error: 0.0379
Image:  130
Initial error: 0.1228
Final error: 0.0278
Image:  131
Initial error: 0.1002
Final error: 0.0251
Image:  132
Initial error: 0.1948
Final error: 0.1199
Image:  133
Initial error: 0.0612
Final error: 0.0178
Image:  134
Initial error: 0.0597
Final error: 0.0191
Image:  135
Initial error: 0.0936
Final error: 0.0352
Image:  136
Initial error: 0.1467
Final error: 0.0347
Image:  137
Initial error: 0.0828
Final error: 0.0437
Image:  138
Initial error: 0.1059
Final error: 0.0236
Image:  139
Initial error: 0.2043
Final error: 0.1464
Image:  140
Initial error: 0.0826
Final error: 0.0278
Image:  141
Initial error: 0.0361
Final error: 0.0237
Image:  142
Initial error: 0.1122
Final error: 0.0287
Image:  143
Initial error: 0.0557
Final error: 0.0193
Image:  144
Initial error: 0.0496
Final error: 0.0214
Image:  145
Initial error: 0.1429
Final error: 0.0241
Image:  146
Initial error: 0.0770
Final error: 0.0286
Image:  147
Initial error: 0.0534
Final error: 0.0270
Image:  148
Initial error: 0.0341
Final error: 0.0183
Image:  149
Initial error: 0.0829
Final error: 0.0206
Image:  150
Initial error: 0.1012
Final error: 0.0473
Image:  151
Initial error: 0.1540
Final error: 0.0512
Image:  152
Initial error: 0.1131
Final error: 0.0147
Image:  153
Initial error: 0.0473
Final error: 0.0263
Image:  154
Initial error: 0.1071
Final error: 0.0294
Image:  155
Initial error: 0.0357
Final error: 0.0293
Image:  156
Initial error: 0.0757
Final error: 0.0150
Image:  157
Initial error: 0.0610
Final error: 0.0227
Image:  158
Initial error: 0.0720
Final error: 0.0232
Image:  159
Initial error: 0.0709
Final error: 0.0272
Image:  160
Initial error: 0.0804
Final error: 0.0190
Image:  161
Initial error: 0.0709
Final error: 0.0259
Image:  162
Initial error: 0.1497
Final error: 0.0204
Image:  163
Initial error: 0.0722
Final error: 0.0401
Image:  164
Initial error: 0.1257
Final error: 0.0374
Image:  165
Initial error: 0.0414
Final error: 0.0288
Image:  166
Initial error: 0.0502
Final error: 0.0226
Image:  167
Initial error: 0.1911
Final error: 0.1288
Image:  168
Initial error: 0.1134
Final error: 0.0325
Image:  169
Initial error: 0.0632
Final error: 0.0176
Image:  170
Initial error: 0.0375
Final error: 0.0154
Image:  171
Initial error: 0.1844
Final error: 0.0734
Image:  172
Initial error: 0.0638
Final error: 0.0281
Image:  173
Initial error: 0.0798
Final error: 0.0309
Image:  174
Initial error: 0.0538
Final error: 0.0186
Image:  175
Initial error: 0.1046
Final error: 0.0386
Image:  176
Initial error: 0.0492
Final error: 0.0196
Image:  177
Initial error: 0.0754
Final error: 0.0203
Image:  178
Initial error: 0.0617
Final error: 0.0299
Image:  179
Initial error: 0.0669
Final error: 0.0226
Image:  180
Initial error: 0.0565
Final error: 0.0211
Image:  181
Initial error: 0.1021
Final error: 0.0655
Image:  182
Initial error: 0.0536
Final error: 0.0356
Image:  183
Initial error: 0.1725
Final error: 0.0518
Image:  184
Initial error: 0.0584
Final error: 0.0358
Image:  185
Initial error: 0.0894
Final error: 0.0233
Image:  186
Initial error: 0.0444
Final error: 0.0442
Image:  187
Initial error: 0.1490
Final error: 0.1074
Image:  188
Initial error: 0.0609
Final error: 0.0210
Image:  189
Initial error: 0.0809
Final error: 0.0194
Image:  190
Initial error: 0.0464
Final error: 0.0206
Image:  191
Initial error: 0.0511
Final error: 0.0250
Image:  192
Initial error: 0.0689
Final error: 0.0410
Image:  193
Initial error: 0.1389
Final error: 0.0170
Image:  194
Initial error: 0.0918
Final error: 0.0180
Image:  195
Initial error: 0.0948
Final error: 0.0294
Image:  196
Initial error: 0.0534
Final error: 0.0312
Image:  197
Initial error: 0.1021
Final error: 0.0486
Image:  198
Initial error: 0.1164
Final error: 0.0905
Image:  199
Initial error: 0.0607
Final error: 0.0197
Image:  200
Initial error: 0.0668
Final error: 0.0247
Image:  201
Initial error: 0.0642
Final error: 0.0246
Image:  202
Initial error: 0.1165
Final error: 0.0214
Image:  203
Initial error: 0.1328
Final error: 0.0225
Image:  204
Initial error: 0.1077
Final error: 0.0293
Image:  205
Initial error: 0.0660
Final error: 0.0257
Image:  206
Initial error: 0.0968
Final error: 0.0309
Image:  207
Initial error: 0.1018
Final error: 0.0245
Image:  208
Initial error: 0.0561
Final error: 0.0205
Image:  209
Initial error: 0.0567
Final error: 0.0391
Image:  210
Initial error: 0.1288
Final error: 0.0189
Image:  211
Initial error: 0.0566
Final error: 0.0181
Image:  212
Initial error: 0.1968
Final error: 0.0863
Image:  213
Initial error: 0.0903
Final error: 0.0176
Image:  214
Initial error: 0.1032
Final error: 0.0151
Image:  215
Initial error: 0.0553
Final error: 0.0184
Image:  216
Initial error: 0.0484
Final error: 0.0152
Image:  217
Initial error: 0.0866
Final error: 0.0174
Image:  218
Initial error: 0.0783
Final error: 0.0170
Image:  219
Initial error: 0.1155
Final error: 0.0659
Image:  220
Initial error: 0.0522
Final error: 0.0127
Image:  221
Initial error: 0.0653
Final error: 0.0154
Image:  222
Initial error: 0.0568
Final error: 0.0172
Image:  223
Initial error: 0.1383
Final error: 0.1161

Visualize Results


In [8]:
np.mean([fr.final_error() for fr in fitter_results])


Out[8]:
0.033488687997248419

In [10]:
from menpofit.visualize import visualize_fitting_results
    
visualize_fitting_results(fitter_results)


Save Results


In [11]:
from alabortcvpr2015.utils import pickle_dump
from alabortcvpr2015.result import SerializableResult

results = [SerializableResult('none', fr.shapes(), fr.n_iters, 'AIC', fr.gt_shape) 
           for fr in fitter_results]

pickle_dump(results, path + 'PhD/Results/aam_aic_lfpw_fast_dsift')

Timing

Total


In [12]:
%timeit fitter.fit(i, s, gt_shape=gt_s, max_iters=20)


10 loops, best of 3: 142 ms per loop

Per line


In [13]:
import line_profiler
import IPython

ip = IPython.get_ipython()
ip.define_magic('lprun', line_profiler.magic_lprun)

In [14]:
from alabortcvpr2015.aam import AIC

%lprun -f AIC.run fitter.fit(i, s, gt_shape=gt_s, max_iters=20)



PIC


In [6]:
from alabortcvpr2015.aam import GlobalAAMFitter, PIC
                  
fitter = GlobalAAMFitter(aam, algorithm_cls=PIC, n_shape=[3, 12], sampling_step=4)

In [7]:
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


Image:  0
Initial error: 0.1847
Final error: 0.0401
Image:  1
Initial error: 0.1086
Final error: 0.0809
Image:  2
Initial error: 0.0730
Final error: 0.0623
Image:  3
Initial error: 0.0574
Final error: 0.0191
Image:  4
Initial error: 0.0662
Final error: 0.0272
Image:  5
Initial error: 0.1399
Final error: 0.0188
Image:  6
Initial error: 0.0868
Final error: 0.0180
Image:  7
Initial error: 0.1125
Final error: 0.2393
Image:  8
Initial error: 0.0627
Final error: 0.0173
Image:  9
Initial error: 0.0298
Final error: 0.0283
Image:  10
Initial error: 0.1454
Final error: 0.1033
Image:  11
Initial error: 0.0880
Final error: 0.0207
Image:  12
Initial error: 0.1057
Final error: 0.0248
Image:  13
Initial error: 0.0356
Final error: 0.0143
Image:  14
Initial error: 0.0950
Final error: 0.0180
Image:  15
Initial error: 0.1339
Final error: 0.0230
Image:  16
Initial error: 0.0899
Final error: 0.0338
Image:  17
Initial error: 0.0720
Final error: 0.0657
Image:  18
Initial error: 0.0629
Final error: 0.0371
Image:  19
Initial error: 0.0592
Final error: 0.0761
Image:  20
Initial error: 0.1301
Final error: 0.0268
Image:  21
Initial error: 0.1056
Final error: 0.0647
Image:  22
Initial error: 0.0790
Final error: 0.0324
Image:  23
Initial error: 0.0511
Final error: 0.0419
Image:  24
Initial error: 0.0600
Final error: 0.0246
Image:  25
Initial error: 0.1091
Final error: 0.1783
Image:  26
Initial error: 0.1060
Final error: 0.0196
Image:  27
Initial error: 0.1797
Final error: 0.2798
Image:  28
Initial error: 0.0524
Final error: 0.0226
Image:  29
Initial error: 0.0953
Final error: 0.0163
Image:  30
Initial error: 0.0817
Final error: 0.0149
Image:  31
Initial error: 0.0857
Final error: 0.0261
Image:  32
Initial error: 0.0625
Final error: 0.0199
Image:  33
Initial error: 0.0688
Final error: 0.0344
Image:  34
Initial error: 0.0741
Final error: 0.0562
Image:  35
Initial error: 0.0680
Final error: 0.0420
Image:  36
Initial error: 0.1298
Final error: 0.0401
Image:  37
Initial error: 0.0789
Final error: 0.0261
Image:  38
Initial error: 0.0822
Final error: 0.0343
Image:  39
Initial error: 0.0792
Final error: 0.0639
Image:  40
Initial error: 0.0983
Final error: 0.0254
Image:  41
Initial error: 0.1618
Final error: 0.0279
Image:  42
Initial error: 0.0968
Final error: 0.1681
Image:  43
Initial error: 0.0800
Final error: 0.0573
Image:  44
Initial error: 0.0682
Final error: 0.1287
Image:  45
Initial error: 0.1432
Final error: 0.0316
Image:  46
Initial error: 0.0803
Final error: 0.0350
Image:  47
Initial error: 0.0908
Final error: 0.0136
Image:  48
Initial error: 0.0401
Final error: 0.0249
Image:  49
Initial error: 0.1610
Final error: 0.1741
Image:  50
Initial error: 0.0515
Final error: 0.0394
Image:  51
Initial error: 0.0543
Final error: 0.0716
Image:  52
Initial error: 0.0547
Final error: 0.0202
Image:  53
Initial error: 0.1048
Final error: 0.0726
Image:  54
Initial error: 0.1050
Final error: 0.1075
Image:  55
Initial error: 0.0816
Final error: 0.0250
Image:  56
Initial error: 0.0755
Final error: 0.0335
Image:  57
Initial error: 0.1143
Final error: 0.0220
Image:  58
Initial error: 0.0855
Final error: 0.0258
Image:  59
Initial error: 0.0919
Final error: 0.0192
Image:  60
Initial error: 0.0633
Final error: 0.0356
Image:  61
Initial error: 0.0770
Final error: 0.0925
Image:  62
Initial error: 0.0653
Final error: 0.0220
Image:  63
Initial error: 0.1445
Final error: 0.0224
Image:  64
Initial error: 0.1038
Final error: 0.0749
Image:  65
Initial error: 0.1567
Final error: 0.0900
Image:  66
Initial error: 0.0865
Final error: 0.1570
Image:  67
Initial error: 0.1748
Final error: 0.1264
Image:  68
Initial error: 0.0584
Final error: 0.0318
Image:  69
Initial error: 0.1486
Final error: 0.1165
Image:  70
Initial error: 0.0834
Final error: 0.0115
Image:  71
Initial error: 0.0859
Final error: 0.0368
Image:  72
Initial error: 0.0542
Final error: 0.0307
Image:  73
Initial error: 0.1554
Final error: 0.0276
Image:  74
Initial error: 0.0458
Final error: 0.0237
Image:  75
Initial error: 0.1024
Final error: 0.0173
Image:  76
Initial error: 0.0873
Final error: 0.0206
Image:  77
Initial error: 0.1316
Final error: 0.0592
Image:  78
Initial error: 0.0756
Final error: 0.0438
Image:  79
Initial error: 0.0315
Final error: 0.0231
Image:  80
Initial error: 0.0909
Final error: 0.0367
Image:  81
Initial error: 0.0870
Final error: 0.0196
Image:  82
Initial error: 0.0990
Final error: 0.0978
Image:  83
Initial error: 0.1552
Final error: 0.1464
Image:  84
Initial error: 0.1218
Final error: 0.0965
Image:  85
Initial error: 0.0552
Final error: 0.0278
Image:  86
Initial error: 0.0448
Final error: 0.0227
Image:  87
Initial error: 0.0861
Final error: 0.0348
Image:  88
Initial error: 0.0346
Final error: 0.0198
Image:  89
Initial error: 0.0908
Final error: 0.0412
Image:  90
Initial error: 0.0733
Final error: 0.0219
Image:  91
Initial error: 0.0553
Final error: 0.0460
Image:  92
Initial error: 0.0793
Final error: 0.0220
Image:  93
Initial error: 0.0526
Final error: 0.0243
Image:  94
Initial error: 0.0964
Final error: 0.0814
Image:  95
Initial error: 0.1957
Final error: 0.2100
Image:  96
Initial error: 0.1034
Final error: 0.0384
Image:  97
Initial error: 0.0916
Final error: 0.0205
Image:  98
Initial error: 0.0763
Final error: 0.0227
Image:  99
Initial error: 0.1203
Final error: 0.2384
Image:  100
Initial error: 0.0593
Final error: 0.0544
Image:  101
Initial error: 0.0919
Final error: 0.1155
Image:  102
Initial error: 0.0860
Final error: 0.0187
Image:  103
Initial error: 0.0853
Final error: 0.1194
Image:  104
Initial error: 0.1238
Final error: 0.0284
Image:  105
Initial error: 0.0939
Final error: 0.0682
Image:  106
Initial error: 0.1568
Final error: 0.1446
Image:  107
Initial error: 0.1161
Final error: 0.0895
Image:  108
Initial error: 0.0754
Final error: 0.0563
Image:  109
Initial error: 0.0615
Final error: 0.0240
Image:  110
Initial error: 0.0379
Final error: 0.0637
Image:  111
Initial error: 0.0810
Final error: 0.0317
Image:  112
Initial error: 0.0864
Final error: 0.0292
Image:  113
Initial error: 0.1303
Final error: 0.0567
Image:  114
Initial error: 0.0514
Final error: 0.0418
Image:  115
Initial error: 0.0537
Final error: 0.0264
Image:  116
Initial error: 0.1014
Final error: 0.0632
Image:  117
Initial error: 0.2082
Final error: 0.1058
Image:  118
Initial error: 0.0857
Final error: 0.0523
Image:  119
Initial error: 0.1389
Final error: 0.1422
Image:  120
Initial error: 0.1172
Final error: 0.0222
Image:  121
Initial error: 0.1187
Final error: 0.0957
Image:  122
Initial error: 0.0649
Final error: 0.0659
Image:  123
Initial error: 0.1760
Final error: 0.4215
Image:  124
Initial error: 0.0869
Final error: 0.0344
Image:  125
Initial error: 0.0677
Final error: 0.0160
Image:  126
Initial error: 0.1445
Final error: 0.0931
Image:  127
Initial error: 0.0794
Final error: 0.0844
Image:  128
Initial error: 0.0960
Final error: 0.0256
Image:  129
Initial error: 0.1203
Final error: 0.0931
Image:  130
Initial error: 0.1228
Final error: 0.0958
Image:  131
Initial error: 0.1002
Final error: 0.0263
Image:  132
Initial error: 0.1948
Final error: 0.0997
Image:  133
Initial error: 0.0612
Final error: 0.0594
Image:  134
Initial error: 0.0597
Final error: 0.0315
Image:  135
Initial error: 0.0936
Final error: 0.0247
Image:  136
Initial error: 0.1467
Final error: 0.3423
Image:  137
Initial error: 0.0828
Final error: 0.1048
Image:  138
Initial error: 0.1059
Final error: 0.0695
Image:  139
Initial error: 0.2043
Final error: 0.1695
Image:  140
Initial error: 0.0826
Final error: 0.0231
Image:  141
Initial error: 0.0361
Final error: 0.0186
Image:  142
Initial error: 0.1122
Final error: 0.0441
Image:  143
Initial error: 0.0557
Final error: 0.0364
Image:  144
Initial error: 0.0496
Final error: 0.0602
Image:  145
Initial error: 0.1429
Final error: 0.0359
Image:  146
Initial error: 0.0770
Final error: 0.0443
Image:  147
Initial error: 0.0534
Final error: 0.0312
Image:  148
Initial error: 0.0341
Final error: 0.0308
Image:  149
Initial error: 0.0829
Final error: 0.0538
Image:  150
Initial error: 0.1012
Final error: 0.0214
Image:  151
Initial error: 0.1540
Final error: 0.0588
Image:  152
Initial error: 0.1131
Final error: 0.0199
Image:  153
Initial error: 0.0473
Final error: 0.0225
Image:  154
Initial error: 0.1071
Final error: 0.0745
Image:  155
Initial error: 0.0357
Final error: 0.0328
Image:  156
Initial error: 0.0757
Final error: 0.0191
Image:  157
Initial error: 0.0610
Final error: 0.0219
Image:  158
Initial error: 0.0720
Final error: 0.0239
Image:  159
Initial error: 0.0709
Final error: 0.0443
Image:  160
Initial error: 0.0804
Final error: 0.0321
Image:  161
Initial error: 0.0709
Final error: 0.0689
Image:  162
Initial error: 0.1497
Final error: 0.0387
Image:  163
Initial error: 0.0722
Final error: 0.0507
Image:  164
Initial error: 0.1257
Final error: 0.1596
Image:  165
Initial error: 0.0414
Final error: 0.0755
Image:  166
Initial error: 0.0502
Final error: 0.0433
Image:  167
Initial error: 0.1911
Final error: 0.0218
Image:  168
Initial error: 0.1134
Final error: 0.0694
Image:  169
Initial error: 0.0632
Final error: 0.0232
Image:  170
Initial error: 0.0375
Final error: 0.0145
Image:  171
Initial error: 0.1844
Final error: 0.2013
Image:  172
Initial error: 0.0638
Final error: 0.0275
Image:  173
Initial error: 0.0798
Final error: 0.0630
Image:  174
Initial error: 0.0538
Final error: 0.0184
Image:  175
Initial error: 0.1046
Final error: 0.1415
Image:  176
Initial error: 0.0492
Final error: 0.0594
Image:  177
Initial error: 0.0754
Final error: 0.0201
Image:  178
Initial error: 0.0617
Final error: 0.0245
Image:  179
Initial error: 0.0669
Final error: 0.0330
Image:  180
Initial error: 0.0565
Final error: 0.0360
Image:  181
Initial error: 0.1021
Final error: 0.1041
Image:  182
Initial error: 0.0536
Final error: 0.0262
Image:  183
Initial error: 0.1725
Final error: 0.2807
Image:  184
Initial error: 0.0584
Final error: 0.0427
Image:  185
Initial error: 0.0894
Final error: 0.2010
Image:  186
Initial error: 0.0444
Final error: 0.0385
Image:  187
Initial error: 0.1490
Final error: 0.0794
Image:  188
Initial error: 0.0609
Final error: 0.0250
Image:  189
Initial error: 0.0809
Final error: 0.0162
Image:  190
Initial error: 0.0464
Final error: 0.0260
Image:  191
Initial error: 0.0511
Final error: 0.0254
Image:  192
Initial error: 0.0689
Final error: 0.0503
Image:  193
Initial error: 0.1389
Final error: 0.0164
Image:  194
Initial error: 0.0918
Final error: 0.0198
Image:  195
Initial error: 0.0948
Final error: 0.0817
Image:  196
Initial error: 0.0534
Final error: 0.0240
Image:  197
Initial error: 0.1021
Final error: 0.0426
Image:  198
Initial error: 0.1164
Final error: 0.1499
Image:  199
Initial error: 0.0607
Final error: 0.0225
Image:  200
Initial error: 0.0668
Final error: 0.0421
Image:  201
Initial error: 0.0642
Final error: 0.0353
Image:  202
Initial error: 0.1165
Final error: 0.0441
Image:  203
Initial error: 0.1328
Final error: 0.0487
Image:  204
Initial error: 0.1077
Final error: 0.0517
Image:  205
Initial error: 0.0660
Final error: 0.0442
Image:  206
Initial error: 0.0968
Final error: 0.0366
Image:  207
Initial error: 0.1018
Final error: 0.0198
Image:  208
Initial error: 0.0561
Final error: 0.0286
Image:  209
Initial error: 0.0567
Final error: 0.0485
Image:  210
Initial error: 0.1288
Final error: 0.0602
Image:  211
Initial error: 0.0566
Final error: 0.0263
Image:  212
Initial error: 0.1968
Final error: 0.0860
Image:  213
Initial error: 0.0903
Final error: 0.0796
Image:  214
Initial error: 0.1032
Final error: 0.0169
Image:  215
Initial error: 0.0553
Final error: 0.0195
Image:  216
Initial error: 0.0484
Final error: 0.0155
Image:  217
Initial error: 0.0866
Final error: 0.0173
Image:  218
Initial error: 0.0783
Final error: 0.0180
Image:  219
Initial error: 0.1155
Final error: 0.0256
Image:  220
Initial error: 0.0522
Final error: 0.0159
Image:  221
Initial error: 0.0653
Final error: 0.0171
Image:  222
Initial error: 0.0568
Final error: 0.0192
Image:  223
Initial error: 0.1383
Final error: 0.0757

Visualize Results


In [18]:
from menpofit.visualize import visualize_fitting_results
    
visualize_fitting_results(fitter_results)


Save Results


In [19]:
from alabortcvpr2015.utils import pickle_dump
from alabortcvpr2015.result import SerializableResult

results = [SerializableResult('none', fr.shapes(), fr.n_iters, 'PIC', fr.gt_shape) 
           for fr in fitter_results]

pickle_dump(results, path + 'PhD/Results/aam_pic_lfpw_fast_dsift')

Timing

Total


In [20]:
%timeit fitter.fit(i, s, gt_shape=gt_s, max_iters=20)


10 loops, best of 3: 53.6 ms per loop

Per line


In [21]:
import line_profiler
import IPython

ip = IPython.get_ipython()
ip.define_magic('lprun', line_profiler.magic_lprun)

In [22]:
from alabortcvpr2015.aam import PIC

%lprun -f PIC.run fitter.fit(i, s, gt_shape=gt_s, max_iters=20)