<commit_before>import numpy as np
from scipy.spatial import distance
from ibugMM.importer.model import import_face
import matplotlib.pyplot as plt
from mayavi import mlab
from ibugMM.mesh.face import Face
plt.interactive(True)

def print_geodesic_patterns(phi_coords, i):
  distances = distance.pdist(phi_coords[:,0:i], 'cityblock')
  plt.figure()
  fig = plt.gcf()
  plt.hist(distances, bins=1000, histtype='stepfilled', range=(0,500))
  fig.savefig('full_' + `i` + '.pdf')
  plt.figure()
  fig = plt.gcf()
  small_distances = distances[np.where(distances < 5)]
  plt.hist(small_distances, bins=1000, histtype='stepfilled', range=(0,5))
  fig.savefig('near0_' + `i` + '.pdf')

def gen_phi_coords(face, method='heat'):
  phi_m = face.geodesics_about_lm('mouth', method)['phi']
  phi_n = face.geodesics_about_lm('nose', method)['phi']
  phi_l = face.geodesics_about_lm('l_eye', method)['phi']
  phi_r = face.geodesics_about_lm('r_eye', method)['phi']
  # ph_coords s.t. phi_coords[0] is the geodesic vector for the first ordinate
  return np.vstack((phi_m, phi_n, phi_l, phi_r)).T

## ioannis face
ioannis_path_1 = '/home/jab08/Dropbox/testData/ioannis_1.obj'
o_ioannis_1 = import_face(ioannis_path_1)
ioannis_path_2 = '/home/jab08/Dropbox/testData/ioannis_2.obj'
o_ioannis_2 = import_face(ioannis_path_2)

## note, l_eye is THEIR l_eye (right as we look at it)
o_ioannis_1.landmarks['nose']  = [17537]
o_ioannis_1.landmarks['l_eye'] = [5695]
o_ioannis_1.landmarks['r_eye'] = [5495]
o_ioannis_1.landmarks['mouth'] = [15461, 18940, 12249, 17473, 36642, 2889, 11560, 10125]
o_ioannis_1.landmarks['cheek_freckle'] = [752]

o_ioannis_2.landmarks['nose']  = [10476]
o_ioannis_2.landmarks['l_eye'] = [40615]
o_ioannis_2.landmarks['r_eye'] = [40526]
o_ioannis_2.landmarks['mouth'] = [41366, 28560, 36719, 17657, 13955, 26988, 6327, 8229]
o_ioannis_2.landmarks['cheek_freckle'] = [32294]

ioannis_1  = o_ioannis_1.new_face_masked_from_lm('nose', method='exact')
ioannis_2  = o_ioannis_2.new_face_masked_from_lm('nose', method='exact')



# james face
#        .   .   .
#    .                 .
#        .   .   .
#<commit_msg>few more james landmarks done<commit_after>import numpy as np
from scipy.spatial import distance
from ibugMM.importer.model import import_face
import matplotlib.pyplot as plt
from mayavi import mlab
from ibugMM.mesh.face import Face
plt.interactive(True)

def print_geodesic_patterns(phi_coords, i):
  distances = distance.pdist(phi_coords[:,0:i], 'cityblock')
  plt.figure()
  fig = plt.gcf()
  plt.hist(distances, bins=1000, histtype='stepfilled', range=(0,500))
  fig.savefig('full_' + `i` + '.pdf')
  plt.figure()
  fig = plt.gcf()
  small_distances = distances[np.where(distances < 5)]
  plt.hist(small_distances, bins=1000, histtype='stepfilled', range=(0,5))
  fig.savefig('near0_' + `i` + '.pdf')

def gen_phi_coords(face, method='heat'):
  phi_m = face.geodesics_about_lm('mouth', method)['phi']
  phi_n = face.geodesics_about_lm('nose', method)['phi']
  phi_l = face.geodesics_about_lm('l_eye', method)['phi']
  phi_r = face.geodesics_about_lm('r_eye', method)['phi']
  # ph_coords s.t. phi_coords[0] is the geodesic vector for the first ordinate
  return np.vstack((phi_m, phi_n, phi_l, phi_r)).T

## ioannis face
ioannis_path_1 = '/home/jab08/Dropbox/testData/ioannis_1.obj'
o_ioannis_1 = import_face(ioannis_path_1)
ioannis_path_2 = '/home/jab08/Dropbox/testData/ioannis_2.obj'
o_ioannis_2 = import_face(ioannis_path_2)

## note, l_eye is THEIR l_eye (right as we look at it)
o_ioannis_1.landmarks['nose']  = [17537]
o_ioannis_1.landmarks['l_eye'] = [5695]
o_ioannis_1.landmarks['r_eye'] = [5495]
o_ioannis_1.landmarks['mouth'] = [15461, 18940, 12249, 17473, 36642, 2889, 11560, 10125]
o_ioannis_1.landmarks['cheek_freckle'] = [752]

o_ioannis_2.landmarks['nose']  = [10476]
o_ioannis_2.landmarks['l_eye'] = [40615]
o_ioannis_2.landmarks['r_eye'] = [40526]
o_ioannis_2.landmarks['mouth'] = [41366, 28560, 36719, 17657, 13955, 26988, 6327, 8229]
o_ioannis_2.landmarks['cheek_freckle'] = [32294]

ioannis_1  = o_ioannis_1.new_face_masked_from_lm('nose', method='exact')
ioannis_2  = o_ioannis_2.new_face_masked_from_lm('nose', method='exact')



# james face
#        .   .   .
#    .                 .
#        .   .   .
#
m_l = 10706
m_r = 29522
m_t = 16243
m_b = 14945
:e i
james_smile.landmarks['mouth'] = [m_l, m_r, m_mt, m_mb]
{'fraction_non_alphanumeric': 0.15225865627149737, 'fraction_numerical': 0.07658793854620499, 'mean_word_length': 5.231428571428571, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7627034', 'n_tokens_mistral': 2122, 'n_tokens_neox': 1869, 'n_words': 315}