#NEWLINE# def ck_lm_pwa( datadir = None , ck_dataset = None , labeled_only = False ) : #NEWLINE# #INDENT# '\n    Subset of Cohn-Kanade dataset with face landmarks as X1,\n    faces, aligend to a mean shape, as X2, and labels as y\n    ' #NEWLINE# if ( not ck_dataset ) : #NEWLINE# #INDENT# ck_dataset = CKDataset ( datadir ) #NEWLINE# #UNINDENT# ref_lms = ck_dataset . data [ 10 ] . landmarks [ 0 ] #NEWLINE# triangles = delaunay ( ref_lms ) #NEWLINE# X1_lst = [ ] #NEWLINE# X2_lst = [ ] #NEWLINE# y_lst = [ ] #NEWLINE# for item in ck_dataset . data : #NEWLINE# #INDENT# landmarks = item . landmarks [ ( - 1 ) ] #NEWLINE# X1_lst . append ( landmarks . flatten ( ) ) #NEWLINE# orig_image = item . images [ ( - 1 ) ] #NEWLINE# item_lms = item . landmarks [ ( - 1 ) ] #NEWLINE# image = pwa . warpTriangle ( orig_image , item_lms [ : , [ 1 , 0 ] ] , ref_lms [ : , [ 1 , 0 ] ] , triangles , orig_image . shape ) #NEWLINE# X2_lst . append ( image . flatten ( ) ) #NEWLINE# y_lst . append ( item . label ) #NEWLINE# #UNINDENT# X1 = np . vstack ( X1_lst ) #NEWLINE# X2 = np . vstack ( X2_lst ) #NEWLINE# y = np . array ( y_lst ) #NEWLINE# del ck_dataset #NEWLINE# if labeled_only : #NEWLINE# #INDENT# return ( X1 [ ( y != ( - 1 ) ) ] , X2 [ ( y != ( - 1 ) ) ] , y [ ( y != ( - 1 ) ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( X1 , X2 , y )