diff --git a/bob/db/cuhk/all-cuhk.lst b/bob/db/cuhk/all-cuhk.lst
deleted file mode 100644
index 07a5976726f946848d69fab8226d1b1396bba464..0000000000000000000000000000000000000000
--- a/bob/db/cuhk/all-cuhk.lst
+++ /dev/null
@@ -1,376 +0,0 @@
-photos/f-005-01 f005
-sketches/F2-005-01-sz1 f005
-photos/f-006-01 f006
-sketches/F2-006-01-sz1 f006
-photos/f-007-01 f007
-sketches/F2-007-01-sz1 f007
-photos/f-008-01 f008
-sketches/F2-008-01-sz1 f008
-photos/f-009-01 f009
-sketches/F2-009-01-sz1 f009
-photos/f-010-01 f010
-sketches/F2-010-01-sz1 f010
-photos/f-011-01 f011
-sketches/F2-011-01-sz1 f011
-photos/f-012-01 f012
-sketches/F2-012-01-sz1 f012
-photos/f-013-01 f013
-sketches/F2-013-01-sz1 f013
-photos/f-014-01 f014
-sketches/F2-014-01-sz1 f014
-photos/f-015-01 f015
-sketches/F2-015-01-sz1 f015
-photos/f-016-01 f016
-sketches/F2-016-01-sz1 f016
-photos/f-017-01 f017
-sketches/F2-017-01-sz1 f017
-photos/f-018-01 f018
-sketches/F2-018-01-sz1 f018
-photos/f-019-01 f019
-sketches/F2-019-01-sz1 f019
-photos/f-020-01 f020
-sketches/F2-020-01-sz1 f020
-photos/f-021-01 f021
-sketches/F2-021-01-sz1 f021
-photos/f-022-01 f022
-sketches/F2-022-01-sz1 f022
-photos/f-023-01 f023
-sketches/F2-023-01-sz1 f023
-photos/f-024-01 f024
-sketches/F2-024-01-sz1 f024
-photos/f-025-01 f025
-sketches/F2-025-01-sz1 f025
-photos/f-026-01 f026
-sketches/F2-026-01-sz1 f026
-photos/f-027-01 f027
-sketches/F2-027-01-sz1 f027
-photos/f-028-01 f028
-sketches/F2-028-01-sz1 f028
-photos/f-029-01 f029
-sketches/F2-029-01-sz1 f029
-photos/f-030-01 f030
-sketches/F2-030-01-sz1 f030
-photos/f-031-01 f031
-sketches/F2-031-01-sz1 f031
-photos/f-032-01 f032
-sketches/F2-032-01-sz1 f032
-photos/f-033-01 f033
-sketches/F2-033-01-sz1 f033
-photos/f-034-01 f034
-sketches/F2-034-01-sz1 f034
-photos/f-035-01 f035
-sketches/F2-035-01-sz1 f035
-photos/f-036-01 f036
-sketches/F2-036-01-sz1 f036
-photos/f-037-01 f037
-sketches/F2-037-01-sz1 f037
-photos/f-038-01 f038
-sketches/F2-038-01-sz1 f038
-photos/f-039-01 f039
-sketches/f-039-01-sz1 f039
-photos/f-040-01 f040
-sketches/f-040-01-sz1 f040
-photos/f-041-01 f041
-sketches/f-041-01-sz1 f041
-photos/f-042-01 f042
-sketches/f-042-01-sz1 f042
-photos/f-043-01 f043
-sketches/f-043-01-sz1 f043
-photos/f1-001-01 f1001
-sketches/f1-001-01-sz1 f1001
-photos/f1-002-01 f1002
-sketches/f1-002-01-sz1 f1002
-photos/f1-003-01 f1003
-sketches/f1-003-01-sz1 f1003
-photos/f1-004-01 f1004
-sketches/f1-004-01-sz1 f1004
-photos/f1-005-01 f1005
-sketches/f1-005-01-sz1 f1005
-photos/f1-006-01 f1006
-sketches/f1-006-01-sz1 f1006
-photos/f1-007-01 f1007
-sketches/f1-007-01-sz1 f1007
-photos/f1-008-01 f1008
-sketches/f1-008-01-sz1 f1008
-photos/f1-009-01 f1009
-sketches/f1-009-01-sz1 f1009
-photos/f1-010-01 f1010
-sketches/f1-010-01-sz1 f1010
-photos/f1-011-01 f1011
-sketches/f1-011-01-sz1 f1011
-photos/f1-012-01 f1012
-sketches/f1-012-01-sz1 f1012
-photos/f1-013-01 f1013
-sketches/f1-013-01-sz1 f1013
-photos/f1-014-01 f1014
-sketches/f1-014-01-sz1 f1014
-photos/f1-015-01 f1015
-sketches/f1-015-01-sz1 f1015
-photos/m-008-01 m008
-sketches/M2-008-01-sz1 m008
-photos/m-009-01 m009
-sketches/M2-009-01-sz1 m009
-photos/m-010-01 m010
-sketches/M2-010-01-sz1 m010
-photos/m-011-01 m011
-sketches/M2-011-01-sz1 m011
-photos/m-012-01 m012
-sketches/M2-012-01-sz1 m012
-photos/m-013-01 m013
-sketches/M2-013-01-sz1 m013
-photos/m-014-01 m014
-sketches/M2-014-01-sz1 m014
-photos/m-015-01 m015
-sketches/M2-015-01-sz1 m015
-photos/m-016-01 m016
-sketches/M2-016-01-sz1 m016
-photos/m-017-01 m017
-sketches/M2-017-01-sz1 m017
-photos/m-018-01 m018
-sketches/M2-018-01-sz1 m018
-photos/m-019-01 m019
-sketches/M2-019-01-sz1 m019
-photos/m-021-01 m021
-sketches/M2-021-01-sz1 m021
-photos/m-022-01 m022
-sketches/M2-022-01-sz1 m022
-photos/m-023-01 m023
-sketches/M2-023-01-sz1 m023
-photos/m-024-01 m024
-sketches/M2-024-01-sz1 m024
-photos/m-025-01 m025
-sketches/M2-025-01-sz1 m025
-photos/m-026-01 m026
-sketches/M2-026-01-sz1 m026
-photos/m-027-01 m027
-sketches/M2-027-01-sz1 m027
-photos/m-028-01 m028
-sketches/M2-028-01-sz1 m028
-photos/m-029-01 m029
-sketches/M2-029-01-sz1 m029
-photos/m-030-01 m030
-sketches/M2-030-01-sz1 m030
-photos/m-031-01 m031
-sketches/M2-031-01-sz1 m031
-photos/m-032-01 m032
-sketches/M2-032-01-sz1 m032
-photos/m-033-01 m033
-sketches/M2-033-01-sz1 m033
-photos/m-034-01 m034
-sketches/M2-034-01-sz1 m034
-photos/m-035-01 m035
-sketches/M2-035-01-sz1 m035
-photos/m-036-01 m036
-sketches/M2-036-01-sz1 m036
-photos/m-037-01 m037
-sketches/M2-037-01-sz1 m037
-photos/m-038-01 m038
-sketches/M2-038-01-sz1 m038
-photos/m-039-01 m039
-sketches/M2-039-01-sz1 m039
-photos/m-040-01 m040
-sketches/M2-040-01-sz1 m040
-photos/m-041-01 m041
-sketches/M2-041-01-sz1 m041
-photos/m-042-01 m042
-sketches/M2-042-01-sz1 m042
-photos/m-043-01 m043
-sketches/M2-043-01-sz1 m043
-photos/m-044-01 m044
-sketches/M2-044-01-sz1 m044
-photos/m-045-01 m045
-sketches/M2-045-01-sz1 m045
-photos/m-046-01 m046
-sketches/M2-046-01-sz1 m046
-photos/m-047-01 m047
-sketches/M2-047-01-sz1 m047
-photos/m-048-01 m048
-sketches/M2-048-01-sz1 m048
-photos/m-049-01 m049
-sketches/M2-049-01-sz1 m049
-photos/m-050-01 m050
-sketches/M2-050-01-sz1 m050
-photos/m-051-01 m051
-sketches/M2-051-01-sz1 m051
-photos/m-052-01 m052
-sketches/M2-052-01-sz1 m052
-photos/m-053-01 m053
-sketches/M2-053-01-sz1 m053
-photos/m-054-01 m054
-sketches/M2-054-01-sz1 m054
-photos/m-055-01 m055
-sketches/M2-055-01-sz1 m055
-photos/m-056-01 m056
-sketches/M2-056-01-sz1 m056
-photos/m-057-01 m057
-sketches/M2-057-01-sz1 m057
-photos/m-058-01 m058
-sketches/M2-058-01-sz1 m058
-photos/m-059-01 m059
-sketches/M2-059-01-sz1 m059
-photos/m-060-01 m060
-sketches/M2-060-01-sz1 m060
-photos/m-061-01 m061
-sketches/M2-061-01-sz1 m061
-photos/m-062-01 m062
-sketches/M2-062-01-sz1 m062
-photos/m-063-01 m063
-sketches/m-063-01-sz1 m063
-photos/m-064-01 m064
-sketches/m-064-01-sz1 m064
-photos/m-065-01 m065
-sketches/m-065-01-sz1 m065
-photos/m-066-01 m066
-sketches/m-066-01-sz1 m066
-photos/m-067-01 m067
-sketches/m-067-01-sz1 m067
-photos/m-068-01 m068
-sketches/m-068-01-sz1 m068
-photos/m-069-01 m069
-sketches/m-069-01-sz1 m069
-photos/m-070-01 m070
-sketches/m-070-01-sz1 m070
-photos/m-071-01 m071
-sketches/m-071-01-sz1 m071
-photos/m-072-01 m072
-sketches/m-072-01-sz1 m072
-photos/m-073-01 m073
-sketches/m-073-01-sz1 m073
-photos/m-074-01 m074
-sketches/m-074-01-sz1 m074
-photos/m-075-01 m075
-sketches/m-075-01-sz1 m075
-photos/m-076-01 m076
-sketches/m-076-01-sz1 m076
-photos/m-077-01 m077
-sketches/m-077-01-sz1 m077
-photos/m-078-01 m078
-sketches/m-078-01-sz1 m078
-photos/m-079-01 m079
-sketches/m-079-01-sz1 m079
-photos/m-080-01 m080
-sketches/m-080-01-sz1 m080
-photos/m-081-01 m081
-sketches/m-081-01-sz1 m081
-photos/m-082-01 m082
-sketches/m-082-01-sz1 m082
-photos/m-083-01 m083
-sketches/m-083-01-sz1 m083
-photos/m-084-01 m084
-sketches/m-084-01-sz1 m084
-photos/m-085-01 m085
-sketches/m-085-01-sz1 m085
-photos/m-086-01 m086
-sketches/m-086-01-sz1 m086
-photos/m-087-01 m087
-sketches/m-087-01-sz1 m087
-photos/m-088-01 m088
-sketches/m-088-01-sz1 m088
-photos/m-089-01 m089
-sketches/m-089-01-sz1 m089
-photos/m-090-01 m090
-sketches/m-090-01-sz1 m090
-photos/m-091-01 m091
-sketches/m-091-01-sz1 m091
-photos/m-092-01 m092
-sketches/m-092-01-sz1 m092
-photos/m-093-01 m093
-sketches/m-093-01-sz1 m093
-photos/m-094-01 m094
-sketches/m-094-01-sz1 m094
-photos/m-095-01 m095
-sketches/m-095-01-sz1 m095
-photos/m-096-01 m096
-sketches/m-096-01-sz1 m096
-photos/m-097-01 m097
-sketches/m-097-01-sz1 m097
-photos/m-098-01 m098
-sketches/m-098-01-sz1 m098
-photos/m-099-01 m099
-sketches/m-099-01-sz1 m099
-photos/m-100-01 m100
-sketches/m-100-01-sz1 m100
-photos/m1-001-01 m1001
-sketches/m1-001-01-sz1 m1001
-photos/m1-002-01 m1002
-sketches/m1-002-01-sz1 m1002
-photos/m1-003-01 m1003
-sketches/m1-003-01-sz1 m1003
-photos/m1-004-01 m1004
-sketches/m1-004-01-sz1 m1004
-photos/m1-005-01 m1005
-sketches/m1-005-01-sz1 m1005
-photos/m1-006-01 m1006
-sketches/m1-006-01-sz1 m1006
-photos/m1-007-01 m1007
-sketches/m1-007-01-sz1 m1007
-photos/m1-008-01 m1008
-sketches/m1-008-01-sz1 m1008
-photos/m1-009-01 m1009
-sketches/m1-009-01-sz1 m1009
-photos/m1-010-01 m1010
-sketches/m1-010-01-sz1 m1010
-photos/m-101-01 m101
-sketches/m-101-01-sz1 m101
-photos/m1-011-01 m1011
-sketches/m1-011-01-sz1 m1011
-photos/m1-012-01 m1012
-sketches/m1-012-01-sz1 m1012
-photos/m1-013-01 m1013
-sketches/m1-013-01-sz1 m1013
-photos/m1-014-01 m1014
-sketches/m1-014-01-sz1 m1014
-photos/m1-015-01 m1015
-sketches/m1-015-01-sz1 m1015
-photos/m1-016-01 m1016
-sketches/m1-016-01-sz1 m1016
-photos/m1-017-01 m1017
-sketches/m1-017-01-sz1 m1017
-photos/m1-018-01 m1018
-sketches/m1-018-01-sz1 m1018
-photos/m1-019-01 m1019
-sketches/m1-019-01-sz1 m1019
-photos/m1-020-01 m1020
-sketches/m1-020-01-sz1 m1020
-photos/m1-021-01 m1021
-sketches/m1-021-01-sz1 m1021
-photos/m1-022-01 m1022
-sketches/m1-022-01-sz1 m1022
-photos/m1-023-01 m1023
-sketches/m1-023-01-sz1 m1023
-photos/m1-024-01 m1024
-sketches/m1-024-01-sz1 m1024
-photos/m1-025-01 m1025
-sketches/m1-025-01-sz1 m1025
-photos/m1-026-01 m1026
-sketches/m1-026-01-sz1 m1026
-photos/m1-027-01 m1027
-sketches/m1-027-01-sz1 m1027
-photos/m1-028-01 m1028
-sketches/m1-028-01-sz1 m1028
-photos/m1-029-01 m1029
-sketches/m1-029-01-sz1 m1029
-photos/m1-030-01 m1030
-sketches/m1-030-01-sz1 m1030
-photos/m1-031-01 m1031
-sketches/m1-031-01-sz1 m1031
-photos/m1-032-01 m1032
-sketches/m1-032-01-sz1 m1032
-photos/m1-033-01 m1033
-sketches/m1-033-01-sz1 m1033
-photos/m1-034-01 m1034
-sketches/m1-034-01-sz1 m1034
-photos/m1-035-01 m1035
-sketches/m1-035-01-sz1 m1035
-photos/m1-036-01 m1036
-sketches/m1-036-01-sz1 m1036
-photos/m1-037-01 m1037
-sketches/m1-037-01-sz1 m1037
-photos/m1-038-01 m1038
-sketches/m1-038-01-sz1 m1038
-photos/m1-039-01 m1039
-sketches/m1-039-01-sz1 m1039
-photos/m1-040-01 m1040
-sketches/m1-040-01-sz1 m1040
-photos/m1-041-01 m1041
-sketches/m1-041-01-sz1 m1041
diff --git a/bob/db/cuhk/create.py b/bob/db/cuhk/create.py
index beba514cf333b443bd8848ce7e83fd69c68be77f..56ee27d6fa86400853dcbe28e76ed001e7515f95 100644
--- a/bob/db/cuhk/create.py
+++ b/bob/db/cuhk/create.py
@@ -29,11 +29,10 @@ from utils import ARFACEWrapper, XM2VTSWrapper, CUHKWrapper
 def add_clients(session, verbose = True):
 
   """Adds the clients and split up the groups 'world', 'dev', and 'eval'"""
-
-  #import ipdb; ipdb.set_trace();
    
   #Adding the clients from ARFACE
-  arface_clients = ARFACEWrapper.get_clients()
+  arface = ARFACEWrapper()
+  arface_clients = arface.get_clients()
 
   if verbose>=1: print('Adding ARFACE clients to the database ...')
     
@@ -45,7 +44,7 @@ def add_clients(session, verbose = True):
  
     if verbose>=1: print("  Adding client {0}".format(original_client_id))   
     session.add(Client(id=id, 
-                       gender=ARFACEWrapper.get_gender_from_client_id(original_client_id),
+                       gender = arface.get_gender_from_client_id(original_client_id),
                        original_id = original_client_id,
                        original_database = "arface"
                        ))
@@ -53,7 +52,8 @@ def add_clients(session, verbose = True):
 
 
   #Adding the clients from XM2VTS
-  xm2vts_clients = XM2VTSWrapper.get_clients()
+  xm2vts = XM2VTSWrapper()
+  xm2vts_clients = xm2vts.get_clients()
 
   if verbose>=1: print('Adding XM2VTS clients to the database ...')
     
@@ -64,7 +64,7 @@ def add_clients(session, verbose = True):
  
     if verbose>=1: print("  Adding client {0}".format(original_client_id))   
     session.add(Client(id=id_offset, 
-                       gender=XM2VTSWrapper.get_gender(),
+                       gender=xm2vts.get_gender(),
                        original_id = original_client_id,
                        original_database = "xm2vts"
                        ))
@@ -72,7 +72,8 @@ def add_clients(session, verbose = True):
 
 
   #Adding the clients from CUHK
-  cuhk_clients = CUHKWrapper.get_clients()
+  cuhk         = CUHKWrapper()
+  cuhk_clients = cuhk.get_clients()
 
   if verbose>=1: print('Adding CUHK clients to the database ...')
     
@@ -83,7 +84,7 @@ def add_clients(session, verbose = True):
  
     if verbose>=1: print("  Adding client {0}".format(original_client_id))   
     session.add(Client(id=id_offset, 
-                       gender=CUHKWrapper.get_gender_from_client_id(original_client_id),
+                       gender=cuhk.get_gender_from_client_id(original_client_id),
                        original_id = original_client_id,
                        original_database = "cuhk"
                        ))
@@ -95,17 +96,96 @@ def add_clients(session, verbose = True):
 
 
 
-
-def add_files(session, directory, annotations_file, verbose):
+def add_files(session, verbose):
   """
   Adds files with their respective information into the Database
-  :param session: DB session
-  :param directory: directory to the CASME2 directory containing the folders of subjects.
-  :param annotations_file: annotations for the dataset file path
-  :param verbose: whether or not to show some information on CLI
   """
-  return None
+  if verbose>=1: print('Adding ARFACE files to the database ...')
+  if verbose>=1: print('Adding PHOTOS ...')
+  
+  arface = ARFACEWrapper()
+  files = arface.get_files_from_modality(modality='photo')
+  id_offset = 1 #ID
+  for f in files:
+    if verbose>=1: print("  Adding file {0}".format(f.path))
+    f.id = id_offset
+    id_offset+=1
+    session.add(f)
+
+
+  if verbose>=1: print('Adding SKETCHES ...') 
+  files = arface.get_files_from_modality(modality='sketches')    
+  for f in files:
+    if verbose>=1: print("  Adding file {0}".format(f.path))
+    f.id = id_offset
+    id_offset+=1
+    session.add(f)
+
+  del arface
+
+  ########
+
+  if verbose>=1: print('Adding XM2VTS files to the database ...')
+  if verbose>=1: print('Adding PHOTOS ...')
+ 
+  xm2vts = XM2VTSWrapper()
+  files = xm2vts.get_files_from_modality(modality='photo')
+  for f in files:
+    if verbose>=1: print("  Adding file {0}".format(f.path))
+    f.id = id_offset
+    id_offset+=1
+    session.add(f)
+
+
+  if verbose>=1: print('Adding SKETCHES ...') 
+  files = xm2vts.get_files_from_modality(modality='sketches')    
+  for f in files:
+    if verbose>=1: print("  Adding file {0}".format(f.path))
+    f.id = id_offset
+    id_offset+=1
+    session.add(f)
+
+  #######
+
+  if verbose>=1: print('Adding CUHK files to the database ...')
+ 
+  cuhk = CUHKWrapper()
+  files = cuhk.get_files()
+  for f in files:
+    if verbose>=1: print("  Adding file {0}".format(f.path))
+    f.id = id_offset
+    id_offset+=1
+    session.add(f)
+
+
+  
+  session.commit()
+
+
+def add_annotations(session, annotation_dir, verbose):
+  """
+  Adds the annotations 
+  """
 
+  if verbose>=1: print('Adding ARFACE Annotations to the database ...')
+  arface = ARFACEWrapper()
+  annotations = arface.get_annotations(annotation_dir, annotation_extension='.dat')
+  for a in annotations:
+    session.add(a)
+
+  if verbose>=1: print('Adding XM2VTS Annotations to the database ...')
+  xm2vts = XM2VTSWrapper()
+  annotations = xm2vts.get_annotations(annotation_dir, annotation_extension='.dat')
+  for a in annotations:
+    session.add(a)
+
+  if verbose>=1: print('Adding CUHK Annotations to the database ...')
+  cuhk = CUHKWrapper()
+  annotations = cuhk.get_annotations(annotation_dir, annotation_extension='.dat')
+  for a in annotations:
+    session.add(a)
+
+  session.commit()   
 
 
 def create_tables(args):
@@ -141,7 +221,9 @@ def create(args):
   create_tables(args)
   s = session_try_nolock(args.type, args.files[0], echo=(args.verbose >= 2))
   add_clients(s, args.verbose)
-  #add_files(s, args.directory, args.annotdir, args.verbose)
+  add_files(s, args.verbose)
+  add_annotations(s, args.annotation_dir, args.verbose)
+
   #add_protocols(s, args.verbose)
   #add_clientxprotocols(s, args.verbose)
   s.commit()
@@ -152,10 +234,8 @@ def add_command(subparsers):
 
   parser = subparsers.add_parser('create', help=create.__doc__)
 
-  parser.add_argument('-R', '--recreate', action='store_true', help='If set, I\'ll first erase the current database')
-  parser.add_argument('-v', '--verbose', action='count', help='Do SQL operations in a verbose way?')
-  parser.add_argument('-D', '--directory', metavar='DIR', default='../CASME2/Cropped/', help='The path to the directory containing the subjects folders, which have the frames')
-  parser.add_argument('--extension', metavar='STR', default='.jpg', help='The file extension of the image files from the CASME2 database')
-  parser.add_argument('-A', '--annotdir', metavar='DIR', default='bob/db/casme2/annotations.csv', help="Change the relative path to the directory containing the action_unit information file of the CASME2 database (defaults to %(default)s)")
+  parser.add_argument('-r', '--recreate', action='store_true', help='If set, I\'ll first erase the current database')
+  parser.add_argument('-v', '--verbose', action='count', help='Increase verbosity?')
+  parser.add_argument('-a', '--annotation-dir', default='.',  help="The annotation directory. HAS TO BE THE SAME STRUCTURE AS PROVIDED BY THE DATABASE PROVIDERS (defaults to %(default)s)")
 
   parser.set_defaults(func=create) #action
diff --git a/bob/db/cuhk/AR_file_names_of_photos.txt b/bob/db/cuhk/data/AR_file_names_of_photos.txt
similarity index 100%
rename from bob/db/cuhk/AR_file_names_of_photos.txt
rename to bob/db/cuhk/data/AR_file_names_of_photos.txt
diff --git a/bob/db/cuhk/data/AR_file_names_of_sketches.txt b/bob/db/cuhk/data/AR_file_names_of_sketches.txt
new file mode 100644
index 0000000000000000000000000000000000000000..f94a597aba33ff35640ed33dc9a390152f625eda
--- /dev/null
+++ b/bob/db/cuhk/data/AR_file_names_of_sketches.txt
@@ -0,0 +1,123 @@
+Mp-002-1-sz1
+Mp-003-1-sz1
+Mp-005-1-sz1
+Mp-006-1-sz1
+Mp-007-1-sz1
+Mp-008-1-sz1
+Mp-009-1-sz1
+Mp-010-1-sz1
+Mp-011-1-sz1
+Mp-013-1-sz1
+Mp-014-1-sz1
+Mp-015-1-sz1
+Mp-016-1-sz1
+Mp-017-1-sz1
+Mp-018-1-sz1
+Mp-020-1-sz1
+Mp-021-1-sz1
+Mp-022-1-sz1
+Mp-023-1-sz1
+Mp-024-1-sz1
+Mp-025-1-sz1
+Mp-026-1-sz1
+Mp-027-1-sz1
+Mp-028-1-sz1
+Mp-029-1-sz1
+Mp-030-1-sz1
+Mp-031-1-sz1
+Mp-032-1-sz1
+Mp-033-1-sz1
+Mp-035-1-sz1
+Mp-036-1-sz1
+Mp-037-1-sz1
+Mp-038-1-sz1
+Mp-039-1-sz1
+Mp-040-1-sz1
+Mp-041-1-sz1
+Mp-042-1-sz1
+Mp-043-1-sz1
+Mp-044-1-sz1
+Mp-045-1-sz1
+Mp-046-1-sz1
+Mp-047-1-sz1
+Mp-048-1-sz1
+Mp-049-1-sz1
+Mp-050-1-sz1
+Mp-051-1-sz1
+Mp-052-1-sz1
+Mp-053-1-sz1
+Mp-054-1-sz1
+Mp-055-1-sz1
+Mp-056-1-sz1
+Mp-057-1-sz1
+Mp-058-1-sz1
+Mp-059-1-sz1
+Mp-060-1-sz1
+Mp-061-1-sz1
+Mp-062-1-sz1
+Mp-063-1-sz1
+Mp-064-1-sz1
+Mp-065-1-sz1
+Mp-066-1-sz1
+Mp-067-1-sz1
+Mp-068-1-sz1
+Mp-069-1-sz1
+Mp-070-1-sz1
+Mp-071-1-sz1
+Mp-072-1-sz1
+Mp-073-1-sz1
+Mp-074-1-sz1
+Mp-075-1-sz1
+Wp-001-1-sz1
+Wp-002-1-sz1
+Wp-003-1-sz1
+Wp-004-1-sz1
+Wp-005-1-sz1
+Wp-007-1-sz1
+Wp-008-1-sz1
+Wp-014-1-sz1
+Wp-015-1-sz1
+Wp-016-1-sz1
+Wp-017-1-sz1
+Wp-018-1-sz1
+Wp-019-1-sz1
+Wp-020-1-sz1
+Wp-021-1-sz1
+Wp-022-1-sz1
+Wp-023-1-sz1
+Wp-024-1-sz1
+Wp-025-1-sz1
+Wp-026-1-sz1
+Wp-027-1-sz1
+Wp-028-1-sz1
+Wp-029-1-sz1
+Wp-030-1-sz1
+Wp-031-1-sz1
+Wp-032-1-sz1
+Wp-033-1-sz1
+Wp-034-1-sz1
+Wp-035-1-sz1
+Wp-036-1-sz1
+Wp-037-1-sz1
+Wp-038-1-sz1
+Wp-039-1-sz1
+Wp-040-1-sz1
+Wp-041-1-sz1
+Wp-042-1-sz1
+Wp-043-1-sz1
+Wp-044-1-sz1
+Wp-045-1-sz1
+Wp-046-1-sz1
+Wp-047-1-sz1
+Wp-048-1-sz1
+Wp-049-1-sz1
+Wp-050-1-sz1
+Wp-051-1-sz1
+Wp-052-1-sz1
+Wp-053-1-sz1
+Wp-054-1-sz1
+Wp-055-1-sz1
+Wp-056-1-sz1
+Wp-057-1-sz1
+Wp-058-1-sz1
+Wp-059-1-sz1
diff --git a/bob/db/cuhk/XM2VTS_file_names_of_photos.txt b/bob/db/cuhk/data/XM2VTS_file_names_of_photos.txt
similarity index 100%
rename from bob/db/cuhk/XM2VTS_file_names_of_photos.txt
rename to bob/db/cuhk/data/XM2VTS_file_names_of_photos.txt
diff --git a/bob/db/cuhk/data/XM2VTS_file_names_of_sketches.txt b/bob/db/cuhk/data/XM2VTS_file_names_of_sketches.txt
new file mode 100644
index 0000000000000000000000000000000000000000..0b475f4c3cd9e2325ae0ea109c4fa306e6480c54
--- /dev/null
+++ b/bob/db/cuhk/data/XM2VTS_file_names_of_sketches.txt
@@ -0,0 +1,295 @@
+000_1_1_sz1
+001_1_1_sz1
+002_1_1_sz1
+003_1_1_sz1
+004_1_1_sz1
+005_1_1_sz1
+006_1_1_sz1
+007_1_1_sz1
+008_1_1_sz1
+009_1_1_sz1
+010_1_1_sz1
+011_1_1_sz1
+012_1_1_sz1
+013_1_1_sz1
+016_1_1_sz1
+017_1_1_sz1
+018_1_1_sz1
+019_1_1_sz1
+020_1_1_sz1
+021_1_1_sz1
+022_1_1_sz1
+023_1_1_sz1
+024_1_1_sz1
+025_1_1_sz1
+026_1_1_sz1
+027_1_1_sz1
+028_1_1_sz1
+029_1_1_sz1
+030_1_1_sz1
+031_1_1_sz1
+032_1_1_sz1
+033_1_1_sz1
+034_1_1_sz1
+035_1_1_sz1
+036_1_1_sz1
+037_1_1_sz1
+038_1_1_sz1
+039_1_1_sz1
+040_1_1_sz1
+041_1_1_sz1
+042_1_1_sz1
+043_1_1_sz1
+044_1_1_sz1
+045_1_1_sz1
+046_1_1_sz1
+047_1_1_sz1
+048_1_1_sz1
+049_1_1_sz1
+050_1_1_sz1
+051_1_1_sz1
+052_1_1_sz1
+053_1_1_sz1
+054_1_1_sz1
+055_1_1_sz1
+056_1_1_sz1
+057_1_1_sz1
+058_1_1_sz1
+059_1_1_sz1
+060_1_1_sz1
+061_1_1_sz1
+062_1_1_sz1
+064_1_1_sz1
+065_1_1_sz1
+066_1_1_sz1
+067_1_1_sz1
+068_1_1_sz1
+069_1_1_sz1
+070_1_1_sz1
+071_1_1_sz1
+072_1_1_sz1
+073_1_1_sz1
+074_1_1_sz1
+075_1_1_sz1
+078_1_1_sz1
+079_1_1_sz1
+080_1_1_sz1
+081_1_1_sz1
+082_1_1_sz1
+083_1_1_sz1
+085_1_1_sz1
+086_1_1_sz1
+087_1_1_sz1
+088_1_1_sz1
+089_1_1_sz1
+090_1_1_sz1
+091_1_1_sz1
+092_1_1_sz1
+093_1_1_sz1
+095_1_1_sz1
+096_1_1_sz1
+098_1_1_sz1
+099_1_1_sz1
+101_1_1_sz1
+102_1_1_sz1
+103_1_1_sz1
+104_1_1_sz1
+105_1_1_sz1
+107_1_1_sz1
+108_1_1_sz1
+109_1_1_sz1
+110_1_1_sz1
+111_1_1_sz1
+112_1_1_sz1
+113_1_1_sz1
+114_1_1_sz1
+115_1_1_sz1
+116_1_1_sz1
+119_1_1_sz1
+120_1_1_sz1
+121_1_1_sz1
+122_1_1_sz1
+123_1_1_sz1
+124_1_1_sz1
+125_1_1_sz1
+126_1_1_sz1
+127_1_1_sz1
+128_1_1_sz1
+129_1_1_sz1
+130_1_1_sz1
+131_1_1_sz1
+132_1_1_sz1
+133_1_1_sz1
+134_1_1_sz1
+135_1_1_sz1
+136_1_1_sz1
+137_1_1_sz1
+138_1_1_sz1
+140_1_1_sz1
+141_1_1_sz1
+142_1_1_sz1
+143_1_1_sz1
+145_1_1_sz1
+146_1_1_sz1
+147_1_1_sz1
+148_1_1_sz1
+149_1_1_sz1
+150_1_1_sz1
+152_1_1_sz1
+153_1_1_sz1
+154_1_1_sz1
+155_1_1_sz1
+157_1_1_sz1
+158_1_1_sz1
+159_1_1_sz1
+160_1_1_sz1
+161_1_1_sz1
+163_1_1_sz1
+164_1_1_sz1
+165_1_1_sz1
+166_1_1_sz1
+167_1_1_sz1
+168_1_1_sz1
+169_1_1_sz1
+170_1_1_sz1
+171_1_1_sz1
+172_1_1_sz1
+173_1_1_sz1
+174_1_1_sz1
+175_1_1_sz1
+176_1_1_sz1
+177_1_1_sz1
+178_1_1_sz1
+179_1_1_sz1
+180_1_1_sz1
+181_1_1_sz1
+182_1_1_sz1
+183_1_1_sz1
+185_1_1_sz1
+187_1_1_sz1
+188_1_1_sz1
+189_1_1_sz1
+190_1_1_sz1
+191_1_1_sz1
+193_1_1_sz1
+196_1_1_sz1
+197_1_1_sz1
+198_1_1_sz1
+199_1_1_sz1
+200_1_1_sz1
+201_1_1_sz1
+202_1_1_sz1
+203_1_1_sz1
+206_1_1_sz1
+207_1_1_sz1
+208_1_1_sz1
+209_1_1_sz1
+210_1_1_sz1
+211_1_1_sz1
+212_1_1_sz1
+213_1_1_sz1
+215_1_1_sz1
+216_1_1_sz1
+218_1_1_sz1
+219_1_1_sz1
+221_1_1_sz1
+222_1_1_sz1
+224_1_1_sz1
+225_1_1_sz1
+226_1_1_sz1
+227_1_1_sz1
+228_1_1_sz1
+229_1_1_sz1
+231_1_1_sz1
+232_1_1_sz1
+233_1_1_sz1
+234_1_1_sz1
+235_1_1_sz1
+236_1_1_sz1
+237_1_1_sz1
+240_1_1_sz1
+241_1_1_sz1
+242_1_1_sz1
+243_1_1_sz1
+244_1_1_sz1
+246_1_1_sz1
+248_1_1_sz1
+249_1_1_sz1
+250_1_1_sz1
+253_1_1_sz1
+255_1_1_sz1
+258_1_1_sz1
+259_1_1_sz1
+261_1_1_sz1
+263_1_1_sz1
+264_1_1_sz1
+266_1_1_sz1
+267_1_1_sz1
+269_1_1_sz1
+270_1_1_sz1
+271_1_1_sz1
+272_1_1_sz1
+274_1_1_sz1
+275_1_1_sz1
+276_1_1_sz1
+278_1_1_sz1
+279_1_1_sz1
+280_1_1_sz1
+281_1_1_sz1
+282_1_1_sz1
+283_1_1_sz1
+284_1_1_sz1
+285_1_1_sz1
+286_1_1_sz1
+287_1_1_sz1
+288_1_1_sz1
+289_1_1_sz1
+290_1_1_sz1
+292_1_1_sz1
+293_1_1_sz1
+295_1_1_sz1
+300_1_1_sz1
+301_1_1_sz1
+305_1_1_sz1
+310_1_1_sz1
+312_1_1_sz1
+313_1_1_sz1
+314_1_1_sz1
+315_1_1_sz1
+316_1_1_sz1
+317_1_1_sz1
+318_1_1_sz1
+319_1_1_sz1
+320_1_1_sz1
+321_1_1_sz1
+322_1_1_sz1
+323_1_1_sz1
+324_1_1_sz1
+325_1_1_sz1
+328_1_1_sz1
+329_1_1_sz1
+330_1_1_sz1
+331_1_1_sz1
+332_1_1_sz1
+333_1_1_sz1
+334_1_1_sz1
+335_1_1_sz1
+336_1_1_sz1
+337_1_1_sz1
+338_1_1_sz1
+339_1_1_sz1
+340_1_1_sz1
+341_1_1_sz1
+342_1_1_sz1
+357_1_1_sz1
+358_1_1_sz1
+359_1_1_sz1
+360_1_1_sz1
+362_1_1_sz1
+364_1_1_sz1
+365_1_1_sz1
+366_1_1_sz1
+367_1_1_sz1
+369_1_1_sz1
+370_1_1_sz1
+371_1_1_sz1
diff --git a/bob/db/cuhk/data/all-cuhk.txt b/bob/db/cuhk/data/all-cuhk.txt
new file mode 100644
index 0000000000000000000000000000000000000000..310548228faf1b5ef9e7d003c18e0505e10a1b90
--- /dev/null
+++ b/bob/db/cuhk/data/all-cuhk.txt
@@ -0,0 +1,376 @@
+CUHK-student-dataset/sketch/f-039-01-sz1 f-039-01
+CUHK-student-dataset/sketch/f-040-01-sz1 f-040-01
+CUHK-student-dataset/sketch/f-041-01-sz1 f-041-01
+CUHK-student-dataset/sketch/f-042-01-sz1 f-042-01
+CUHK-student-dataset/sketch/f-043-01-sz1 f-043-01
+CUHK-student-dataset/sketch/f1-001-01-sz1 f1-001-01
+CUHK-student-dataset/sketch/f1-002-01-sz1 f1-002-01
+CUHK-student-dataset/sketch/f1-003-01-sz1 f1-003-01
+CUHK-student-dataset/sketch/f1-004-01-sz1 f1-004-01
+CUHK-student-dataset/sketch/f1-005-01-sz1 f1-005-01
+CUHK-student-dataset/sketch/f1-006-01-sz1 f1-006-01
+CUHK-student-dataset/sketch/f1-007-01-sz1 f1-007-01
+CUHK-student-dataset/sketch/f1-008-01-sz1 f1-008-01
+CUHK-student-dataset/sketch/f1-009-01-sz1 f1-009-01
+CUHK-student-dataset/sketch/f1-010-01-sz1 f1-010-01
+CUHK-student-dataset/sketch/f1-011-01-sz1 f1-011-01
+CUHK-student-dataset/sketch/f1-012-01-sz1 f1-012-01
+CUHK-student-dataset/sketch/f1-013-01-sz1 f1-013-01
+CUHK-student-dataset/sketch/f1-014-01-sz1 f1-014-01
+CUHK-student-dataset/sketch/f1-015-01-sz1 f1-015-01
+CUHK-student-dataset/sketch/f2-005-01-sz1 f2-005-01
+CUHK-student-dataset/sketch/f2-006-01-sz1 f2-006-01
+CUHK-student-dataset/sketch/f2-007-01-sz1 f2-007-01
+CUHK-student-dataset/sketch/f2-008-01-sz1 f2-008-01
+CUHK-student-dataset/sketch/f2-009-01-sz1 f2-009-01
+CUHK-student-dataset/sketch/f2-010-01-sz1 f2-010-01
+CUHK-student-dataset/sketch/f2-011-01-sz1 f2-011-01
+CUHK-student-dataset/sketch/f2-012-01-sz1 f2-012-01
+CUHK-student-dataset/sketch/f2-013-01-sz1 f2-013-01
+CUHK-student-dataset/sketch/f2-014-01-sz1 f2-014-01
+CUHK-student-dataset/sketch/f2-015-01-sz1 f2-015-01
+CUHK-student-dataset/sketch/f2-016-01-sz1 f2-016-01
+CUHK-student-dataset/sketch/f2-017-01-sz1 f2-017-01
+CUHK-student-dataset/sketch/f2-018-01-sz1 f2-018-01
+CUHK-student-dataset/sketch/f2-019-01-sz1 f2-019-01
+CUHK-student-dataset/sketch/f2-020-01-sz1 f2-020-01
+CUHK-student-dataset/sketch/f2-021-01-sz1 f2-021-01
+CUHK-student-dataset/sketch/f2-022-01-sz1 f2-022-01
+CUHK-student-dataset/sketch/f2-023-01-sz1 f2-023-01
+CUHK-student-dataset/sketch/f2-024-01-sz1 f2-024-01
+CUHK-student-dataset/sketch/f2-025-01-sz1 f2-025-01
+CUHK-student-dataset/sketch/f2-026-01-sz1 f2-026-01
+CUHK-student-dataset/sketch/f2-027-01-sz1 f2-027-01
+CUHK-student-dataset/sketch/f2-028-01-sz1 f2-028-01
+CUHK-student-dataset/sketch/f2-029-01-sz1 f2-029-01
+CUHK-student-dataset/sketch/f2-030-01-sz1 f2-030-01
+CUHK-student-dataset/sketch/f2-031-01-sz1 f2-031-01
+CUHK-student-dataset/sketch/f2-032-01-sz1 f2-032-01
+CUHK-student-dataset/sketch/f2-033-01-sz1 f2-033-01
+CUHK-student-dataset/sketch/f2-034-01-sz1 f2-034-01
+CUHK-student-dataset/sketch/f2-035-01-sz1 f2-035-01
+CUHK-student-dataset/sketch/f2-036-01-sz1 f2-036-01
+CUHK-student-dataset/sketch/f2-037-01-sz1 f2-037-01
+CUHK-student-dataset/sketch/f2-038-01-sz1 f2-038-01
+CUHK-student-dataset/sketch/m-063-01-sz1 m-063-01
+CUHK-student-dataset/sketch/m-064-01-sz1 m-064-01
+CUHK-student-dataset/sketch/m-065-01-sz1 m-065-01
+CUHK-student-dataset/sketch/m-066-01-sz1 m-066-01
+CUHK-student-dataset/sketch/m-067-01-sz1 m-067-01
+CUHK-student-dataset/sketch/m-068-01-sz1 m-068-01
+CUHK-student-dataset/sketch/m-069-01-sz1 m-069-01
+CUHK-student-dataset/sketch/m-070-01-sz1 m-070-01
+CUHK-student-dataset/sketch/m-071-01-sz1 m-071-01
+CUHK-student-dataset/sketch/m-072-01-sz1 m-072-01
+CUHK-student-dataset/sketch/m-073-01-sz1 m-073-01
+CUHK-student-dataset/sketch/m-074-01-sz1 m-074-01
+CUHK-student-dataset/sketch/m-075-01-sz1 m-075-01
+CUHK-student-dataset/sketch/m-076-01-sz1 m-076-01
+CUHK-student-dataset/sketch/m-077-01-sz1 m-077-01
+CUHK-student-dataset/sketch/m-078-01-sz1 m-078-01
+CUHK-student-dataset/sketch/m-079-01-sz1 m-079-01
+CUHK-student-dataset/sketch/m-080-01-sz1 m-080-01
+CUHK-student-dataset/sketch/m-081-01-sz1 m-081-01
+CUHK-student-dataset/sketch/m-082-01-sz1 m-082-01
+CUHK-student-dataset/sketch/m-083-01-sz1 m-083-01
+CUHK-student-dataset/sketch/m-084-01-sz1 m-084-01
+CUHK-student-dataset/sketch/m-085-01-sz1 m-085-01
+CUHK-student-dataset/sketch/m-086-01-sz1 m-086-01
+CUHK-student-dataset/sketch/m-087-01-sz1 m-087-01
+CUHK-student-dataset/sketch/m-088-01-sz1 m-088-01
+CUHK-student-dataset/sketch/m-089-01-sz1 m-089-01
+CUHK-student-dataset/sketch/m-090-01-sz1 m-090-01
+CUHK-student-dataset/sketch/m-091-01-sz1 m-091-01
+CUHK-student-dataset/sketch/m-092-01-sz1 m-092-01
+CUHK-student-dataset/sketch/m-093-01-sz1 m-093-01
+CUHK-student-dataset/sketch/m-094-01-sz1 m-094-01
+CUHK-student-dataset/sketch/m-095-01-sz1 m-095-01
+CUHK-student-dataset/sketch/m-096-01-sz1 m-096-01
+CUHK-student-dataset/sketch/m-097-01-sz1 m-097-01
+CUHK-student-dataset/sketch/m-098-01-sz1 m-098-01
+CUHK-student-dataset/sketch/m-099-01-sz1 m-099-01
+CUHK-student-dataset/sketch/m-100-01-sz1 m-100-01
+CUHK-student-dataset/sketch/m1-001-01-sz1 m1-001-01
+CUHK-student-dataset/sketch/m1-002-01-sz1 m1-002-01
+CUHK-student-dataset/sketch/m1-003-01-sz1 m1-003-01
+CUHK-student-dataset/sketch/m1-004-01-sz1 m1-004-01
+CUHK-student-dataset/sketch/m1-005-01-sz1 m1-005-01
+CUHK-student-dataset/sketch/m1-006-01-sz1 m1-006-01
+CUHK-student-dataset/sketch/m1-007-01-sz1 m1-007-01
+CUHK-student-dataset/sketch/m1-008-01-sz1 m1-008-01
+CUHK-student-dataset/sketch/m1-009-01-sz1 m1-009-01
+CUHK-student-dataset/sketch/m1-010-01-sz1 m1-010-01
+CUHK-student-dataset/sketch/m-101-01-sz1 m-101-01
+CUHK-student-dataset/sketch/m1-011-01-sz1 m1-011-01
+CUHK-student-dataset/sketch/m1-012-01-sz1 m1-012-01
+CUHK-student-dataset/sketch/m1-013-01-sz1 m1-013-01
+CUHK-student-dataset/sketch/m1-014-01-sz1 m1-014-01
+CUHK-student-dataset/sketch/m1-015-01-sz1 m1-015-01
+CUHK-student-dataset/sketch/m1-016-01-sz1 m1-016-01
+CUHK-student-dataset/sketch/m1-017-01-sz1 m1-017-01
+CUHK-student-dataset/sketch/m1-018-01-sz1 m1-018-01
+CUHK-student-dataset/sketch/m1-019-01-sz1 m1-019-01
+CUHK-student-dataset/sketch/m1-020-01-sz1 m1-020-01
+CUHK-student-dataset/sketch/m1-021-01-sz1 m1-021-01
+CUHK-student-dataset/sketch/m1-022-01-sz1 m1-022-01
+CUHK-student-dataset/sketch/m1-023-01-sz1 m1-023-01
+CUHK-student-dataset/sketch/m1-024-01-sz1 m1-024-01
+CUHK-student-dataset/sketch/m1-025-01-sz1 m1-025-01
+CUHK-student-dataset/sketch/m1-026-01-sz1 m1-026-01
+CUHK-student-dataset/sketch/m1-027-01-sz1 m1-027-01
+CUHK-student-dataset/sketch/m1-028-01-sz1 m1-028-01
+CUHK-student-dataset/sketch/m1-029-01-sz1 m1-029-01
+CUHK-student-dataset/sketch/m1-030-01-sz1 m1-030-01
+CUHK-student-dataset/sketch/m1-031-01-sz1 m1-031-01
+CUHK-student-dataset/sketch/m1-032-01-sz1 m1-032-01
+CUHK-student-dataset/sketch/m1-033-01-sz1 m1-033-01
+CUHK-student-dataset/sketch/m1-034-01-sz1 m1-034-01
+CUHK-student-dataset/sketch/m1-035-01-sz1 m1-035-01
+CUHK-student-dataset/sketch/m1-036-01-sz1 m1-036-01
+CUHK-student-dataset/sketch/m1-037-01-sz1 m1-037-01
+CUHK-student-dataset/sketch/m1-038-01-sz1 m1-038-01
+CUHK-student-dataset/sketch/m1-039-01-sz1 m1-039-01
+CUHK-student-dataset/sketch/m1-040-01-sz1 m1-040-01
+CUHK-student-dataset/sketch/m1-041-01-sz1 m1-041-01
+CUHK-student-dataset/sketch/m2-008-01-sz1 m2-008-01
+CUHK-student-dataset/sketch/m2-009-01-sz1 m2-009-01
+CUHK-student-dataset/sketch/m2-010-01-sz1 m2-010-01
+CUHK-student-dataset/sketch/m2-011-01-sz1 m2-011-01
+CUHK-student-dataset/sketch/m2-012-01-sz1 m2-012-01
+CUHK-student-dataset/sketch/m2-013-01-sz1 m2-013-01
+CUHK-student-dataset/sketch/m2-014-01-sz1 m2-014-01
+CUHK-student-dataset/sketch/m2-015-01-sz1 m2-015-01
+CUHK-student-dataset/sketch/m2-016-01-sz1 m2-016-01
+CUHK-student-dataset/sketch/m2-017-01-sz1 m2-017-01
+CUHK-student-dataset/sketch/m2-018-01-sz1 m2-018-01
+CUHK-student-dataset/sketch/m2-019-01-sz1 m2-019-01
+CUHK-student-dataset/sketch/m2-021-01-sz1 m2-021-01
+CUHK-student-dataset/sketch/m2-022-01-sz1 m2-022-01
+CUHK-student-dataset/sketch/m2-023-01-sz1 m2-023-01
+CUHK-student-dataset/sketch/m2-024-01-sz1 m2-024-01
+CUHK-student-dataset/sketch/m2-025-01-sz1 m2-025-01
+CUHK-student-dataset/sketch/m2-026-01-sz1 m2-026-01
+CUHK-student-dataset/sketch/m2-027-01-sz1 m2-027-01
+CUHK-student-dataset/sketch/m2-028-01-sz1 m2-028-01
+CUHK-student-dataset/sketch/m2-029-01-sz1 m2-029-01
+CUHK-student-dataset/sketch/m2-030-01-sz1 m2-030-01
+CUHK-student-dataset/sketch/m2-031-01-sz1 m2-031-01
+CUHK-student-dataset/sketch/m2-032-01-sz1 m2-032-01
+CUHK-student-dataset/sketch/m2-033-01-sz1 m2-033-01
+CUHK-student-dataset/sketch/m2-034-01-sz1 m2-034-01
+CUHK-student-dataset/sketch/m2-035-01-sz1 m2-035-01
+CUHK-student-dataset/sketch/m2-036-01-sz1 m2-036-01
+CUHK-student-dataset/sketch/m2-037-01-sz1 m2-037-01
+CUHK-student-dataset/sketch/m2-038-01-sz1 m2-038-01
+CUHK-student-dataset/sketch/m2-039-01-sz1 m2-039-01
+CUHK-student-dataset/sketch/m2-040-01-sz1 m2-040-01
+CUHK-student-dataset/sketch/m2-041-01-sz1 m2-041-01
+CUHK-student-dataset/sketch/m2-042-01-sz1 m2-042-01
+CUHK-student-dataset/sketch/m2-043-01-sz1 m2-043-01
+CUHK-student-dataset/sketch/m2-044-01-sz1 m2-044-01
+CUHK-student-dataset/sketch/m2-045-01-sz1 m2-045-01
+CUHK-student-dataset/sketch/m2-046-01-sz1 m2-046-01
+CUHK-student-dataset/sketch/m2-047-01-sz1 m2-047-01
+CUHK-student-dataset/sketch/m2-048-01-sz1 m2-048-01
+CUHK-student-dataset/sketch/m2-049-01-sz1 m2-049-01
+CUHK-student-dataset/sketch/m2-050-01-sz1 m2-050-01
+CUHK-student-dataset/sketch/m2-051-01-sz1 m2-051-01
+CUHK-student-dataset/sketch/m2-052-01-sz1 m2-052-01
+CUHK-student-dataset/sketch/m2-053-01-sz1 m2-053-01
+CUHK-student-dataset/sketch/m2-054-01-sz1 m2-054-01
+CUHK-student-dataset/sketch/m2-055-01-sz1 m2-055-01
+CUHK-student-dataset/sketch/m2-056-01-sz1 m2-056-01
+CUHK-student-dataset/sketch/m2-057-01-sz1 m2-057-01
+CUHK-student-dataset/sketch/m2-058-01-sz1 m2-058-01
+CUHK-student-dataset/sketch/m2-059-01-sz1 m2-059-01
+CUHK-student-dataset/sketch/m2-060-01-sz1 m2-060-01
+CUHK-student-dataset/sketch/m2-061-01-sz1 m2-061-01
+CUHK-student-dataset/sketch/m2-062-01-sz1 m2-062-01
+CUHK-student-dataset/photo/f-005-01 f-005-01  
+CUHK-student-dataset/photo/f-006-01 f-006-01
+CUHK-student-dataset/photo/f-007-01 f-007-01
+CUHK-student-dataset/photo/f-008-01 f-008-01
+CUHK-student-dataset/photo/f-009-01 f-009-01
+CUHK-student-dataset/photo/f-010-01 f-010-01
+CUHK-student-dataset/photo/f-011-01 f-011-01
+CUHK-student-dataset/photo/f-012-01 f-012-01
+CUHK-student-dataset/photo/f-013-01 f-013-01
+CUHK-student-dataset/photo/f-014-01 f-014-01
+CUHK-student-dataset/photo/f-015-01 f-015-01
+CUHK-student-dataset/photo/f-016-01 f-016-01
+CUHK-student-dataset/photo/f-017-01 f-017-01
+CUHK-student-dataset/photo/f-018-01 f-018-01
+CUHK-student-dataset/photo/f-019-01 f-019-01
+CUHK-student-dataset/photo/f-020-01 f-020-01
+CUHK-student-dataset/photo/f-021-01 f-021-01
+CUHK-student-dataset/photo/f-022-01 f-022-01
+CUHK-student-dataset/photo/f-023-01 f-023-01
+CUHK-student-dataset/photo/f-024-01 f-024-01
+CUHK-student-dataset/photo/f-025-01 f-025-01
+CUHK-student-dataset/photo/f-026-01 f-026-01
+CUHK-student-dataset/photo/f-027-01 f-027-01
+CUHK-student-dataset/photo/f-028-01 f-028-01
+CUHK-student-dataset/photo/f-029-01 f-029-01
+CUHK-student-dataset/photo/f-030-01 f-030-01
+CUHK-student-dataset/photo/f-031-01 f-031-01
+CUHK-student-dataset/photo/f-032-01 f-032-01
+CUHK-student-dataset/photo/f-033-01 f-033-01
+CUHK-student-dataset/photo/f-034-01 f-034-01
+CUHK-student-dataset/photo/f-035-01 f-035-01
+CUHK-student-dataset/photo/f-036-01 f-036-01
+CUHK-student-dataset/photo/f-037-01 f-037-01
+CUHK-student-dataset/photo/f-038-01 f-038-01
+CUHK-student-dataset/photo/f-039-01 f-039-01
+CUHK-student-dataset/photo/f-040-01 f-040-01
+CUHK-student-dataset/photo/f-041-01 f-041-01
+CUHK-student-dataset/photo/f-042-01 f-042-01
+CUHK-student-dataset/photo/f-043-01 f-043-01
+CUHK-student-dataset/photo/f1-001-01 f1-001-01
+CUHK-student-dataset/photo/f1-002-01 f1-002-01
+CUHK-student-dataset/photo/f1-003-01 f1-003-01
+CUHK-student-dataset/photo/f1-004-01 f1-004-01
+CUHK-student-dataset/photo/f1-005-01 f1-005-01
+CUHK-student-dataset/photo/f1-006-01 f1-006-01
+CUHK-student-dataset/photo/f1-007-01 f1-007-01
+CUHK-student-dataset/photo/f1-008-01 f1-008-01
+CUHK-student-dataset/photo/f1-009-01 f1-009-01
+CUHK-student-dataset/photo/f1-010-01 f1-010-01
+CUHK-student-dataset/photo/f1-011-01 f1-011-01
+CUHK-student-dataset/photo/f1-012-01 f1-012-01
+CUHK-student-dataset/photo/f1-013-01 f1-013-01
+CUHK-student-dataset/photo/f1-014-01 f1-014-01
+CUHK-student-dataset/photo/f1-015-01 f1-015-01
+CUHK-student-dataset/photo/m-008-01 m-008-01
+CUHK-student-dataset/photo/m-009-01 m-009-01
+CUHK-student-dataset/photo/m-010-01 m-010-01
+CUHK-student-dataset/photo/m-011-01 m-011-01
+CUHK-student-dataset/photo/m-012-01 m-012-01
+CUHK-student-dataset/photo/m-013-01 m-013-01
+CUHK-student-dataset/photo/m-014-01 m-014-01
+CUHK-student-dataset/photo/m-015-01 m-015-01
+CUHK-student-dataset/photo/m-016-01 m-016-01
+CUHK-student-dataset/photo/m-017-01 m-017-01
+CUHK-student-dataset/photo/m-018-01 m-018-01
+CUHK-student-dataset/photo/m-019-01 m-019-01
+CUHK-student-dataset/photo/m-021-01 m-021-01
+CUHK-student-dataset/photo/m-022-01 m-022-01
+CUHK-student-dataset/photo/m-023-01 m-023-01
+CUHK-student-dataset/photo/m-024-01 m-024-01
+CUHK-student-dataset/photo/m-025-01 m-025-01
+CUHK-student-dataset/photo/m-026-01 m-026-01
+CUHK-student-dataset/photo/m-027-01 m-027-01
+CUHK-student-dataset/photo/m-028-01 m-028-01
+CUHK-student-dataset/photo/m-029-01 m-029-01
+CUHK-student-dataset/photo/m-030-01 m-030-01
+CUHK-student-dataset/photo/m-031-01 m-031-01
+CUHK-student-dataset/photo/m-032-01 m-032-01
+CUHK-student-dataset/photo/m-033-01 m-033-01
+CUHK-student-dataset/photo/m-034-01 m-034-01
+CUHK-student-dataset/photo/m-035-01 m-035-01
+CUHK-student-dataset/photo/m-036-01 m-036-01
+CUHK-student-dataset/photo/m-037-01 m-037-01
+CUHK-student-dataset/photo/m-038-01 m-038-01
+CUHK-student-dataset/photo/m-039-01 m-039-01
+CUHK-student-dataset/photo/m-040-01 m-040-01
+CUHK-student-dataset/photo/m-041-01 m-041-01
+CUHK-student-dataset/photo/m-042-01 m-042-01
+CUHK-student-dataset/photo/m-043-01 m-043-01
+CUHK-student-dataset/photo/m-044-01 m-044-01
+CUHK-student-dataset/photo/m-045-01 m-045-01
+CUHK-student-dataset/photo/m-046-01 m-046-01
+CUHK-student-dataset/photo/m-047-01 m-047-01
+CUHK-student-dataset/photo/m-048-01 m-048-01
+CUHK-student-dataset/photo/m-049-01 m-049-01
+CUHK-student-dataset/photo/m-050-01 m-050-01
+CUHK-student-dataset/photo/m-051-01 m-051-01
+CUHK-student-dataset/photo/m-052-01 m-052-01
+CUHK-student-dataset/photo/m-053-01 m-053-01
+CUHK-student-dataset/photo/m-054-01 m-054-01
+CUHK-student-dataset/photo/m-055-01 m-055-01
+CUHK-student-dataset/photo/m-056-01 m-056-01
+CUHK-student-dataset/photo/m-057-01 m-057-01
+CUHK-student-dataset/photo/m-058-01 m-058-01
+CUHK-student-dataset/photo/m-059-01 m-059-01
+CUHK-student-dataset/photo/m-060-01 m-060-01
+CUHK-student-dataset/photo/m-061-01 m-061-01
+CUHK-student-dataset/photo/m-062-01 m-062-01
+CUHK-student-dataset/photo/m-063-01 m-063-01
+CUHK-student-dataset/photo/m-064-01 m-064-01
+CUHK-student-dataset/photo/m-065-01 m-065-01
+CUHK-student-dataset/photo/m-066-01 m-066-01
+CUHK-student-dataset/photo/m-067-01 m-067-01
+CUHK-student-dataset/photo/m-068-01 m-068-01
+CUHK-student-dataset/photo/m-069-01 m-069-01
+CUHK-student-dataset/photo/m-070-01 m-070-01
+CUHK-student-dataset/photo/m-071-01 m-071-01
+CUHK-student-dataset/photo/m-072-01 m-072-01
+CUHK-student-dataset/photo/m-073-01 m-073-01
+CUHK-student-dataset/photo/m-074-01 m-074-01
+CUHK-student-dataset/photo/m-075-01 m-075-01
+CUHK-student-dataset/photo/m-076-01 m-076-01
+CUHK-student-dataset/photo/m-077-01 m-077-01
+CUHK-student-dataset/photo/m-078-01 m-078-01
+CUHK-student-dataset/photo/m-079-01 m-079-01
+CUHK-student-dataset/photo/m-080-01 m-080-01
+CUHK-student-dataset/photo/m-081-01 m-081-01
+CUHK-student-dataset/photo/m-082-01 m-082-01
+CUHK-student-dataset/photo/m-083-01 m-083-01
+CUHK-student-dataset/photo/m-084-01 m-084-01
+CUHK-student-dataset/photo/m-085-01 m-085-01
+CUHK-student-dataset/photo/m-086-01 m-086-01
+CUHK-student-dataset/photo/m-087-01 m-087-01
+CUHK-student-dataset/photo/m-088-01 m-088-01
+CUHK-student-dataset/photo/m-089-01 m-089-01
+CUHK-student-dataset/photo/m-090-01 m-090-01
+CUHK-student-dataset/photo/m-091-01 m-091-01
+CUHK-student-dataset/photo/m-092-01 m-092-01
+CUHK-student-dataset/photo/m-093-01 m-093-01
+CUHK-student-dataset/photo/m-094-01 m-094-01
+CUHK-student-dataset/photo/m-095-01 m-095-01
+CUHK-student-dataset/photo/m-096-01 m-096-01
+CUHK-student-dataset/photo/m-097-01 m-097-01
+CUHK-student-dataset/photo/m-098-01 m-098-01
+CUHK-student-dataset/photo/m-099-01 m-099-01
+CUHK-student-dataset/photo/m-100-01 m-100-01
+CUHK-student-dataset/photo/m1-001-01 m1-001-01
+CUHK-student-dataset/photo/m1-002-01 m1-002-01
+CUHK-student-dataset/photo/m1-003-01 m1-003-01
+CUHK-student-dataset/photo/m1-004-01 m1-004-01
+CUHK-student-dataset/photo/m1-005-01 m1-005-01
+CUHK-student-dataset/photo/m1-006-01 m1-006-01
+CUHK-student-dataset/photo/m1-007-01 m1-007-01
+CUHK-student-dataset/photo/m1-008-01 m1-008-01
+CUHK-student-dataset/photo/m1-009-01 m1-009-01
+CUHK-student-dataset/photo/m1-010-01 m1-010-01
+CUHK-student-dataset/photo/m-101-01 m-101-01
+CUHK-student-dataset/photo/m1-011-01 m1-011-01
+CUHK-student-dataset/photo/m1-012-01 m1-012-01
+CUHK-student-dataset/photo/m1-013-01 m1-013-01
+CUHK-student-dataset/photo/m1-014-01 m1-014-01
+CUHK-student-dataset/photo/m1-015-01 m1-015-01
+CUHK-student-dataset/photo/m1-016-01 m1-016-01
+CUHK-student-dataset/photo/m1-017-01 m1-017-01
+CUHK-student-dataset/photo/m1-018-01 m1-018-01
+CUHK-student-dataset/photo/m1-019-01 m1-019-01
+CUHK-student-dataset/photo/m1-020-01 m1-020-01
+CUHK-student-dataset/photo/m1-021-01 m1-021-01
+CUHK-student-dataset/photo/m1-022-01 m1-022-01
+CUHK-student-dataset/photo/m1-023-01 m1-023-01
+CUHK-student-dataset/photo/m1-024-01 m1-024-01
+CUHK-student-dataset/photo/m1-025-01 m1-025-01
+CUHK-student-dataset/photo/m1-026-01 m1-026-01
+CUHK-student-dataset/photo/m1-027-01 m1-027-01
+CUHK-student-dataset/photo/m1-028-01 m1-028-01
+CUHK-student-dataset/photo/m1-029-01 m1-029-01
+CUHK-student-dataset/photo/m1-030-01 m1-030-01
+CUHK-student-dataset/photo/m1-031-01 m1-031-01
+CUHK-student-dataset/photo/m1-032-01 m1-032-01
+CUHK-student-dataset/photo/m1-033-01 m1-033-01
+CUHK-student-dataset/photo/m1-034-01 m1-034-01
+CUHK-student-dataset/photo/m1-035-01 m1-035-01
+CUHK-student-dataset/photo/m1-036-01 m1-036-01
+CUHK-student-dataset/photo/m1-037-01 m1-037-01
+CUHK-student-dataset/photo/m1-038-01 m1-038-01
+CUHK-student-dataset/photo/m1-039-01 m1-039-01
+CUHK-student-dataset/photo/m1-040-01 m1-040-01
+CUHK-student-dataset/photo/m1-041-01 m1-041-01
diff --git a/bob/db/cuhk/models.py b/bob/db/cuhk/models.py
index 22ea0876e7191027409a4e055c1060ac8934f8b8..2a955734b67f35cc271135f274b34e7c9b84088a 100644
--- a/bob/db/cuhk/models.py
+++ b/bob/db/cuhk/models.py
@@ -75,7 +75,7 @@ class Client(Base):
     self.original_database = original_database
 
   def __repr__(self):
-    return "<Client('%d', '%s', '%s')>" % self.id, self.original_database, self.original_id
+    return "<Client({0}, {1}, {2})>".format(self.id, self.original_database, self.original_id)
 
 
 class File(Base, bob.db.verification.utils.File):
@@ -89,20 +89,33 @@ class File(Base, bob.db.verification.utils.File):
 
   modality_choices = ('photo', 'sketch')
 
-  id        = Column(String(100), primary_key=True)
+  id        = Column(String(100), primary_key=True, autoincrement=True)
   path      = Column(String(100), unique=True)
   client_id = Column(Integer, ForeignKey('client.id'))
   modality  = Column(Enum(*modality_choices))
 
   # a back-reference from the client class to a list of files
   client      = relationship("Client", backref=backref("file", order_by=id))
-  annotations = relationship("Annotation", backref=backref("file"), uselist=True)
+  all_annotations = relationship("Annotation", backref=backref("file"), uselist=True)
 
-  def __init__(self, id, image_name, client_id):
+  def __init__(self, id, image_name, client_id, modality):
     # call base class constructor
     bob.db.verification.utils.File.__init__(self, file_id = id, client_id = client_id, path = image_name)
-    
+    #bob.db.verification.utils.File.__init__(self, client_id = client_id, path = image_name)
+    self.modality = modality
+
+  def annotations(self, annotation_type="eyes_center"):
+    if annotation_type=="eyes_center":
+      return {'reye' : (self.all_annotations[16].y, self.all_annotations[16].x), 'leye' : (self.all_annotations[18].y, self.all_annotations[18].x) }
+    else:      
+      data = {}
+      for i in range(len(self.all_annotations)):
+        a = self.all_annotations[i]
+        data[i] = (a.y, a.x)
+ 
+      return data
 
+    
 
 class Annotation(Base):
   """
@@ -121,8 +134,8 @@ class Annotation(Base):
   x = Column(Integer, primary_key=True)
   y = Column(Integer, primary_key=True)  
 
-  def __init__(self, annotation, x,y):
-    self.annotation = annotation
+  def __init__(self, file_id, x,y):
+    self.file_id = file_id
     self.x          = x
     self.y          = y
 
diff --git a/bob/db/cuhk/utils.py b/bob/db/cuhk/utils.py
index fa7c906899690dfa6b5ba825ccf562d15a2bc48e..805c5c818a7e4a537e950b7522ef883f20ae91b8 100644
--- a/bob/db/cuhk/utils.py
+++ b/bob/db/cuhk/utils.py
@@ -9,74 +9,354 @@ This file has some utilities to deal with the files provided by the database
 """
 
 import os
+import bob.db.arface
+
+def read_annotations(file_name):
+  """
+  Read the annotations in the format
+
+  X Y\n
+  X Y\n
+  .
+  .
+  .
+  """
+  original_annotations = open(file_name).readlines()
+  annotations         = []
+  
+  for a in original_annotations:
+    a = a.rstrip("\n").rstrip("\r")
+    data = a.split(" ")
+    if(len(data)!=2): #NEED TO HAVE ONLY 2 COORDINATES
+      continue
+    else:
+      annotations.append(data)
+
+  return annotations
+
+
 class ARFACEWrapper():
   """
   Utility functions to deal with the AR Face database.
   """
 
-  @staticmethod
-  def get_clients(file_name=os.path.join(os.path.curdir,"bob","db","cuhk","AR_file_names_of_photos.txt")):
+  def __init__(self, 
+      photo_file_name=os.path.join(os.path.curdir,"bob","db","cuhk","data","AR_file_names_of_photos.txt"),
+      sketch_file_name=os.path.join(os.path.curdir,"bob","db","cuhk","data","AR_file_names_of_sketches.txt")
+   ):
+
+    self.m_photo_file_name  = photo_file_name
+    self.m_sketch_file_name = sketch_file_name
+
+
+  def get_clients(self):
     """
     Basically read the input file and extract the clients from the original file_name
     """
-    raw_clients = open(file_name).readlines()
+    raw_clients = open(self.m_photo_file_name).readlines()
     clients = []
     for c in raw_clients:
       clients.append(c[5:10])
     
     return clients
 
-  @staticmethod 
-  def get_gender_from_client_id(client_id):
+  
+  def get_gender_from_client_id(self,client_id):
     return 'man' if client_id[0]=='m' else 'woman'
 
 
+  def get_annotations(self, annotation_dir, annotation_extension='.dat'):
+    """
+    Get the annotation objects
+    """
+
+    db = bob.db.cuhk.Database()
+    annotations = []
+
+    #import ipdb; ipdb.set_trace();
+ 
+    for o in db.query(bob.db.cuhk.File).join(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_database=="arface"):
+      #making the path
+      if(o.modality=="sketch"):
+        path = os.path.join(annotation_dir, o.path) + annotation_extension
+      else:
+        path = os.path.join(annotation_dir,"ARFACE", "photo", o.path) + annotation_extension
+
+      #Reading the annotation file
+      original_annotations = read_annotations(path)
+      for a in original_annotations:
+        
+        annotations.append(bob.db.cuhk.Annotation(o.id, 
+                                                  a[0],
+                                                  a[1]
+                                                 ))
+    return annotations
+
+
+  def get_files_from_modality(self, modality):
+    """
+    For a given modality, get the correct file object.
+
+    If modality=='photo', all the information will be taken from bob.db.arface
+    else, the data will be read from the original data files
+
+    **Parameters**
+
+      modality: Modality (photo | sketch)
+
+      clients: The list of bob.db.cuhk.clients
+
+    """
+
+    files = []
+    if(modality=='photo'):
+      db = bob.db.arface.Database()
+      
+      #Parsing the provided data
+      raw_files = open(self.m_photo_file_name).readlines()
+      original_files = []      
+      for f in raw_files:
+        original_files.append(f[5:12])
+
+      #Searching in the original database
+      original_files = db.files(ids=original_files)
+      for f in original_files:
+        #self, id, image_name, client_id, modality        
+        client = bob.db.cuhk.Database().query(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_id == f.id[0:5])
+        assert client.count() == 1
+        client = client[0]
+        files.append(bob.db.cuhk.File(id = 0,
+                                      client_id=client.id,
+                                      image_name=f.path,
+                                      modality = 'photo'
+                                      )
+                                     )
+ 
+
+    else:
+      #Parsing the provided data
+      raw_files = open(self.m_sketch_file_name).readlines()
+      for f in raw_files:
+        f = f.rstrip("\n")
+        original_client_id = f[0] + f[2:6] #the original client id is [m|w]-number
+        client = bob.db.cuhk.Database().query(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_id == original_client_id.lower()) #GEtting the client_id
+        assert client.count() == 1
+        client = client[0]
+
+        f = os.path.join("ARFACE","sketch",f)
+        files.append(bob.db.cuhk.File(id         = 0,
+                                      client_id  = client.id,
+                                      image_name = f,
+                                      modality   = 'sketch'
+                                      )
+                                     )
+
+    return files    
+
+
 
 class XM2VTSWrapper():
   """
   Utility functions to deal with the XM2VTS database.
   """
 
-  @staticmethod
-  def get_clients(file_name=os.path.join(os.path.curdir,"bob","db","cuhk","XM2VTS_file_names_of_photos.txt")):
+  def __init__(self, 
+      photo_file_name=os.path.join(os.path.curdir,"bob","db","cuhk","data","XM2VTS_file_names_of_photos.txt"),
+      sketch_file_name=os.path.join(os.path.curdir,"bob","db","cuhk","data","XM2VTS_file_names_of_sketches.txt")
+   ):
+
+    self.m_photo_file_name  = photo_file_name
+    self.m_sketch_file_name = sketch_file_name
+
+
+
+  def get_clients(self):
     """
     Basically read the input file and extract the clients from the original file_name
     """
-    raw_clients = open(file_name).readlines()
+    raw_clients = open(self.m_photo_file_name).readlines()
     clients = []
     for c in raw_clients:
       clients.append(c[5:8])
     
     return clients
 
-  @staticmethod 
-  def get_gender():
+  def get_gender(self):
     return 'none'
 
 
+
+  def get_annotations(self, annotation_dir, annotation_extension='.dat'):
+    """
+    Get the annotation objects
+    """
+
+    db = bob.db.cuhk.Database()
+    annotations = []
+ 
+    for o in db.query(bob.db.cuhk.File).join(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_database=="xm2vts"):
+      #making the path
+      if(o.modality=="sketch"):
+        path = os.path.join(annotation_dir, o.path) + annotation_extension
+      else:
+        #import ipdb; ipdb.set_trace();
+        file_name = o.path.split("/")[2] #THE ORIGINAL XM2VTS RELATIVE PATH IS: XXX\XXX\XXX
+        path = os.path.join(annotation_dir,"xm2vts", "photo", file_name) + "_f02" +  annotation_extension #FOR SOME REASON THE AUTHORS SET THIS '_f02 IN THE END OF THE FILE'
+
+      #Reading the annotation file
+      original_annotations = read_annotations(path)
+      for a in original_annotations:
+        
+        annotations.append(bob.db.cuhk.Annotation(o.id, 
+                                                  a[0],
+                                                  a[1]
+                                                 ))
+    return annotations
+
+
+
+
+  def get_files_from_modality(self, modality):
+    """
+    For a given modality, get the correct file object.
+
+    If modality=='photo', all the information will be taken from bob.db.arface
+    else, the data will be read from the original data files
+
+    **Parameters**
+
+      modality: Modality (photo | sketch)
+
+      clients: The list of bob.db.cuhk.clients
+
+    """
+
+    files = []
+    if(modality=='photo'):
+      db = bob.db.xm2vts.Database()
+      
+      #Parsing the provided data
+      raw_files = open(self.m_photo_file_name).readlines()
+      original_files = []      
+      for f in raw_files:
+        original_files.append(f[5:12])
+
+      for f in original_files:
+        #getting the original file object
+        query = db.query(bob.db.xm2vts.File).filter(bob.db.xm2vts.File.path.endswith(f))
+        assert query.count()==1
+        f_obj = query[0] 
+
+        #getting the CUHK-CUFS file
+        client = bob.db.cuhk.Database().query(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_id == f[0:3])
+        assert client.count() == 1
+        client = client[0]
+ 
+        files.append(bob.db.cuhk.File(id = 0,
+                                      client_id=client.id,
+                                      image_name=f_obj.path,
+                                      modality = 'photo'
+                                      )
+                                     )
+ 
+    else:
+      #Parsing the provided data
+      raw_files = open(self.m_sketch_file_name).readlines()
+
+      for f in raw_files:
+        f = f.rstrip("\n")
+        original_client_id = str(int(f[0:3]))        
+        client = bob.db.cuhk.Database().query(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_id == original_client_id)
+        assert client.count() == 1
+        client = client[0]
+
+        f = os.path.join("xm2vts","sketch",f) 
+        files.append(bob.db.cuhk.File(id         = 0,
+                                      client_id  = client.id,
+                                      image_name = f,
+                                      modality   = 'sketch'
+                                      )
+                                     )
+
+    return files    
+
+
+
+
+
 class CUHKWrapper():
   """
   Utility functions to deal with the CUHK database.
   """
 
-  @staticmethod
-  def get_clients(file_name=os.path.join(os.path.curdir,"bob","db","cuhk","all-cuhk.lst")):
+  def __init__(self, 
+      file_name=os.path.join(os.path.curdir,"bob","db","cuhk","data","all-cuhk.txt"),      
+   ):
+
+    self.m_file_name  = file_name
+
+
+  def get_clients(self):
     """
     Basically read the input file and extract the clients from the original file_name
     """
-    raw_clients = open(file_name).readlines()
+    raw_clients = open(self.m_file_name).readlines()
     clients = []
     for c in raw_clients:
       clients.append(c.split(" ")[1].rstrip("\n"))
     
     return list(set(clients))
 
-  @staticmethod 
-  def get_gender_from_client_id(client_id):
+
+  def get_gender_from_client_id(self, client_id):
     return 'man' if client_id[0]=='m' else 'woman'
 
 
 
+  def get_annotations(self, annotation_dir, annotation_extension='.dat'):
+    """
+    Get the annotation objects
+    """
+
+    db = bob.db.cuhk.Database()
+    annotations = []
+ 
+    for o in db.query(bob.db.cuhk.File).join(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_database=="cuhk"):
+      #making the path
+      path = os.path.join(annotation_dir, o.path) + annotation_extension
+
+      #Reading the annotation file
+      original_annotations = read_annotations(path)
+      for a in original_annotations:
+        annotations.append(bob.db.cuhk.Annotation(o.id, 
+                                                  a[0],
+                                                  a[1]
+                                                 ))
+    return annotations
+
+
+  def get_files(self):
+    """
+    Get the correct file object from insert
+    """
+    raw_data = open(self.m_file_name).readlines()
+    files = []
+    for d in raw_data:
+      d = d.rstrip("\n")
+
+      original_client_id = d.split(" ")[1]
+      image_name         = d.split(" ")[0]
+      modality           = 'sketch' if (image_name.find('sketch')>-1) else 'photo'
 
+      client = bob.db.cuhk.Database().query(bob.db.cuhk.Client).filter(bob.db.cuhk.Client.original_id == original_client_id)
+      assert client.count() == 1
+      client = client[0]    
 
+      files.append(bob.db.cuhk.File(id         = 0,
+                                    client_id  = client.id,
+                                    image_name = image_name,
+                                    modality   = modality
+                                    )
+                                   )
 
+    return files