In [1]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

Load Results


In [73]:
from menpofast.feature import no_op, fast_dsift
from alabortijcv2015.utils import pickle_load

path = '/data/'
db = 'afw'
aam_type = 'PartsAAM'
features_type = no_op.__name__
#noise_std = [0, 0.02, 0.04, 0.06, 0.08]
noise_std = [0.04]
alphas = np.arange(0, 1.1, 0.1)

ssc = []
asc = []
bsc = []

for n in noise_std:
    for a in alphas:
        ssc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_SSC_' + db + '_' + str(n) + '_' + str(a))) 
        asc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_ASC_' + db + '_' + str(n) + '_' + str(a)))
        bsc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_BSC_' + db + '_' + str(n) + '_' + str(a)))


---------------------------------------------------------------------------
IOError                                   Traceback (most recent call last)
<ipython-input-73-2868604fb039> in <module>()
     16 for n in noise_std:
     17     for a in alphas:
---> 18         ssc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_SSC_' + db + '_' + str(n) + '_' + str(a)))
     19         asc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_ASC_' + db + '_' + str(n) + '_' + str(a)))
     20         bsc.append(pickle_load(path + 'PhD/Results/ijcv2015/exp4_' + aam_type + '_' + features_type +  '_BSC_' + db + '_' + str(n) + '_' + str(a)))

/data/pythondev/src/alabortijcv2015/alabortijcv2015/utils.pyc in pickle_load(path)
      5 
      6 def pickle_load(path):
----> 7     with open(str(path), 'rb') as f:
      8         return cPickle.load(f)
      9 

IOError: [Errno 2] No such file or directory: '/data/PhD/Results/ijcv2015/exp4_PartsAAM_no_op_SSC_afw_0.04_0.0'

In [64]:
results = [ssc, asc, bsc]

legend_entries = ['SSC', 'ASC', 'BSC']

Graph 1


In [65]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.final_error() for fr in frs]
        mean_error = np.mean(errors)
        mean_errors.append(mean_error)
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = alphas

In [66]:
plot(x_values, all_errors.T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Initialization')
ylabel('Mean Normalized Point-to-Point Error')


Out[66]:
<matplotlib.text.Text at 0x7fd2709a1f90>

Graph 2


In [9]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.errors() for fr in frs]
        mean_errors.append(np.mean(errors, axis=0))
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = xrange(0, fr.n_iters + 2)

In [14]:
n = 0

plot(x_values, all_errors[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Point-to-Point Error')


Out[14]:
<matplotlib.text.Text at 0x7fe57e922c10>

Graph 3


In [12]:
all_costs = []

for fitter_results in results:
    mean_costs = []
    for frs in fitter_results:
        costs = [fr.costs() for fr in frs]
        mean_costs.append(np.mean(costs, axis=0))
    all_costs.append(mean_costs)
    
all_costs = np.asarray(all_costs)
x_values = xrange(0, fr.n_iters)

In [13]:
n = 0

plot(x_values, all_costs[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Cost')


Out[13]:
<matplotlib.text.Text at 0x7f81d0ebe050>

Graph 4


In [26]:
sic = []
aic = []

for n in noise_std:
    sic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_SIC_' + db + '_' + str(n)))
    aic.append(pickle_load(path + 'PhD/Results/ijcv2015/exp2_' + aam_type + '_' + features_type +  '_AIC_' + db + '_' + str(n)))

In [28]:
results = [sic, aic, ssc, asc, bsc]

legend_entries = ['SIC', 'AIC', 'SSC', 'ASC', 'BSC']

In [29]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.final_error() for fr in frs]
        mean_error = np.mean(errors)
        mean_errors.append(mean_error)
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = noise_std

In [30]:
plot(x_values, all_errors.T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Initialization')
ylabel('Mean Normalized Point-to-Point Error')


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-30-54ae4efdb594> in <module>()
----> 1 plot(x_values, all_errors.T, linewidth=1, marker='o', ms=5)
      2 
      3 legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
      4 xlabel('Initialization')
      5 ylabel('Mean Normalized Point-to-Point Error')

/data/installed/anaconda/envs/menpo/lib/python2.7/site-packages/matplotlib/pyplot.pyc in plot(*args, **kwargs)
   3091         ax.hold(hold)
   3092     try:
-> 3093         ret = ax.plot(*args, **kwargs)
   3094         draw_if_interactive()
   3095     finally:

/data/installed/anaconda/envs/menpo/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in plot(self, *args, **kwargs)
   1371         lines = []
   1372 
-> 1373         for line in self._get_lines(*args, **kwargs):
   1374             self.add_line(line)
   1375             lines.append(line)

/data/installed/anaconda/envs/menpo/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _grab_next_args(self, *args, **kwargs)
    301                 return
    302             if len(remaining) <= 3:
--> 303                 for seg in self._plot_args(remaining, kwargs):
    304                     yield seg
    305                 return

/data/installed/anaconda/envs/menpo/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _plot_args(self, tup, kwargs)
    279             x = np.arange(y.shape[0], dtype=float)
    280 
--> 281         x, y = self._xy_from_xy(x, y)
    282 
    283         if self.command == 'plot':

/data/installed/anaconda/envs/menpo/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _xy_from_xy(self, x, y)
    221         y = np.atleast_1d(y)
    222         if x.shape[0] != y.shape[0]:
--> 223             raise ValueError("x and y must have same first dimension")
    224         if x.ndim > 2 or y.ndim > 2:
    225             raise ValueError("x and y can be no greater than 2-D")

ValueError: x and y must have same first dimension

Graph 5


In [18]:
all_errors = []

for fitter_results in results:
    mean_errors = []
    for frs in fitter_results:
        errors = [fr.errors() for fr in frs]
        mean_errors.append(np.mean(errors, axis=0))
    all_errors.append(mean_errors)
    
all_errors = np.asarray(all_errors)
x_values = xrange(0, fr.n_iters + 2)

In [19]:
n = 0

plot(x_values, all_errors[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Point-to-Point Error')


Out[19]:
<matplotlib.text.Text at 0x7f81d4b8a6d0>

Graph 6


In [20]:
all_costs = []

for fitter_results in results:
    mean_costs = []
    for frs in fitter_results:
        costs = [fr.costs() for fr in frs]
        mean_costs.append(np.mean(costs, axis=0))
    all_costs.append(mean_costs)
    
all_costs = np.asarray(all_costs)
x_values = xrange(0, fr.n_iters)

In [21]:
n = 0

plot(x_values, all_costs[:, n].T, linewidth=1, marker='o', ms=5)

legend(legend_entries, bbox_to_anchor=(1.3, 1.025))
xlabel('Iteration')
ylabel('Mean Normalized Cost')


Out[21]:
<matplotlib.text.Text at 0x7f81d206b350>

Graph 7


In [35]:



Out[35]:
1

In [48]:
n = 7

errors = [[fr.initial_error() for fr in results[3][n]]]
for fitter_results in results[2:]:
    errors.append([fr.final_error() for fr in fitter_results[n]])

In [49]:
from menpofit.visualize import plot_ced


legend_entries2 = ['Ini'] + legend_entries

plot_ced(errors, legend_entries=legend_entries2)


Fitting Statistics


In [50]:
from __future__ import division

print '\t', 'Mean \t', 'STD \t', 'Median \t', 'Convergence \t'

for err, method in zip(errors, legend_entries2):
    print method, '\t', 
    print np.round(np.mean(err), decimals=4), '\t', 
    print np.round(np.std(err), decimals=4), '\t', 
    print np.round(np.median(err), decimals=4), '\t',
    
    c = 0
    for e, ini_e in zip(err, errors[0]):
        if e < ini_e:
            c+=1
        
    print np.round(c / len(err), decimals=4)


	Mean 	STD 	Median 	Convergence 	
Ini 	0.0895 	0.0266 	0.0873 	0.0
SIC 	0.0345 	0.0205 	0.0287 	0.9852
AIC 	0.0347 	0.0209 	0.0286 	0.9852
SSC 	0.0337 	0.0177 	0.0288 	0.997

In [ ]: