[
  {
    "path": ".gitignore",
    "content": "led / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packaging\n.Python\nenv/\nbuild/\ndevelop-eggs/\ndist/\ndownloads/\neggs/\n.eggs/\nlib/\nlib64/\nparts/\nsdist/\nvar/\nwheels/\n*.egg-info/\n.installed.cfg\n*.egg\n\n# PyInstaller\n#  Usually these files are written by a python script from a template\n#  before PyInstaller builds the exe, so as to inject date/other infos into it.\n*.manifest\n*.spec\n\n# Installer logs\npip-log.txt\npip-delete-this-directory.txt\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*,cover\n.hypothesis/\n\n# Translations\n*.mo\n*.pot\n\n# Django stuff:\n*.log\nlocal_settings.py\n\n# Flask stuff:\ninstance/\n.webassets-cache\n\n# Scrapy stuff:\n.scrapy\n\n# Sphinx documentation\ndocs/_build/\n\n# PyBuilder\ntarget/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# pyenv\n.python-version\n\n# celery beat schedule file\ncelerybeat-schedule\n\n# dotenv\n.env\n\n# virtualenv\n.venv\nvenv/\nENV/\n\n# Spyder project settings\n.spyderproject\n\n# Rope project settings\n.ropeproject\n\n# PyCharm project setting\n.idea\n"
  },
  {
    "path": ".project",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<projectDescription>\n\t<name>facenet</name>\n\t<comment></comment>\n\t<projects>\n\t</projects>\n\t<buildSpec>\n\t\t<buildCommand>\n\t\t\t<name>org.python.pydev.PyDevBuilder</name>\n\t\t\t<arguments>\n\t\t\t</arguments>\n\t\t</buildCommand>\n\t</buildSpec>\n\t<natures>\n\t\t<nature>org.python.pydev.pythonNature</nature>\n\t</natures>\n</projectDescription>\n"
  },
  {
    "path": ".pydevproject",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<?eclipse-pydev version=\"1.0\"?><pydev_project>\n<pydev_pathproperty name=\"org.python.pydev.PROJECT_SOURCE_PATH\">\n<path>/${PROJECT_DIR_NAME}</path>\n<path>/${PROJECT_DIR_NAME}/src</path>\n</pydev_pathproperty>\n<pydev_property name=\"org.python.pydev.PYTHON_PROJECT_VERSION\">python 2.7</pydev_property>\n<pydev_property name=\"org.python.pydev.PYTHON_PROJECT_INTERPRETER\">Default</pydev_property>\n</pydev_project>\n"
  },
  {
    "path": ".pylintrc",
    "content": "[MASTER]\n\n# Specify a configuration file.\n#rcfile=\n\n# Python code to execute, usually for sys.path manipulation such as\n# pygtk.require().\n#init-hook=\n\n# Add files or directories to the blacklist. They should be base names, not\n# paths.\nignore=CVS\n\n# Add files or directories matching the regex patterns to the blacklist. The\n# regex matches against base names, not paths.\nignore-patterns=\n\n# Pickle collected data for later comparisons.\npersistent=yes\n\n# List of plugins (as comma separated values of python modules names) to load,\n# usually to register additional checkers.\nload-plugins=\n\n# Use multiple processes to speed up Pylint.\njobs=1\n\n# Allow loading of arbitrary C extensions. Extensions are imported into the\n# active Python interpreter and may run arbitrary code.\nunsafe-load-any-extension=no\n\n# A comma-separated list of package or module names from where C extensions may\n# be loaded. Extensions are loading into the active Python interpreter and may\n# run arbitrary code\nextension-pkg-whitelist=cv2\n\n# Allow optimization of some AST trees. This will activate a peephole AST\n# optimizer, which will apply various small optimizations. For instance, it can\n# be used to obtain the result of joining multiple strings with the addition\n# operator. Joining a lot of strings can lead to a maximum recursion error in\n# Pylint and this flag can prevent that. It has one side effect, the resulting\n# AST will be different than the one from reality. This option is deprecated\n# and it will be removed in Pylint 2.0.\noptimize-ast=no\n\n\n[MESSAGES CONTROL]\n\n# Only show warnings with the listed confidence levels. Leave empty to show\n# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED\nconfidence=\n\n# Enable the message, report, category or checker with the given id(s). You can\n# either give multiple identifier separated by comma (,) or put this option\n# multiple time (only on the command line, not in the configuration file where\n# it should appear only once). See also the \"--disable\" option for examples.\n#enable=\n\n# Disable the message, report, category or checker with the given id(s). You\n# can either give multiple identifiers separated by comma (,) or put this\n# option multiple times (only on the command line, not in the configuration\n# file where it should appear only once).You can also use \"--disable=all\" to\n# disable everything first and then reenable specific checks. For example, if\n# you want to run only the similarities checker, you can use \"--disable=all\n# --enable=similarities\". If you want to run only the classes checker, but have\n# no Warning level messages displayed, use\"--disable=all --enable=classes\n# --disable=W\"\ndisable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating\n\n\n[REPORTS]\n\n# Set the output format. Available formats are text, parseable, colorized, msvs\n# (visual studio) and html. You can also give a reporter class, eg\n# mypackage.mymodule.MyReporterClass.\noutput-format=text\n\n# Put messages in a separate file for each module / package specified on the\n# command line instead of printing them on stdout. Reports (if any) will be\n# written in a file name \"pylint_global.[txt|html]\". This option is deprecated\n# and it will be removed in Pylint 2.0.\nfiles-output=no\n\n# Tells whether to display a full report or only the messages\nreports=yes\n\n# Python expression which should return a note less than 10 (10 is the highest\n# note). You have access to the variables errors warning, statement which\n# respectively contain the number of errors / warnings messages and the total\n# number of statements analyzed. This is used by the global evaluation report\n# (RP0004).\nevaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)\n\n# Template used to display messages. This is a python new-style format string\n# used to format the message information. See doc for all details\n#msg-template=\n\n\n[BASIC]\n\n# Good variable names which should always be accepted, separated by a comma\ngood-names=i,j,k,ex,Run,_\n\n# Bad variable names which should always be refused, separated by a comma\nbad-names=foo,bar,baz,toto,tutu,tata\n\n# Colon-delimited sets of names that determine each other's naming style when\n# the name regexes allow several styles.\nname-group=\n\n# Include a hint for the correct naming format with invalid-name\ninclude-naming-hint=no\n\n# List of decorators that produce properties, such as abc.abstractproperty. Add\n# to this list to register other decorators that produce valid properties.\nproperty-classes=abc.abstractproperty\n\n# Regular expression matching correct function names\nfunction-rgx=[a-z_][a-z0-9_]{2,30}$\n\n# Naming hint for function names\nfunction-name-hint=[a-z_][a-z0-9_]{2,30}$\n\n# Regular expression matching correct variable names\nvariable-rgx=[a-z_][a-z0-9_]{2,30}$\n\n# Naming hint for variable names\nvariable-name-hint=[a-z_][a-z0-9_]{2,30}$\n\n# Regular expression matching correct constant names\nconst-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$\n\n# Naming hint for constant names\nconst-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$\n\n# Regular expression matching correct attribute names\nattr-rgx=[a-z_][a-z0-9_]{2,30}$\n\n# Naming hint for attribute names\nattr-name-hint=[a-z_][a-z0-9_]{2,30}$\n\n# Regular expression matching correct argument names\nargument-rgx=[a-z_][a-z0-9_]{2,30}$\n\n# Naming hint for argument names\nargument-name-hint=[a-z_][a-z0-9_]{2,30}$\n\n# Regular expression matching correct class attribute names\nclass-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$\n\n# Naming hint for class attribute names\nclass-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$\n\n# Regular expression matching correct inline iteration names\ninlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$\n\n# Naming hint for inline iteration names\ninlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$\n\n# Regular expression matching correct class names\nclass-rgx=[A-Z_][a-zA-Z0-9]+$\n\n# Naming hint for class names\nclass-name-hint=[A-Z_][a-zA-Z0-9]+$\n\n# Regular expression matching correct module names\nmodule-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$\n\n# Naming hint for module names\nmodule-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$\n\n# Regular expression matching correct method names\nmethod-rgx=[a-z_][a-z0-9_]{2,30}$\n\n# Naming hint for method names\nmethod-name-hint=[a-z_][a-z0-9_]{2,30}$\n\n# Regular expression which should only match function or class names that do\n# not require a docstring.\nno-docstring-rgx=^_\n\n# Minimum line length for functions/classes that require docstrings, shorter\n# ones are exempt.\ndocstring-min-length=-1\n\n\n[ELIF]\n\n# Maximum number of nested blocks for function / method body\nmax-nested-blocks=5\n\n\n[FORMAT]\n\n# Maximum number of characters on a single line.\nmax-line-length=100\n\n# Regexp for a line that is allowed to be longer than the limit.\nignore-long-lines=^\\s*(# )?<?https?://\\S+>?$\n\n# Allow the body of an if to be on the same line as the test if there is no\n# else.\nsingle-line-if-stmt=no\n\n# List of optional constructs for which whitespace checking is disabled. `dict-\n# separator` is used to allow tabulation in dicts, etc.: {1  : 1,\\n222: 2}.\n# `trailing-comma` allows a space between comma and closing bracket: (a, ).\n# `empty-line` allows space-only lines.\nno-space-check=trailing-comma,dict-separator\n\n# Maximum number of lines in a module\nmax-module-lines=1000\n\n# String used as indentation unit. This is usually \"    \" (4 spaces) or \"\\t\" (1\n# tab).\nindent-string='    '\n\n# Number of spaces of indent required inside a hanging  or continued line.\nindent-after-paren=4\n\n# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.\nexpected-line-ending-format=\n\n\n[LOGGING]\n\n# Logging modules to check that the string format arguments are in logging\n# function parameter format\nlogging-modules=logging\n\n\n[VARIABLES]\n\n# Tells whether we should check for unused import in __init__ files.\ninit-import=no\n\n# A regular expression matching the name of dummy variables (i.e. expectedly\n# not used).\ndummy-variables-rgx=(_+[a-zA-Z0-9]*?$)|dummy\n\n# List of additional names supposed to be defined in builtins. Remember that\n# you should avoid to define new builtins when possible.\nadditional-builtins=\n\n# List of strings which can identify a callback function by name. A callback\n# name must start or end with one of those strings.\ncallbacks=cb_,_cb\n\n# List of qualified module names which can have objects that can redefine\n# builtins.\nredefining-builtins-modules=six.moves,future.builtins\n\n\n[SPELLING]\n\n# Spelling dictionary name. Available dictionaries: none. To make it working\n# install python-enchant package.\nspelling-dict=\n\n# List of comma separated words that should not be checked.\nspelling-ignore-words=\n\n# A path to a file that contains private dictionary; one word per line.\nspelling-private-dict-file=\n\n# Tells whether to store unknown words to indicated private dictionary in\n# --spelling-private-dict-file option instead of raising a message.\nspelling-store-unknown-words=no\n\n\n[SIMILARITIES]\n\n# Minimum lines number of a similarity.\nmin-similarity-lines=4\n\n# Ignore comments when computing similarities.\nignore-comments=yes\n\n# Ignore docstrings when computing similarities.\nignore-docstrings=yes\n\n# Ignore imports when computing similarities.\nignore-imports=no\n\n\n[MISCELLANEOUS]\n\n# List of note tags to take in consideration, separated by a comma.\nnotes=FIXME,XXX,TODO\n\n\n[TYPECHECK]\n\n# Tells whether missing members accessed in mixin class should be ignored. A\n# mixin class is detected if its name ends with \"mixin\" (case insensitive).\nignore-mixin-members=yes\n\n# List of module names for which member attributes should not be checked\n# (useful for modules/projects where namespaces are manipulated during runtime\n# and thus existing member attributes cannot be deduced by static analysis. It\n# supports qualified module names, as well as Unix pattern matching.\nignored-modules=\n\n# List of class names for which member attributes should not be checked (useful\n# for classes with dynamically set attributes). This supports the use of\n# qualified names.\nignored-classes=optparse.Values,thread._local,_thread._local\n\n# List of members which are set dynamically and missed by pylint inference\n# system, and so shouldn't trigger E1101 when accessed. Python regular\n# expressions are accepted.\ngenerated-members=\n\n# List of decorators that produce context managers, such as\n# contextlib.contextmanager. Add to this list to register other decorators that\n# produce valid context managers.\ncontextmanager-decorators=contextlib.contextmanager\n\n\n[CLASSES]\n\n# List of method names used to declare (i.e. assign) instance attributes.\ndefining-attr-methods=__init__,__new__,setUp\n\n# List of valid names for the first argument in a class method.\nvalid-classmethod-first-arg=cls\n\n# List of valid names for the first argument in a metaclass class method.\nvalid-metaclass-classmethod-first-arg=mcs\n\n# List of member names, which should be excluded from the protected access\n# warning.\nexclude-protected=_asdict,_fields,_replace,_source,_make\n\n\n[DESIGN]\n\n# Maximum number of arguments for function / method\nmax-args=5\n\n# Argument names that match this expression will be ignored. Default to name\n# with leading underscore\nignored-argument-names=_.*\n\n# Maximum number of locals for function / method body\nmax-locals=15\n\n# Maximum number of return / yield for function / method body\nmax-returns=6\n\n# Maximum number of branch for function / method body\nmax-branches=12\n\n# Maximum number of statements in function / method body\nmax-statements=50\n\n# Maximum number of parents for a class (see R0901).\nmax-parents=7\n\n# Maximum number of attributes for a class (see R0902).\nmax-attributes=7\n\n# Minimum number of public methods for a class (see R0903).\nmin-public-methods=2\n\n# Maximum number of public methods for a class (see R0904).\nmax-public-methods=20\n\n# Maximum number of boolean expressions in a if statement\nmax-bool-expr=5\n\n\n[IMPORTS]\n\n# Deprecated modules which should not be used, separated by a comma\ndeprecated-modules=regsub,TERMIOS,Bastion,rexec\n\n# Create a graph of every (i.e. internal and external) dependencies in the\n# given file (report RP0402 must not be disabled)\nimport-graph=\n\n# Create a graph of external dependencies in the given file (report RP0402 must\n# not be disabled)\next-import-graph=\n\n# Create a graph of internal dependencies in the given file (report RP0402 must\n# not be disabled)\nint-import-graph=\n\n# Force import order to recognize a module as part of the standard\n# compatibility libraries.\nknown-standard-library=\n\n# Force import order to recognize a module as part of a third party library.\nknown-third-party=enchant\n\n# Analyse import fallback blocks. This can be used to support both Python 2 and\n# 3 compatible code, which means that the block might have code that exists\n# only in one or another interpreter, leading to false positives when analysed.\nanalyse-fallback-blocks=no\n\n\n[EXCEPTIONS]\n\n# Exceptions that will emit a warning when being caught. Defaults to\n# \"Exception\"\novergeneral-exceptions=Exception\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: python\nsudo: required\npython:\n  - \"2.7\"\n  - \"3.5\"\n# command to install dependencies\ninstall:\n# numpy not using wheel to avoid problem described in \n#  https://github.com/tensorflow/tensorflow/issues/6968\n  - pip install --no-binary numpy --upgrade numpy\n  - pip install -r requirements.txt\n# command to run tests\nscript:\n  - export PYTHONPATH=./src:./src/models:./src/align\n  - python -m unittest discover -s test --pattern=*.py 1>&2\ndist: trusty\n\n"
  },
  {
    "path": "LICENSE.md",
    "content": "MIT License\n\nCopyright (c) 2016 David Sandberg\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# Face Recognition using Tensorflow [![Build Status][travis-image]][travis]\n\n[travis-image]: http://travis-ci.org/davidsandberg/facenet.svg?branch=master\n[travis]: http://travis-ci.org/davidsandberg/facenet\n\nThis is a TensorFlow implementation of the face recognizer described in the paper\n[\"FaceNet: A Unified Embedding for Face Recognition and Clustering\"](http://arxiv.org/abs/1503.03832). The project also uses ideas from the paper [\"Deep Face Recognition\"](http://www.robots.ox.ac.uk/~vgg/publications/2015/Parkhi15/parkhi15.pdf) from the [Visual Geometry Group](http://www.robots.ox.ac.uk/~vgg/) at Oxford.\n\n## Compatibility\nThe code is tested using Tensorflow r1.7 under Ubuntu 14.04 with Python 2.7 and Python 3.5. The test cases can be found [here](https://github.com/davidsandberg/facenet/tree/master/test) and the results can be found [here](http://travis-ci.org/davidsandberg/facenet).\n\n## News\n| Date     | Update |\n|----------|--------|\n| 2018-04-10 | Added new models trained on Casia-WebFace and VGGFace2 (see below). Note that the models uses fixed image standardization (see [wiki](https://github.com/davidsandberg/facenet/wiki/Training-using-the-VGGFace2-dataset)). |\n| 2018-03-31 | Added a new, more flexible input pipeline as well as a bunch of minor updates. |\n| 2017-05-13 | Removed a bunch of older non-slim models. Moved the last bottleneck layer into the respective models. Corrected normalization of Center Loss. |\n| 2017-05-06 | Added code to [train a classifier on your own images](https://github.com/davidsandberg/facenet/wiki/Train-a-classifier-on-own-images). Renamed facenet_train.py to train_tripletloss.py and facenet_train_classifier.py to train_softmax.py. |\n| 2017-03-02 | Added pretrained models that generate 128-dimensional embeddings.|\n| 2017-02-22 | Updated to Tensorflow r1.0. Added Continuous Integration using Travis-CI.|\n| 2017-02-03 | Added models where only trainable variables has been stored in the checkpoint. These are therefore significantly smaller. |\n| 2017-01-27 | Added a model trained on a subset of the MS-Celeb-1M dataset. The LFW accuracy of this model is around 0.994. |\n| 2017&#8209;01&#8209;02 | Updated to run with Tensorflow r0.12. Not sure if it runs with older versions of Tensorflow though.   |\n\n## Pre-trained models\n| Model name      | LFW accuracy | Training dataset | Architecture |\n|-----------------|--------------|------------------|-------------|\n| [20180408-102900](https://drive.google.com/open?id=1R77HmFADxe87GmoLwzfgMu_HY0IhcyBz) | 0.9905        | CASIA-WebFace    | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |\n| [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) | 0.9965        | VGGFace2      | [Inception ResNet v1](https://github.com/davidsandberg/facenet/blob/master/src/models/inception_resnet_v1.py) |\n\nNOTE: If you use any of the models, please do not forget to give proper credit to those providing the training dataset as well.\n\n## Inspiration\nThe code is heavily inspired by the [OpenFace](https://github.com/cmusatyalab/openface) implementation.\n\n## Training data\nThe [CASIA-WebFace](http://www.cbsr.ia.ac.cn/english/CASIA-WebFace-Database.html) dataset has been used for training. This training set consists of total of 453 453 images over 10 575 identities after face detection. Some performance improvement has been seen if the dataset has been filtered before training. Some more information about how this was done will come later.\nThe best performing model has been trained on the [VGGFace2](https://www.robots.ox.ac.uk/~vgg/data/vgg_face2/) dataset consisting of ~3.3M faces and ~9000 classes.\n\n## Pre-processing\n\n### Face alignment using MTCNN\nOne problem with the above approach seems to be that the Dlib face detector misses some of the hard examples (partial occlusion, silhouettes, etc). This makes the training set too \"easy\" which causes the model to perform worse on other benchmarks.\nTo solve this, other face landmark detectors has been tested. One face landmark detector that has proven to work very well in this setting is the\n[Multi-task CNN](https://kpzhang93.github.io/MTCNN_face_detection_alignment/index.html). A Matlab/Caffe implementation can be found [here](https://github.com/kpzhang93/MTCNN_face_detection_alignment) and this has been used for face alignment with very good results. A Python/Tensorflow implementation of MTCNN can be found [here](https://github.com/davidsandberg/facenet/tree/master/src/align). This implementation does not give identical results to the Matlab/Caffe implementation but the performance is very similar.\n\n## Running training\nCurrently, the best results are achieved by training the model using softmax loss. Details on how to train a model using softmax loss on the CASIA-WebFace dataset can be found on the page [Classifier training of Inception-ResNet-v1](https://github.com/davidsandberg/facenet/wiki/Classifier-training-of-inception-resnet-v1) and .\n\n## Pre-trained models\n### Inception-ResNet-v1 model\nA couple of pretrained models are provided. They are trained using softmax loss with the Inception-Resnet-v1 model. The datasets has been aligned using [MTCNN](https://github.com/davidsandberg/facenet/tree/master/src/align).\n\n## Performance\nThe accuracy on LFW for the model [20180402-114759](https://drive.google.com/open?id=1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-) is 0.99650+-0.00252. A description of how to run the test can be found on the page [Validate on LFW](https://github.com/davidsandberg/facenet/wiki/Validate-on-lfw). Note that the input images to the model need to be standardized using fixed image standardization (use the option `--use_fixed_image_standardization` when running e.g. `validate_on_lfw.py`).\n"
  },
  {
    "path": "__init__.py",
    "content": ""
  },
  {
    "path": "contributed/__init__.py",
    "content": ""
  },
  {
    "path": "contributed/batch_represent.py",
    "content": "#!/usr/bin/env python\n# coding=utf-8\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\n\"\"\"\nAllows you to generate embeddings from a directory of images in the format:\n\nInstructions:\n\nImage data directory should look like the following figure:\nperson-1\n├── image-1.jpg\n├── image-2.png\n...\n└── image-p.png\n\n...\n\nperson-m\n├── image-1.png\n├── image-2.jpg\n...\n└── image-q.png\n\nTrained Model:\n- Both the trained model metagraph and the model parameters need to exist\nin the same directory, and the metagraph should have the extension '.meta'.\n\n####\nUSAGE:\n$ python batch_represent.py -d <YOUR IMAGE DATA DIRECTORY> -o <DIRECTORY TO STORE OUTPUT ARRAYS> --trained_model_dir <DIRECTORY CONTAINING PRETRAINED MODEL>\n###\n\"\"\"\n\n\"\"\"\nAttributions:\nThe code is heavily inspired by the code from by David Sandberg's ../src/validate_on_lfw.py\nThe concept is inspired by Brandon Amos' github.com/cmusatyalab/openface/blob/master/batch-represent/batch-represent.lua\n\"\"\"\n\n#----------------------------------------------------\n# MIT License\n#\n# Copyright (c) 2017 Rakshak Talwar\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n#----------------------------------------------------\n\nimport os\nimport sys\nimport argparse\nimport importlib\nimport time\n\nsys.path.insert(1, \"../src\")\nimport facenet\nimport numpy as np\nfrom sklearn.datasets import load_files\nimport tensorflow as tf\nfrom six.moves import xrange\n\ndef main(args):\n\n\twith tf.Graph().as_default():\n\n\t\twith tf.Session() as sess:\n\n\t\t\t# create output directory if it doesn't exist\n\t\t\toutput_dir = os.path.expanduser(args.output_dir)\n\t\t\tif not os.path.isdir(output_dir):\n\t\t\t\tos.makedirs(output_dir)\n\n\t\t\t# load the model\n\t\t\tprint(\"Loading trained model...\\n\")\n\t\t\tmeta_file, ckpt_file = facenet.get_model_filenames(os.path.expanduser(args.trained_model_dir))\n\t\t\tfacenet.load_model(args.trained_model_dir, meta_file, ckpt_file)\n\n\t\t\t# grab all image paths and labels\n\t\t\tprint(\"Finding image paths and targets...\\n\")\n\t\t\tdata = load_files(args.data_dir, load_content=False, shuffle=False)\n\t\t\tlabels_array = data['target']\n\t\t\tpaths = data['filenames']\n\n\t\t\t# Get input and output tensors\n\t\t\timages_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n\t\t\tembeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n\t\t\tphase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n\n\t\t\timage_size = images_placeholder.get_shape()[1]\n\t\t\tembedding_size = embeddings.get_shape()[1]\n\n\t\t\t# Run forward pass to calculate embeddings\n\t\t\tprint('Generating embeddings from images...\\n')\n\t\t\tstart_time = time.time()\n\t\t\tbatch_size = args.batch_size\n\t\t\tnrof_images = len(paths)\n\t\t\tnrof_batches = int(np.ceil(1.0*nrof_images / batch_size))\n\t\t\temb_array = np.zeros((nrof_images, embedding_size))\n\t\t\tfor i in xrange(nrof_batches):\n\t\t\t\tstart_index = i*batch_size\n\t\t\t\tend_index = min((i+1)*batch_size, nrof_images)\n\t\t\t\tpaths_batch = paths[start_index:end_index]\n\t\t\t\timages = facenet.load_data(paths_batch, do_random_crop=False, do_random_flip=False, image_size=image_size, do_prewhiten=True)\n\t\t\t\tfeed_dict = { images_placeholder:images, phase_train_placeholder:False}\n\t\t\t\temb_array[start_index:end_index,:] = sess.run(embeddings, feed_dict=feed_dict)\n\n\t\t\ttime_avg_forward_pass = (time.time() - start_time) / float(nrof_images)\n\t\t\tprint(\"Forward pass took avg of %.3f[seconds/image] for %d images\\n\" % (time_avg_forward_pass, nrof_images))\n\n\t\t\tprint(\"Finally saving embeddings and gallery to: %s\" % (output_dir))\n\t\t\t# save the gallery and embeddings (signatures) as numpy arrays to disk\n\t\t\tnp.save(os.path.join(output_dir, \"gallery.npy\"), labels_array)\n\t\t\tnp.save(os.path.join(output_dir, \"signatures.npy\"), emb_array)\n\ndef parse_arguments(argv):\n\tparser = argparse.ArgumentParser(description=\"Batch-represent face embeddings from a given data directory\")\n\tparser.add_argument('-d', '--data_dir', type=str,\n\t\thelp='directory of images with structure as seen at the top of this file.')\n\tparser.add_argument('-o', '--output_dir', type=str,\n\t\thelp='directory containing aligned face patches with file structure as seen at the top of this file.')\n\tparser.add_argument('--trained_model_dir', type=str,\n        help='Load a trained model before training starts.')\n\tparser.add_argument('--batch_size', type=int, help='Number of images to process in a batch.', default=50)\n\n\treturn parser.parse_args(argv)\n\n\nif __name__ == \"__main__\":\n\tmain(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "contributed/cluster.py",
    "content": "# MIT License\n#\n# Copyright (c) 2017 PXL University College\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# Clusters similar faces from input folder together in folders based on euclidean distance matrix\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport tensorflow as tf\nimport numpy as np\nimport os\nimport sys\nimport argparse\nimport facenet\nimport align.detect_face\nfrom sklearn.cluster import DBSCAN\n\n\ndef main(args):\n    pnet, rnet, onet = create_network_face_detection(args.gpu_memory_fraction)\n\n    with tf.Graph().as_default():\n\n        with tf.Session() as sess:\n            facenet.load_model(args.model)\n\n            image_list = load_images_from_folder(args.data_dir)\n            images = align_data(image_list, args.image_size, args.margin, pnet, rnet, onet)\n\n            images_placeholder = sess.graph.get_tensor_by_name(\"input:0\")\n            embeddings = sess.graph.get_tensor_by_name(\"embeddings:0\")\n            phase_train_placeholder = sess.graph.get_tensor_by_name(\"phase_train:0\")\n            feed_dict = {images_placeholder: images, phase_train_placeholder: False}\n            emb = sess.run(embeddings, feed_dict=feed_dict)\n\n            nrof_images = len(images)\n\n            matrix = np.zeros((nrof_images, nrof_images))\n\n            print('')\n            # Print distance matrix\n            print('Distance matrix')\n            print('    ', end='')\n            for i in range(nrof_images):\n                print('    %1d     ' % i, end='')\n            print('')\n            for i in range(nrof_images):\n                print('%1d  ' % i, end='')\n                for j in range(nrof_images):\n                    dist = np.sqrt(np.sum(np.square(np.subtract(emb[i, :], emb[j, :]))))\n                    matrix[i][j] = dist\n                    print('  %1.4f  ' % dist, end='')\n                print('')\n\n            print('')\n\n            # DBSCAN is the only algorithm that doesn't require the number of clusters to be defined.\n            db = DBSCAN(eps=args.cluster_threshold, min_samples=args.min_cluster_size, metric='precomputed')\n            db.fit(matrix)\n            labels = db.labels_\n\n            # get number of clusters\n            no_clusters = len(set(labels)) - (1 if -1 in labels else 0)\n\n            print('No of clusters:', no_clusters)\n\n            if no_clusters > 0:\n                if args.largest_cluster_only:\n                    largest_cluster = 0\n                    for i in range(no_clusters):\n                        print('Cluster {}: {}'.format(i, np.nonzero(labels == i)[0]))\n                        if len(np.nonzero(labels == i)[0]) > len(np.nonzero(labels == largest_cluster)[0]):\n                            largest_cluster = i\n                    print('Saving largest cluster (Cluster: {})'.format(largest_cluster))\n                    cnt = 1\n                    for i in np.nonzero(labels == largest_cluster)[0]:\n                        misc.imsave(os.path.join(args.out_dir, str(cnt) + '.png'), images[i])\n                        cnt += 1\n                else:\n                    print('Saving all clusters')\n                    for i in range(no_clusters):\n                        cnt = 1\n                        print('Cluster {}: {}'.format(i, np.nonzero(labels == i)[0]))\n                        path = os.path.join(args.out_dir, str(i))\n                        if not os.path.exists(path):\n                            os.makedirs(path)\n                            for j in np.nonzero(labels == i)[0]:\n                                misc.imsave(os.path.join(path, str(cnt) + '.png'), images[j])\n                                cnt += 1\n                        else:\n                            for j in np.nonzero(labels == i)[0]:\n                                misc.imsave(os.path.join(path, str(cnt) + '.png'), images[j])\n                                cnt += 1\n\n\ndef align_data(image_list, image_size, margin, pnet, rnet, onet):\n    minsize = 20  # minimum size of face\n    threshold = [0.6, 0.7, 0.7]  # three steps's threshold\n    factor = 0.709  # scale factor\n\n    img_list = []\n\n    for x in xrange(len(image_list)):\n        img_size = np.asarray(image_list[x].shape)[0:2]\n        bounding_boxes, _ = align.detect_face.detect_face(image_list[x], minsize, pnet, rnet, onet, threshold, factor)\n        nrof_samples = len(bounding_boxes)\n        if nrof_samples > 0:\n            for i in xrange(nrof_samples):\n                if bounding_boxes[i][4] > 0.95:\n                    det = np.squeeze(bounding_boxes[i, 0:4])\n                    bb = np.zeros(4, dtype=np.int32)\n                    bb[0] = np.maximum(det[0] - margin / 2, 0)\n                    bb[1] = np.maximum(det[1] - margin / 2, 0)\n                    bb[2] = np.minimum(det[2] + margin / 2, img_size[1])\n                    bb[3] = np.minimum(det[3] + margin / 2, img_size[0])\n                    cropped = image_list[x][bb[1]:bb[3], bb[0]:bb[2], :]\n                    aligned = misc.imresize(cropped, (image_size, image_size), interp='bilinear')\n                    prewhitened = facenet.prewhiten(aligned)\n                    img_list.append(prewhitened)\n\n    if len(img_list) > 0:\n        images = np.stack(img_list)\n        return images\n    else:\n        return None\n\n\ndef create_network_face_detection(gpu_memory_fraction):\n    with tf.Graph().as_default():\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        with sess.as_default():\n            pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)\n    return pnet, rnet, onet\n\n\ndef load_images_from_folder(folder):\n    images = []\n    for filename in os.listdir(folder):\n        img = misc.imread(os.path.join(folder, filename))\n        if img is not None:\n            images.append(img)\n    return images\n\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n\n    parser.add_argument('model', type=str,\n                        help='Either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')\n    parser.add_argument('data_dir', type=str,\n                        help='The directory containing the images to cluster into folders.')\n    parser.add_argument('out_dir', type=str,\n                        help='The output directory where the image clusters will be saved.')\n    parser.add_argument('--image_size', type=int,\n                        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--margin', type=int,\n                        help='Margin for the crop around the bounding box (height, width) in pixels.', default=44)\n    parser.add_argument('--min_cluster_size', type=int,\n                        help='The minimum amount of pictures required for a cluster.', default=1)\n    parser.add_argument('--cluster_threshold', type=float,\n                        help='The minimum distance for faces to be in the same cluster', default=1.0)\n    parser.add_argument('--largest_cluster_only', action='store_true',\n                        help='This argument will make that only the biggest cluster is saved.')\n    parser.add_argument('--gpu_memory_fraction', type=float,\n                        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n\n    return parser.parse_args(argv)\n\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "contributed/clustering.py",
    "content": "\"\"\" Face Cluster \"\"\"\nimport tensorflow as tf\nimport numpy as np\nimport importlib\nimport argparse\nimport facenet\nimport os\nimport math\ndef face_distance(face_encodings, face_to_compare):\n    \"\"\"\n    Given a list of face encodings, compare them to a known face encoding and get a euclidean distance\n    for each comparison face. The distance tells you how similar the faces are.\n    :param faces: List of face encodings to compare\n    :param face_to_compare: A face encoding to compare against\n    :return: A numpy ndarray with the distance for each face in the same order as the 'faces' array\n    \"\"\"\n    import numpy as np\n    if len(face_encodings) == 0:\n        return np.empty((0))\n\n    #return 1/np.linalg.norm(face_encodings - face_to_compare, axis=1)\n    return np.sum(face_encodings*face_to_compare,axis=1)\n\ndef load_model(model_dir, meta_file, ckpt_file):\n    model_dir_exp = os.path.expanduser(model_dir)\n    saver = tf.train.import_meta_graph(os.path.join(model_dir_exp, meta_file))\n    saver.restore(tf.get_default_session(), os.path.join(model_dir_exp, ckpt_file))\n\ndef _chinese_whispers(encoding_list, threshold=0.55, iterations=20):\n    \"\"\" Chinese Whispers Algorithm\n\n    Modified from Alex Loveless' implementation,\n    http://alexloveless.co.uk/data/chinese-whispers-graph-clustering-in-python/\n\n    Inputs:\n        encoding_list: a list of facial encodings from face_recognition\n        threshold: facial match threshold,default 0.6\n        iterations: since chinese whispers is an iterative algorithm, number of times to iterate\n\n    Outputs:\n        sorted_clusters: a list of clusters, a cluster being a list of imagepaths,\n            sorted by largest cluster to smallest\n    \"\"\"\n\n    #from face_recognition.api import _face_distance\n    from random import shuffle\n    import networkx as nx\n    # Create graph\n    nodes = []\n    edges = []\n\n    image_paths, encodings = zip(*encoding_list)\n\n    if len(encodings) <= 1:\n        print (\"No enough encodings to cluster!\")\n        return []\n\n    for idx, face_encoding_to_check in enumerate(encodings):\n        # Adding node of facial encoding\n        node_id = idx+1\n\n        # Initialize 'cluster' to unique value (cluster of itself)\n        node = (node_id, {'cluster': image_paths[idx], 'path': image_paths[idx]})\n        nodes.append(node)\n\n        # Facial encodings to compare\n        if (idx+1) >= len(encodings):\n            # Node is last element, don't create edge\n            break\n\n        compare_encodings = encodings[idx+1:]\n        distances = face_distance(compare_encodings, face_encoding_to_check)\n        encoding_edges = []\n        for i, distance in enumerate(distances):\n            if distance > threshold:\n                # Add edge if facial match\n                edge_id = idx+i+2\n                encoding_edges.append((node_id, edge_id, {'weight': distance}))\n\n        edges = edges + encoding_edges\n\n    G = nx.Graph()\n    G.add_nodes_from(nodes)\n    G.add_edges_from(edges)\n\n    # Iterate\n    for _ in range(0, iterations):\n        cluster_nodes = G.nodes()\n        shuffle(cluster_nodes)\n        for node in cluster_nodes:\n            neighbors = G[node]\n            clusters = {}\n\n            for ne in neighbors:\n                if isinstance(ne, int):\n                    if G.node[ne]['cluster'] in clusters:\n                        clusters[G.node[ne]['cluster']] += G[node][ne]['weight']\n                    else:\n                        clusters[G.node[ne]['cluster']] = G[node][ne]['weight']\n\n            # find the class with the highest edge weight sum\n            edge_weight_sum = 0\n            max_cluster = 0\n            #use the max sum of neighbor weights class as current node's class\n            for cluster in clusters:\n                if clusters[cluster] > edge_weight_sum:\n                    edge_weight_sum = clusters[cluster]\n                    max_cluster = cluster\n\n            # set the class of target node to the winning local class\n            G.node[node]['cluster'] = max_cluster\n\n    clusters = {}\n\n    # Prepare cluster output\n    for (_, data) in G.node.items():\n        cluster = data['cluster']\n        path = data['path']\n\n        if cluster:\n            if cluster not in clusters:\n                clusters[cluster] = []\n            clusters[cluster].append(path)\n\n    # Sort cluster output\n    sorted_clusters = sorted(clusters.values(), key=len, reverse=True)\n\n    return sorted_clusters\n\ndef cluster_facial_encodings(facial_encodings):\n    \"\"\" Cluster facial encodings\n\n        Intended to be an optional switch for different clustering algorithms, as of right now\n        only chinese whispers is available.\n\n        Input:\n            facial_encodings: (image_path, facial_encoding) dictionary of facial encodings\n\n        Output:\n            sorted_clusters: a list of clusters, a cluster being a list of imagepaths,\n                sorted by largest cluster to smallest\n\n    \"\"\"\n\n    if len(facial_encodings) <= 1:\n        print (\"Number of facial encodings must be greater than one, can't cluster\")\n        return []\n\n    # Only use the chinese whispers algorithm for now\n    sorted_clusters = _chinese_whispers(facial_encodings.items())\n    return sorted_clusters\n\ndef compute_facial_encodings(sess,images_placeholder,embeddings,phase_train_placeholder,image_size,\n                    embedding_size,nrof_images,nrof_batches,emb_array,batch_size,paths):\n    \"\"\" Compute Facial Encodings\n\n        Given a set of images, compute the facial encodings of each face detected in the images and\n        return them. If no faces, or more than one face found, return nothing for that image.\n\n        Inputs:\n            image_paths: a list of image paths\n\n        Outputs:\n            facial_encodings: (image_path, facial_encoding) dictionary of facial encodings\n\n    \"\"\"\n\n    for i in range(nrof_batches):\n        start_index = i*batch_size\n        end_index = min((i+1)*batch_size, nrof_images)\n        paths_batch = paths[start_index:end_index]\n        images = facenet.load_data(paths_batch, False, False, image_size)\n        feed_dict = { images_placeholder:images, phase_train_placeholder:False }\n        emb_array[start_index:end_index,:] = sess.run(embeddings, feed_dict=feed_dict)\n\n    facial_encodings = {}\n    for x in range(nrof_images):\n        facial_encodings[paths[x]] = emb_array[x,:]\n\n\n    return facial_encodings\n\ndef get_onedir(paths):\n    dataset = []\n    path_exp = os.path.expanduser(paths)\n    if os.path.isdir(path_exp):\n        images = os.listdir(path_exp)\n        image_paths = [os.path.join(path_exp,img) for img in images]\n\n        for x in image_paths:\n            if os.path.getsize(x)>0:\n                dataset.append(x)\n        \n    return dataset \n\n\ndef main(args):\n    \"\"\" Main\n\n    Given a list of images, save out facial encoding data files and copy\n    images into folders of face clusters.\n\n    \"\"\"\n    from os.path import join, basename, exists\n    from os import makedirs\n    import numpy as np\n    import shutil\n    import sys\n\n    if not exists(args.output):\n        makedirs(args.output)\n\n    with tf.Graph().as_default():\n        with tf.Session() as sess:\n            image_paths = get_onedir(args.input)\n            #image_list, label_list = facenet.get_image_paths_and_labels(train_set)\n\n            meta_file, ckpt_file = facenet.get_model_filenames(os.path.expanduser(args.model_dir))\n            \n            print('Metagraph file: %s' % meta_file)\n            print('Checkpoint file: %s' % ckpt_file)\n            load_model(args.model_dir, meta_file, ckpt_file)\n            \n            # Get input and output tensors\n            images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n            \n            image_size = images_placeholder.get_shape()[1]\n            print(\"image_size:\",image_size)\n            embedding_size = embeddings.get_shape()[1]\n        \n            # Run forward pass to calculate embeddings\n            print('Runnning forward pass on images') \n\n            nrof_images = len(image_paths)\n            nrof_batches = int(math.ceil(1.0*nrof_images / args.batch_size))\n            emb_array = np.zeros((nrof_images, embedding_size))\n            facial_encodings = compute_facial_encodings(sess,images_placeholder,embeddings,phase_train_placeholder,image_size,\n                embedding_size,nrof_images,nrof_batches,emb_array,args.batch_size,image_paths)\n            sorted_clusters = cluster_facial_encodings(facial_encodings)\n            num_cluster = len(sorted_clusters)\n                \n            # Copy image files to cluster folders\n            for idx, cluster in enumerate(sorted_clusters):\n                #save all the cluster\n                cluster_dir = join(args.output, str(idx))\n                if not exists(cluster_dir):\n                    makedirs(cluster_dir)\n                for path in cluster:\n                    shutil.copy(path, join(cluster_dir, basename(path)))\n\ndef parse_args():\n    \"\"\"Parse input arguments.\"\"\"\n    import argparse\n    parser = argparse.ArgumentParser(description='Get a shape mesh (t-pose)')\n    parser.add_argument('--model_dir', type=str, help='model dir', required=True)\n    parser.add_argument('--batch_size', type=int, help='batch size', required=30)\n    parser.add_argument('--input', type=str, help='Input dir of images', required=True)\n    parser.add_argument('--output', type=str, help='Output dir of clusters', required=True)\n    args = parser.parse_args()\n\n    return args\n\nif __name__ == '__main__':\n    \"\"\" Entry point \"\"\"\n    main(parse_args())\n"
  },
  {
    "path": "contributed/export_embeddings.py",
    "content": "\"\"\"\nExports the embeddings and labels of a directory of images as numpy arrays.\n\nTypicall usage expect the image directory to be of the openface/facenet form and\nthe images to be aligned. Simply point to your model and your image directory:\n    python facenet/contributed/export_embeddings.py ~/models/facenet/20170216-091149/ ~/datasets/lfw/mylfw\n\nOutput:\nembeddings.npy -- Embeddings as np array, Use --embeddings_name to change name\nlabels.npy -- Integer labels as np array, Use --labels_name to change name\nlabel_strings.npy -- Strings from folders names, --labels_strings_name to change name\n\n\nUse --image_batch to dictacte how many images to load in memory at a time.\n\nIf your images aren't already pre-aligned, use --is_aligned False\n\nI started with compare.py from David Sandberg, and modified it to export\nthe embeddings. The image loading is done use the facenet library if the image\nis pre-aligned. If the image isn't pre-aligned, I use the compare.py function.\nI've found working with the embeddings useful for classifications models.\n\nCharles Jekel 2017\n\n\"\"\"\n\n# MIT License\n#\n# Copyright (c) 2016 David Sandberg\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport time\nfrom scipy import misc\nimport tensorflow as tf\nimport numpy as np\nimport sys\nimport os\nimport argparse\nimport facenet\nimport align.detect_face\nimport glob\n\nfrom six.moves import xrange\n\ndef main(args):\n    train_set = facenet.get_dataset(args.data_dir)\n    image_list, label_list = facenet.get_image_paths_and_labels(train_set)\n    # fetch the classes (labels as strings) exactly as it's done in get_dataset\n    path_exp = os.path.expanduser(args.data_dir)\n    classes = [path for path in os.listdir(path_exp) \\\n               if os.path.isdir(os.path.join(path_exp, path))]\n    classes.sort()\n    # get the label strings\n    label_strings = [name for name in classes if \\\n       os.path.isdir(os.path.join(path_exp, name))]\n\n    with tf.Graph().as_default():\n\n        with tf.Session() as sess:\n\n            # Load the model\n            facenet.load_model(args.model_dir)\n\n            # Get input and output tensors\n            images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n\n            # Run forward pass to calculate embeddings\n            nrof_images = len(image_list)\n            print('Number of images: ', nrof_images)\n            batch_size = args.image_batch\n            if nrof_images % batch_size == 0:\n                nrof_batches = nrof_images // batch_size\n            else:\n                nrof_batches = (nrof_images // batch_size) + 1\n            print('Number of batches: ', nrof_batches)\n            embedding_size = embeddings.get_shape()[1]\n            emb_array = np.zeros((nrof_images, embedding_size))\n            start_time = time.time()\n\n            for i in range(nrof_batches):\n                if i == nrof_batches -1:\n                    n = nrof_images\n                else:\n                    n = i*batch_size + batch_size\n                # Get images for the batch\n                if args.is_aligned is True:\n                    images = facenet.load_data(image_list[i*batch_size:n], False, False, args.image_size)\n                else:\n                    images = load_and_align_data(image_list[i*batch_size:n], args.image_size, args.margin, args.gpu_memory_fraction)\n                feed_dict = { images_placeholder: images, phase_train_placeholder:False }\n                # Use the facenet model to calcualte embeddings\n                embed = sess.run(embeddings, feed_dict=feed_dict)\n                emb_array[i*batch_size:n, :] = embed\n                print('Completed batch', i+1, 'of', nrof_batches)\n\n            run_time = time.time() - start_time\n            print('Run time: ', run_time)\n\n            #   export emedings and labels\n            label_list  = np.array(label_list)\n\n            np.save(args.embeddings_name, emb_array)\n            np.save(args.labels_name, label_list)\n            label_strings = np.array(label_strings)\n            np.save(args.labels_strings_name, label_strings[label_list])\n\n\ndef load_and_align_data(image_paths, image_size, margin, gpu_memory_fraction):\n\n    minsize = 20 # minimum size of face\n    threshold = [ 0.6, 0.7, 0.7 ]  # three steps's threshold\n    factor = 0.709 # scale factor\n\n    print('Creating networks and loading parameters')\n    with tf.Graph().as_default():\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        with sess.as_default():\n            pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)\n\n    nrof_samples = len(image_paths)\n    img_list = [None] * nrof_samples\n    for i in xrange(nrof_samples):\n        print(image_paths[i])\n        img = misc.imread(os.path.expanduser(image_paths[i]))\n        img_size = np.asarray(img.shape)[0:2]\n        bounding_boxes, _ = align.detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)\n        det = np.squeeze(bounding_boxes[0,0:4])\n        bb = np.zeros(4, dtype=np.int32)\n        bb[0] = np.maximum(det[0]-margin/2, 0)\n        bb[1] = np.maximum(det[1]-margin/2, 0)\n        bb[2] = np.minimum(det[2]+margin/2, img_size[1])\n        bb[3] = np.minimum(det[3]+margin/2, img_size[0])\n        cropped = img[bb[1]:bb[3],bb[0]:bb[2],:]\n        aligned = misc.imresize(cropped, (image_size, image_size), interp='bilinear')\n        prewhitened = facenet.prewhiten(aligned)\n        img_list[i] = prewhitened\n    images = np.stack(img_list)\n    return images\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    parser.add_argument('model_dir', type=str,\n        help='Directory containing the meta_file and ckpt_file')\n    parser.add_argument('data_dir', type=str,\n        help='Directory containing images. If images are not already aligned and cropped include --is_aligned False.')\n    parser.add_argument('--is_aligned', type=str,\n        help='Is the data directory already aligned and cropped?', default=True)\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--margin', type=int,\n        help='Margin for the crop around the bounding box (height, width) in pixels.',\n        default=44)\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.',\n        default=1.0)\n    parser.add_argument('--image_batch', type=int,\n        help='Number of images stored in memory at a time. Default 500.',\n        default=500)\n\n    #   numpy file Names\n    parser.add_argument('--embeddings_name', type=str,\n        help='Enter string of which the embeddings numpy array is saved as.',\n        default='embeddings.npy')\n    parser.add_argument('--labels_name', type=str,\n        help='Enter string of which the labels numpy array is saved as.',\n        default='labels.npy')\n    parser.add_argument('--labels_strings_name', type=str,\n        help='Enter string of which the labels as strings numpy array is saved as.',\n        default='label_strings.npy')\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "contributed/face.py",
    "content": "# coding=utf-8\n\"\"\"Face Detection and Recognition\"\"\"\n# MIT License\n#\n# Copyright (c) 2017 François Gervais\n#\n# This is the work of David Sandberg and shanren7 remodelled into a\n# high level container. It's an attempt to simplify the use of such\n# technology and provide an easy to use facial recognition package.\n#\n# https://github.com/davidsandberg/facenet\n# https://github.com/shanren7/real_time_face_recognition\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport pickle\nimport os\n\nimport cv2\nimport numpy as np\nimport tensorflow as tf\nfrom scipy import misc\n\nimport align.detect_face\nimport facenet\n\n\ngpu_memory_fraction = 0.3\nfacenet_model_checkpoint = os.path.dirname(__file__) + \"/../model_checkpoints/20170512-110547\"\nclassifier_model = os.path.dirname(__file__) + \"/../model_checkpoints/my_classifier_1.pkl\"\ndebug = False\n\n\nclass Face:\n    def __init__(self):\n        self.name = None\n        self.bounding_box = None\n        self.image = None\n        self.container_image = None\n        self.embedding = None\n\n\nclass Recognition:\n    def __init__(self):\n        self.detect = Detection()\n        self.encoder = Encoder()\n        self.identifier = Identifier()\n\n    def add_identity(self, image, person_name):\n        faces = self.detect.find_faces(image)\n\n        if len(faces) == 1:\n            face = faces[0]\n            face.name = person_name\n            face.embedding = self.encoder.generate_embedding(face)\n            return faces\n\n    def identify(self, image):\n        faces = self.detect.find_faces(image)\n\n        for i, face in enumerate(faces):\n            if debug:\n                cv2.imshow(\"Face: \" + str(i), face.image)\n            face.embedding = self.encoder.generate_embedding(face)\n            face.name = self.identifier.identify(face)\n\n        return faces\n\n\nclass Identifier:\n    def __init__(self):\n        with open(classifier_model, 'rb') as infile:\n            self.model, self.class_names = pickle.load(infile)\n\n    def identify(self, face):\n        if face.embedding is not None:\n            predictions = self.model.predict_proba([face.embedding])\n            best_class_indices = np.argmax(predictions, axis=1)\n            return self.class_names[best_class_indices[0]]\n\n\nclass Encoder:\n    def __init__(self):\n        self.sess = tf.Session()\n        with self.sess.as_default():\n            facenet.load_model(facenet_model_checkpoint)\n\n    def generate_embedding(self, face):\n        # Get input and output tensors\n        images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n        embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n        phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n\n        prewhiten_face = facenet.prewhiten(face.image)\n\n        # Run forward pass to calculate embeddings\n        feed_dict = {images_placeholder: [prewhiten_face], phase_train_placeholder: False}\n        return self.sess.run(embeddings, feed_dict=feed_dict)[0]\n\n\nclass Detection:\n    # face detection parameters\n    minsize = 20  # minimum size of face\n    threshold = [0.6, 0.7, 0.7]  # three steps's threshold\n    factor = 0.709  # scale factor\n\n    def __init__(self, face_crop_size=160, face_crop_margin=32):\n        self.pnet, self.rnet, self.onet = self._setup_mtcnn()\n        self.face_crop_size = face_crop_size\n        self.face_crop_margin = face_crop_margin\n\n    def _setup_mtcnn(self):\n        with tf.Graph().as_default():\n            gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n            sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n            with sess.as_default():\n                return align.detect_face.create_mtcnn(sess, None)\n\n    def find_faces(self, image):\n        faces = []\n\n        bounding_boxes, _ = align.detect_face.detect_face(image, self.minsize,\n                                                          self.pnet, self.rnet, self.onet,\n                                                          self.threshold, self.factor)\n        for bb in bounding_boxes:\n            face = Face()\n            face.container_image = image\n            face.bounding_box = np.zeros(4, dtype=np.int32)\n\n            img_size = np.asarray(image.shape)[0:2]\n            face.bounding_box[0] = np.maximum(bb[0] - self.face_crop_margin / 2, 0)\n            face.bounding_box[1] = np.maximum(bb[1] - self.face_crop_margin / 2, 0)\n            face.bounding_box[2] = np.minimum(bb[2] + self.face_crop_margin / 2, img_size[1])\n            face.bounding_box[3] = np.minimum(bb[3] + self.face_crop_margin / 2, img_size[0])\n            cropped = image[face.bounding_box[1]:face.bounding_box[3], face.bounding_box[0]:face.bounding_box[2], :]\n            face.image = misc.imresize(cropped, (self.face_crop_size, self.face_crop_size), interp='bilinear')\n\n            faces.append(face)\n\n        return faces\n"
  },
  {
    "path": "contributed/predict.py",
    "content": "\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\n#----------------------------------------------------\n# MIT License\n#\n# Copyright (c) 2017 Rishi Rai\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n#----------------------------------------------------\n\n\nimport tensorflow as tf\nimport numpy as np\nimport argparse\nimport facenet\nimport os\nimport sys\nimport math\nimport pickle\nfrom sklearn.svm import SVC\nfrom scipy import misc\nimport align.detect_face\nfrom six.moves import xrange\n\ndef main(args):\n  \n    images, cout_per_image, nrof_samples = load_and_align_data(args.image_files,args.image_size, args.margin, args.gpu_memory_fraction)\n    with tf.Graph().as_default():\n\n       with tf.Session() as sess:\n      \n            # Load the model\n                facenet.load_model(args.model)\n            # Get input and output tensors\n                images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n                embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n                phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n\n            # Run forward pass to calculate embeddings\n                feed_dict = { images_placeholder: images , phase_train_placeholder:False}\n                emb = sess.run(embeddings, feed_dict=feed_dict)\n                classifier_filename_exp = os.path.expanduser(args.classifier_filename)\n                with open(classifier_filename_exp, 'rb') as infile:\n                    (model, class_names) = pickle.load(infile)\n                print('Loaded classifier model from file \"%s\"\\n' % classifier_filename_exp)\n                predictions = model.predict_proba(emb)\n                best_class_indices = np.argmax(predictions, axis=1)\n                best_class_probabilities = predictions[np.arange(len(best_class_indices)), best_class_indices]\n                k=0     \n\t    #print predictions       \n                for i in range(nrof_samples):\n                    print(\"\\npeople in image %s :\" %(args.image_files[i]))\n                    for j in range(cout_per_image[i]):\n                        print('%s: %.3f' % (class_names[best_class_indices[k]], best_class_probabilities[k]))\n                        k+=1\n                    \ndef load_and_align_data(image_paths, image_size, margin, gpu_memory_fraction):\n\n    minsize = 20 # minimum size of face\n    threshold = [ 0.6, 0.7, 0.7 ]  # three steps's threshold\n    factor = 0.709 # scale factor\n    \n    print('Creating networks and loading parameters')\n    with tf.Graph().as_default():\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        with sess.as_default():\n            pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)\n  \n    nrof_samples = len(image_paths)\n    img_list = [] \n    count_per_image = []\n    for i in xrange(nrof_samples):\n        img = misc.imread(os.path.expanduser(image_paths[i]))\n        img_size = np.asarray(img.shape)[0:2]\n        bounding_boxes, _ = align.detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)\n        count_per_image.append(len(bounding_boxes))\n        for j in range(len(bounding_boxes)):\t\n                det = np.squeeze(bounding_boxes[j,0:4])\n                bb = np.zeros(4, dtype=np.int32)\n                bb[0] = np.maximum(det[0]-margin/2, 0)\n                bb[1] = np.maximum(det[1]-margin/2, 0)\n                bb[2] = np.minimum(det[2]+margin/2, img_size[1])\n                bb[3] = np.minimum(det[3]+margin/2, img_size[0])\n                cropped = img[bb[1]:bb[3],bb[0]:bb[2],:]\n                aligned = misc.imresize(cropped, (image_size, image_size), interp='bilinear')\n                prewhitened = facenet.prewhiten(aligned)\n                img_list.append(prewhitened)\t\t\n    images = np.stack(img_list)\n    return images, count_per_image, nrof_samples\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    parser.add_argument('image_files', type=str, nargs='+', help='Path(s) of the image(s)')\n    parser.add_argument('model', type=str, \n        help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')\n    parser.add_argument('classifier_filename', \n        help='Classifier model file name as a pickle (.pkl) file. ' + \n        'For training this is the output and for classification this is an input.')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    parser.add_argument('--margin', type=int,\n        help='Margin for the crop around the bounding box (height, width) in pixels.', default=44)\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n\n"
  },
  {
    "path": "contributed/real_time_face_recognition.py",
    "content": "# coding=utf-8\n\"\"\"Performs face detection in realtime.\n\nBased on code from https://github.com/shanren7/real_time_face_recognition\n\"\"\"\n# MIT License\n#\n# Copyright (c) 2017 François Gervais\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\nimport argparse\nimport sys\nimport time\n\nimport cv2\n\nimport face\n\n\ndef add_overlays(frame, faces, frame_rate):\n    if faces is not None:\n        for face in faces:\n            face_bb = face.bounding_box.astype(int)\n            cv2.rectangle(frame,\n                          (face_bb[0], face_bb[1]), (face_bb[2], face_bb[3]),\n                          (0, 255, 0), 2)\n            if face.name is not None:\n                cv2.putText(frame, face.name, (face_bb[0], face_bb[3]),\n                            cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0),\n                            thickness=2, lineType=2)\n\n    cv2.putText(frame, str(frame_rate) + \" fps\", (10, 30),\n                cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0),\n                thickness=2, lineType=2)\n\n\ndef main(args):\n    frame_interval = 3  # Number of frames after which to run face detection\n    fps_display_interval = 5  # seconds\n    frame_rate = 0\n    frame_count = 0\n\n    video_capture = cv2.VideoCapture(0)\n    face_recognition = face.Recognition()\n    start_time = time.time()\n\n    if args.debug:\n        print(\"Debug enabled\")\n        face.debug = True\n\n    while True:\n        # Capture frame-by-frame\n        ret, frame = video_capture.read()\n\n        if (frame_count % frame_interval) == 0:\n            faces = face_recognition.identify(frame)\n\n            # Check our current fps\n            end_time = time.time()\n            if (end_time - start_time) > fps_display_interval:\n                frame_rate = int(frame_count / (end_time - start_time))\n                start_time = time.time()\n                frame_count = 0\n\n        add_overlays(frame, faces, frame_rate)\n\n        frame_count += 1\n        cv2.imshow('Video', frame)\n\n        if cv2.waitKey(1) & 0xFF == ord('q'):\n            break\n\n    # When everything is done, release the capture\n    video_capture.release()\n    cv2.destroyAllWindows()\n\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n\n    parser.add_argument('--debug', action='store_true',\n                        help='Enable some debug outputs.')\n    return parser.parse_args(argv)\n\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "data/learning_rate_retrain_tripletloss.txt",
    "content": "# Learning rate schedule\n# Maps an epoch number to a learning rate\n0:  0.1\n300: 0.01\n400: 0.001\n1000: 0.0001"
  },
  {
    "path": "data/learning_rate_schedule_classifier_casia.txt",
    "content": "# Learning rate schedule\n# Maps an epoch number to a learning rate\n0:  0.05\n60: 0.005\n80: 0.0005\n91: -1\n"
  },
  {
    "path": "data/learning_rate_schedule_classifier_msceleb.txt",
    "content": "# Learning rate schedule\n# Maps an epoch number to a learning rate\n0:  0.1\n150: 0.01\n180: 0.001\n251: 0.0001"
  },
  {
    "path": "data/learning_rate_schedule_classifier_vggface2.txt",
    "content": "# Learning rate schedule\n# Maps an epoch number to a learning rate\n0:   0.05\n100: 0.005\n200: 0.0005\n276: -1"
  },
  {
    "path": "data/pairs.txt",
    "content": "10\t300\nAbel_Pacheco\t1\t4\nAkhmed_Zakayev\t1\t3\nAkhmed_Zakayev\t2\t3\nAmber_Tamblyn\t1\t2\nAnders_Fogh_Rasmussen\t1\t3\nAnders_Fogh_Rasmussen\t1\t4\nAngela_Bassett\t1\t5\nAngela_Bassett\t2\t5\nAngela_Bassett\t3\t4\nAnn_Veneman\t3\t5\nAnn_Veneman\t6\t10\nAnn_Veneman\t10\t11\nAnthony_Fauci\t1\t2\nAntony_Leung\t1\t2\nAntony_Leung\t2\t3\nAnwar_Ibrahim\t1\t2\nAugusto_Pinochet\t1\t2\nBarbara_Brezigar\t1\t2\nBenjamin_Netanyahu\t1\t4\nBenjamin_Netanyahu\t4\t5\nBernard_Law\t2\t3\nBernard_Law\t3\t4\nBertrand_Bonello\t1\t2\nBill_Frist\t2\t9\nBill_Frist\t4\t5\nBob_Graham\t2\t4\nBob_Graham\t3\t6\nBob_Graham\t4\t6\nBob_Graham\t5\t6\nBoris_Becker\t2\t6\nBrad_Johnson\t1\t3\nBrad_Johnson\t2\t3\nBrad_Johnson\t2\t4\nBrian_Griese\t1\t2\nCandice_Bergen\t1\t2\nCandice_Bergen\t2\t3\nCarla_Myers\t1\t2\nCathy_Freeman\t1\t2\nChang_Dae-whan\t1\t2\nCharles_Grassley\t1\t2\nClare_Short\t1\t3\nClare_Short\t1\t4\nCorinne_Coman\t1\t2\nDai_Bachtiar\t1\t2\nDale_Earnhardt_Jr\t1\t3\nDavid_Caruso\t1\t2\nDemi_Moore\t1\t3\nDick_Vermeil\t1\t2\nDoris_Roberts\t1\t2\nDoris_Roberts\t1\t3\nDrew_Barrymore\t1\t2\nEdmund_Stoiber\t4\t7\nEdmund_Stoiber\t5\t7\nEdmund_Stoiber\t7\t12\nEdmund_Stoiber\t9\t11\nElinor_Caplan\t1\t2\nEmmanuelle_Beart\t1\t2\nEmmanuelle_Beart\t1\t3\nFederico_Trillo\t1\t2\nFederico_Trillo\t1\t3\nFederico_Trillo\t2\t3\nFrancis_Ford_Coppola\t1\t2\nFred_Thompson\t1\t2\nFred_Thompson\t1\t3\nFred_Thompson\t2\t3\nGarry_Trudeau\t1\t2\nGary_Williams\t1\t2\nGene_Robinson\t1\t2\nGene_Robinson\t1\t3\nGene_Robinson\t2\t3\nGeorge_Galloway\t1\t3\nGeorge_Galloway\t2\t3\nGeorge_Galloway\t2\t4\nGeraldine_Chaplin\t1\t2\nGeraldine_Chaplin\t1\t4\nGeraldine_Chaplin\t3\t4\nGerardo_Gambala\t1\t2\nGian_Marco\t1\t2\nGian_Marco\t2\t3\nGillian_Anderson\t1\t2\nGordon_Brown\t6\t9\nGordon_Brown\t10\t13\nGrant_Hackett\t1\t2\nGrant_Hackett\t1\t3\nGrant_Hackett\t1\t5\nGray_Davis\t7\t22\nGray_Davis\t21\t26\nGregg_Popovich\t1\t5\nGregg_Popovich\t3\t4\nGuy_Ritchie\t1\t2\nHamzah_Haz\t1\t2\nHarbhajan_Singh\t1\t2\nHootie_Johnson\t1\t2\nHugo_Chavez\t2\t27\nHugo_Chavez\t27\t53\nHugo_Chavez\t36\t51\nHugo_Chavez\t41\t50\nHugo_Chavez\t45\t56\nIsaiah_Washington\t1\t2\nJack_Grubman\t1\t2\nJacques_Rogge\t1\t9\nJacques_Rogge\t3\t7\nJacques_Rogge\t3\t10\nJacques_Rogge\t4\t6\nJacques_Rogge\t4\t9\nJacques_Rogge\t5\t8\nJacques_Rogge\t6\t8\nJames_Caan\t1\t2\nJames_Caan\t1\t3\nJames_Caan\t2\t3\nJames_Jones\t1\t2\nJamling_Norgay\t1\t2\nJanica_Kostelic\t1\t2\nJeanne_Moreau\t1\t2\nJeffrey_Archer\t1\t2\nJennifer_Garner\t1\t3\nJennifer_Garner\t4\t9\nJennifer_Garner\t5\t6\nJennifer_Garner\t5\t9\nJennifer_Garner\t7\t12\nJennifer_Garner\t8\t11\nJeremy_Greenstock\t2\t24\nJeremy_Greenstock\t3\t22\nJeremy_Greenstock\t5\t11\nJeremy_Greenstock\t10\t14\nJeremy_Greenstock\t17\t21\nJessica_Lange\t1\t2\nJimmy_Carter\t1\t7\nJimmy_Carter\t4\t6\nJimmy_Carter\t5\t8\nJimmy_Carter\t6\t7\nJodie_Foster\t1\t2\nJohn_Manley\t1\t6\nJohn_Manley\t2\t5\nJohn_McCain\t2\t3\nJohn_McCain\t3\t7\nJohn_McCain\t6\t7\nJohn_Snow\t3\t15\nJohn_Snow\t4\t16\nJohn_Snow\t9\t11\nJohnson_Panjaitan\t1\t2\nJorge_Castaneda\t1\t2\nJose_Serra\t1\t9\nJose_Serra\t2\t8\nJose_Serra\t3\t5\nJose_Serra\t3\t7\nJose_Serra\t6\t9\nJose_Theodore\t1\t2\nJoseph_Blatter\t1\t2\nJoseph_Ralston\t1\t2\nJuan_Pablo_Montoya\t1\t8\nJuan_Pablo_Montoya\t2\t4\nJuan_Pablo_Montoya\t4\t5\nJulianna_Margulies\t1\t2\nJustin_Guarini\t1\t2\nJustin_Guarini\t2\t3\nJustine_Henin\t2\t3\nKate_Winslet\t1\t2\nKate_Winslet\t1\t4\nKate_Winslet\t2\t3\nKate_Winslet\t2\t4\nKathy_Winters\t1\t2\nKelvin_Sampson\t1\t2\nKevin_Stallings\t1\t2\nKim_Jong-Il\t2\t3\nKristin_Davis\t1\t2\nKristin_Davis\t2\t3\nLance_Armstrong\t1\t17\nLance_Armstrong\t5\t10\nLance_Armstrong\t7\t11\nLance_Armstrong\t10\t18\nLance_Armstrong\t14\t17\nLaurent_Jalabert\t1\t2\nLindsey_Graham\t1\t2\nLisa_Gottsegen\t1\t2\nLleyton_Hewitt\t1\t13\nLleyton_Hewitt\t16\t27\nLleyton_Hewitt\t18\t37\nLleyton_Hewitt\t24\t36\nLuis_Ernesto_Derbez_Bautista\t3\t6\nMario_Dumont\t1\t2\nMark_Wahlberg\t1\t3\nMark_Wahlberg\t2\t3\nMark_Wahlberg\t2\t4\nMarlene_Weingartner\t1\t2\nMartha_Bowen\t1\t2\nMartin_Cauchon\t1\t2\nMartin_Hoellwarth\t1\t2\nMartin_Sheen\t1\t2\nMatthew_Broderick\t1\t4\nMatthew_Broderick\t2\t3\nMike_Krzyzewski\t1\t6\nMikhail_Gorbachev\t1\t2\nMonica_Bellucci\t1\t4\nMonica_Bellucci\t2\t4\nNaomi_Campbell\t1\t2\nNestor_Kirchner\t3\t30\nNestor_Kirchner\t12\t21\nNestor_Kirchner\t17\t25\nNicolas_Lapentti\t1\t2\nNoah_Wyle\t2\t3\nNora_Bendijo\t1\t2\nNursultan_Nazarbayev\t1\t2\nPamela_Anderson\t1\t2\nPamela_Anderson\t1\t5\nPatricia_Heaton\t1\t2\nPatty_Schnyder\t1\t2\nPatty_Schnyder\t2\t3\nPatty_Schnyder\t2\t4\nPatty_Schnyder\t3\t4\nPaul_Bremer\t6\t17\nPaul_Bremer\t7\t10\nPaul_Bremer\t9\t15\nPaul_Bremer\t14\t16\nPaul_Sarbanes\t1\t3\nPaul_Sarbanes\t2\t3\nPaul_William_Hurley\t1\t2\nPervez_Musharraf\t1\t6\nPervez_Musharraf\t2\t16\nPervez_Musharraf\t3\t10\nPervez_Musharraf\t4\t14\nPervez_Musharraf\t5\t7\nPervez_Musharraf\t5\t15\nPhil_Gramm\t1\t2\nPrince_Edward\t1\t2\nRicardo_Lagos\t3\t12\nRicardo_Lagos\t23\t27\nRicardo_Monasterio\t1\t2\nRich_Gannon\t1\t2\nRick_Perry\t1\t4\nRick_Perry\t1\t5\nRick_Perry\t2\t4\nRick_Perry\t3\t4\nRobert_Bonner\t2\t3\nRobert_Evans\t2\t3\nRobert_Fico\t1\t2\nRomano_Prodi\t3\t5\nRoy_Moore\t2\t5\nRoy_Moore\t3\t6\nSachiko_Yamada\t1\t2\nSachiko_Yamada\t1\t4\nSachiko_Yamada\t2\t3\nSachiko_Yamada\t2\t4\nSaeb_Erekat\t1\t2\nSam_Bith\t1\t2\nSam_Bith\t1\t3\nSam_Bith\t2\t3\nSean_Hayes\t1\t2\nSergio_Garcia\t1\t2\nSilvia_Farina_Elia\t1\t2\nSteve_Ballmer\t1\t2\nSteve_Ballmer\t1\t3\nStockard_Channing\t1\t3\nStockard_Channing\t2\t3\nTerry_McAuliffe\t1\t2\nTerry_McAuliffe\t1\t3\nThomas_Rupprath\t1\t3\nThomas_Rupprath\t2\t3\nTom_Ridge\t6\t16\nTom_Ridge\t8\t25\nTom_Ridge\t9\t26\nTom_Ridge\t18\t22\nTommy_Haas\t4\t5\nTommy_Thompson\t1\t2\nTommy_Thompson\t1\t7\nTommy_Thompson\t2\t8\nTommy_Thompson\t4\t8\nTommy_Thompson\t6\t9\nTomoko_Hagiwara\t1\t2\nTrent_Lott\t1\t2\nTrent_Lott\t2\t3\nTrent_Lott\t2\t8\nTrent_Lott\t6\t11\nTrent_Lott\t7\t10\nTrent_Lott\t8\t16\nTsutomu_Takebe\t1\t2\nTyler_Hamilton\t1\t2\nTyra_Banks\t1\t2\nVaclav_Havel\t2\t4\nVaclav_Havel\t2\t5\nVaclav_Havel\t2\t6\nVaclav_Havel\t4\t9\nVaclav_Havel\t5\t7\nValerie_Harper\t1\t2\nVince_Carter\t3\t4\nVincent_Brooks\t2\t3\nVincent_Brooks\t2\t7\nVincent_Brooks\t4\t5\nVincent_Brooks\t4\t7\nVincent_Gallo\t1\t2\nVitali_Klitschko\t1\t2\nVitali_Klitschko\t3\t4\nWilliam_Macy\t1\t4\nWilliam_Macy\t2\t4\nWilliam_Macy\t3\t4\nWoody_Allen\t2\t4\nWoody_Allen\t3\t5\nYukiko_Okudo\t1\t2\nZico\t1\t2\nZico\t2\t3\nAbdel_Madi_Shabneh\t1\tDean_Barker\t1\nAbdel_Madi_Shabneh\t1\tGiancarlo_Fisichella\t1\nAbdel_Madi_Shabneh\t1\tMikhail_Gorbachev\t1\nAbdul_Rahman\t1\tPortia_de_Rossi\t1\nAbel_Pacheco\t1\tJong_Thae_Hwa\t2\nAbel_Pacheco\t2\tJean-Francois_Lemounier\t1\nAfton_Smith\t1\tDwayne_Wade\t1\nAhmad_Jbarah\t1\tJames_Comey\t1\nAkhmed_Zakayev\t2\tDonna_Morrissey\t1\nAlan_Dershowitz\t1\tBertrand_Bonello\t1\nAlanis_Morissette\t1\tMartin_Cauchon\t1\nAlexander_Lukashenko\t1\tHeather_Chinnock\t1\nAlfonso_Cuaron\t1\tJason_Priestley\t1\nAlfonso_Cuaron\t1\tPatty_Schnyder\t2\nAlfonso_Soriano\t1\tBill_Nelson\t2\nAlfonso_Soriano\t1\tJulio_De_Brun\t1\nAlfonso_Soriano\t1\tPatty_Schnyder\t3\nAlonzo_Mourning\t1\tCecilia_Cheung\t1\nAmber_Tamblyn\t2\tBenjamin_Netanyahu\t1\nAmporn_Falise\t1\tJoe_Pantoliano\t1\nAnders_Fogh_Rasmussen\t2\tJohnson_Panjaitan\t2\nAndre_Bucher\t1\tJoseph_Ralston\t1\nAndre_Bucher\t1\tMaria_Garcia\t1\nAndrew_Gilligan\t1\tHenry_Castellanos\t1\nAndrew_Shutley\t1\tEdmund_Stoiber\t5\nAndrew_Shutley\t1\tMitchell_Swartz\t1\nAndrew_Shutley\t1\tSaeb_Erekat\t2\nAndy_Dick\t1\tSimon_Yam\t1\nAndy_Griffith\t1\tOsrat_Iosef\t1\nAndy_Wisecarver\t1\tDimitar_Berbatov\t1\nAngela_Lansbury\t1\tSteven_Van_Zandt\t1\nAngela_Lansbury\t2\tJohn_Coomber\t1\nAnn_Veneman\t6\tSergio_Garcia\t2\nAnn_Veneman\t8\tTed_Williams\t1\nAnnie-Jeanne_Reynaud\t1\tSJ_Twu\t1\nAnthony_Carter\t1\tEliza_Dushku\t1\nAntonio_Cassano\t1\tPaul_Celluci\t1\nAnwar_Ibrahim\t1\tDavid_Alpay\t1\nArmand_Sargen\t1\tDaryl_Sabara\t1\nArmand_Sargen\t1\tKelvin_Sampson\t3\nArmand_Sargen\t1\tLisa_Gottsegen\t2\nAtom_Egoyan\t1\tBill_Stapleton\t1\nAtom_Egoyan\t1\tJanis_Ruth_Coulter\t1\nBarbara_Brezigar\t2\tDoris_Roberts\t2\nBarbara_Felt-Miller\t1\tLeticia_Dolera\t1\nBart_Freundlich\t1\tErnie_Grunfeld\t1\nBart_Freundlich\t1\tKirsten_Gilham\t1\nBenjamin_Martinez\t1\tGarry_McCoy\t1\nBenjamin_Netanyahu\t1\tMaria_Callas\t1\nBenjamin_Netanyahu\t5\tFrank_Beamer\t1\nBernard_Law\t1\tLiu_Xiaoqing\t1\nBernard_Law\t3\tValerie_Harper\t2\nBertrand_Bonello\t1\tJong_Thae_Hwa\t2\nBill_Bradley\t1\tChen_Tsai-chin\t1\nBill_Bradley\t1\tHelen_Alvare\t1\nBill_Elliott\t1\tMary_Anne_Souza\t1\nBill_Frist\t5\tJimmy_Kimmel\t2\nBill_Maher\t1\tBrad_Russ\t1\nBill_Maher\t1\tJuliette_Binoche\t1\nBill_Nelson\t1\tKim_Jong-Il\t3\nBill_Nelson\t2\tGillian_Anderson\t1\nBill_Stapleton\t1\tSedigh_Barmak\t1\nBill_Stapleton\t1\tValerie_Harper\t1\nBilly_Bob_Thornton\t1\tHerb_Dhaliwal\t1\nBilly_Bob_Thornton\t1\tNong_Duc_Manh\t1\nBob_Alper\t1\tKevin_Millwood\t1\nBob_Graham\t2\tDwayne_Wade\t1\nBob_Petrino\t1\tGeraldine_Chaplin\t4\nBob_Petrino\t1\tJorge_Castaneda\t1\nBoris_Becker\t4\tJulianna_Margulies\t2\nBrad_Russ\t1\tHana_Urushima\t1\nBrad_Russ\t1\tRomeo_Gigli\t1\nBrawley_King\t1\tTom_Glavine\t2\nBrian_Griese\t2\tJeffrey_Archer\t2\nBrian_Griese\t2\tLaura_Elena_Harring\t1\nBrian_Griese\t2\tNicolas_Lapentti\t2\nBryan_Adams\t1\tMichael_Kors\t1\nBryan_Adams\t1\tMohamed_Seineldin\t1\nCalbert_Cheaney\t1\tIan_Smith\t1\nCalbert_Cheaney\t1\tRobert_Downey_Jr\t1\nCarl_Reiner\t1\tHamid_Efendi\t1\nCarl_Reiner\t2\tJohn_Engler\t1\nCarl_Reiner\t2\tPrince_Rainier_III\t1\nCarl_Reiner\t2\tTom_Glavine\t2\nCarlo_Azeglio_Ciampi\t1\tFrancis_Ford_Coppola\t1\nCarlos_Arroyo\t1\tShane_Phillips\t1\nCarlos_Paternina\t1\tEmily_Stevens\t1\nCarlos_Paternina\t1\tPaul_Sarbanes\t1\nCasey_Mears\t1\tMike_Davis\t1\nCasey_Mears\t1\tYukiko_Okudo\t1\nCathy_Freeman\t2\tWilliam_Martin\t2\nCecilia_Cheung\t1\tDaryl_Parks\t1\nCecilia_Cheung\t1\tPascal_Affi_Nguessan\t1\nChen_Tsai-chin\t1\tDereck_Whittenburg\t1\nChen_Tsai-chin\t1\tMamdouh_Habib\t1\nCho_Myung-kyun\t1\tDavid_Bell\t1\nCho_Myung-kyun\t1\tFernando_Sanz\t1\nCho_Myung-kyun\t1\tGeorgia_Giddings\t1\nCho_Myung-kyun\t1\tRichard_Fine\t1\nChoi_Yun-yong\t1\tChuck_Eidson\t1\nChris_Dodd\t1\tTaylor_Twellman\t1\nChris_Swecker\t1\tTom_Vilsack\t1\nChristian_Lacroix\t1\tLaura_Elena_Harring\t1\nChristian_Lacroix\t1\tOrnella_Muti\t1\nChuck_Eidson\t1\tSigourney_Weaver\t1\nClare_Short\t4\tDon_Carcieri\t1\nCoco_dEste\t1\tDarvis_Patton\t1\nCoco_dEste\t1\tMelina_Kanakaredes\t1\nCoco_dEste\t1\tTom_Rouen\t1\nColeen_Rowley\t1\tNong_Duc_Manh\t1\nCorinne_Coman\t2\tFrank_Beamer\t1\nDale_Earnhardt_Jr\t1\tNick_Reilly\t1\nDario_Franchitti\t1\tHenry_Castellanos\t1\nDarren_Campel\t1\tHilary_McKay\t1\nDarvis_Patton\t1\tGerard_Tronche\t1\nDarvis_Patton\t1\tWilliam_Macy\t4\nDaryl_Parks\t1\tGuus_Hiddink\t1\nDaryl_Sabara\t1\tNick_Reilly\t1\nDaryl_Sabara\t1\tValentina_Tereshkova\t1\nDave_Johnson\t1\tHoward_Stern\t1\nDave_Tucker\t1\tGary_Gitnick\t1\nDavid_Collenette\t1\tSalman_Khan\t1\nDavid_Westerfield\t1\tStan_Kroenke\t1\nDean_Jacek\t1\tLarry_Wilmore\t1\nDemi_Moore\t2\tFred_Thompson\t1\nDemi_Moore\t2\tLinus_Roache\t1\nDereck_Whittenburg\t1\tLindsey_Graham\t2\nDianne_Reeves\t1\tLarry_Wilmore\t1\nDianne_Reeves\t1\tRomeo_Gigli\t1\nDon_Carcieri\t1\tJanica_Kostelic\t1\nDora_Bakoyianni\t1\tRichard_Sambrook\t2\nDora_Bakoyianni\t1\tSaeb_Erekat\t2\nDoris_Roberts\t1\tNong_Duc_Manh\t1\nDoug_Wilson\t1\tSzu_Yu_Chen\t1\nDouglas_Gansler\t1\tMartin_Brooke\t1\nDouglas_Gansler\t1\tRonald_Kadish\t1\nDwayne_Wade\t1\tMike_Farrar\t1\nEdward_Arsenault\t1\tJim_Hardin\t1\nEinars_Repse\t1\tMinnie_Mendoza\t1\nEinars_Repse\t1\tTim_Blake_Nelson\t1\nElinor_Caplan\t1\tHilary_McKay\t1\nEliza_Dushku\t1\tGeorge_Lucas\t1\nEliza_Dushku\t1\tItzhak_Perlman\t1\nEmily_Stevens\t1\tJanez_Drnovsek\t1\nEmmanuelle_Beart\t2\tPhil_Jackson\t1\nEric_Daze\t1\tSterling_Hitchcock\t1\nErika_Christensen\t2\tMichael_Dell\t1\nErika_Christensen\t2\tWoody_Allen\t2\nEriko_Tamura\t1\tGeorgia_Giddings\t1\nErnie_Grunfeld\t1\tFrank_Coraci\t1\nEugene_Melnyk\t1\tMahima_Chaudhari\t1\nFatma_Kusibeh\t1\tLee_Baca\t1\nFederico_Trillo\t1\tJonathan_Woodgate\t1\nFernando_Alonso\t1\tSam_Brownback\t1\nFernando_Sanz\t1\tMiranda_Otto\t1\nFernando_Sanz\t1\tRoy_Moore\t1\nFlor_Montulo\t2\tJuan_Pablo_Montoya\t1\nFrancisco_Garcia\t1\tMarsha_Sharp\t1\nFrancois_Ozon\t1\tMakiya_Ali_Hassan\t1\nFrank_Coraci\t1\tTomoko_Hagiwara\t2\nFrank_Van_Ecke\t1\tTsutomu_Takebe\t1\nFred_Thompson\t2\tHelen_Alvare\t1\nFred_Thompson\t2\tSterling_Hitchcock\t1\nFred_Thompson\t3\tMagda_Kertasz\t1\nGarry_Trudeau\t1\tPat_Riley\t1\nGarry_Witherall\t1\tHoward_Stern\t1\nGarry_Witherall\t1\tIngrid_Betancourt\t1\nGarry_Witherall\t1\tMartin_Keown\t1\nGary_Gero\t1\tKim_Hong-gul\t1\nGary_Gero\t1\tPhil_Gramm\t1\nGavin_Degraw\t1\tJeffrey_Archer\t1\nGene_Robinson\t3\tMartha_Bowen\t2\nGeorgia_Giddings\t1\tMahima_Chaudhari\t1\nGeovani_Lapentti\t1\tRodney_Rempt\t1\nGeovani_Lapentti\t1\tSam_Brownback\t1\nGerard_de_Cortanze\t1\tMark_Wahlberg\t1\nGian_Marco\t2\tKevin_Stallings\t2\nGiancarlo_Fisichella\t1\tMaria_Callas\t1\nGideon_Yago\t1\tNatalie_Williams\t1\nGideon_Yago\t1\tPaul_William_Hurley\t1\nGlenn_Plummer\t1\tMaria_Garcia\t1\nGrant_Hackett\t1\tTodd_Robbins\t1\nGrant_Hackett\t3\tMilo_Djukanovic\t3\nGray_Davis\t26\tKaren_Lynn_Gorney\t1\nGregg_Popovich\t3\tVernon_Forrest\t1\nGregor_Gysi\t1\tTomoko_Hagiwara\t1\nGuy_Ritchie\t2\tHerb_Dhaliwal\t1\nGuy_Ritchie\t2\tWilliam_Macy\t1\nHamid_Efendi\t1\tJimmy_Carter\t8\nHamzah_Haz\t2\tHilary_McKay\t1\nHarald_Ringstorff\t1\tPat_Riley\t1\nHarald_Ringstorff\t1\tRomano_Prodi\t6\nHeather_Chinnock\t1\tJean-Francois_Lemounier\t1\nHelen_Alvare\t1\tMilo_Djukanovic\t1\nHenry_Castellanos\t1\tPamela_Anderson\t4\nHenry_Castellanos\t1\tTommy_Shane_Steiner\t1\nHerb_Dhaliwal\t1\tHung_Wan-ting\t1\nHilary_McKay\t1\tKevin_Millwood\t1\nHoward_Stern\t1\tMaria_Callas\t1\nHugo_Chavez\t33\tKaren_Lynn_Gorney\t1\nHugo_Chavez\t60\tSteve_Shiver\t1\nImam_Samudra\t1\tIvana_Trump\t1\nImelda_Marcos\t1\tPatty_Schnyder\t4\nJack_Smith\t1\tMary_Jo_Myers\t1\nJames_Caan\t2\tPaul_Sarbanes\t2\nJames_Comey\t1\tJuan_Carlos_Morales\t1\nJames_Comey\t1\tPaul_William_Hurley\t1\nJamling_Norgay\t1\tZico\t2\nJan_Pronk\t1\tKim_Dong-hwa\t1\nJanez_Drnovsek\t1\tSterling_Hitchcock\t1\nJanica_Kostelic\t2\tYasushi_Akashi\t1\nJanice_Abreu\t1\tKevin_Sorbo\t1\nJeffrey_Ashby\t1\tMichael_Dell\t1\nJennifer_Garner\t6\tMike_Duke\t1\nJennifer_Renee_Short\t1\tTaylor_Twellman\t1\nJerry_Seinfeld\t1\tTim_Blake_Nelson\t1\nJerry_Tarkanian\t1\tThomas_Rupprath\t1\nJessica_Lange\t2\tSedigh_Barmak\t1\nJim_Freudenberg\t1\tNigel_Redden\t1\nJim_Freudenberg\t1\tTina_Pisnik\t1\nJim_Haslett\t1\tTsutomu_Takebe\t1\nJim_Otto\t1\tRafiq_Hariri\t1\nJimmy_Gurule\t1\tTerry_McAuliffe\t1\nJodie_Foster\t3\tJoe_Pantoliano\t1\nJohn_Herrington\t1\tLuis_Ernesto_Derbez_Bautista\t2\nJohn_Richardson\t1\tYasushi_Akashi\t1\nJohn_Snow\t17\tSe_Hyuk_Joo\t1\nJonathan_Arden\t1\tJoseph_Ralston\t1\nJorge_Castaneda\t1\tRobert_Fico\t1\nJose_Rosado\t1\tMicky_Arison\t1\nJoseph_Blatter\t1\tRonald_Kadish\t1\nJoseph_Ralston\t2\tJuan_Pablo_Montoya\t5\nJoseph_Ralston\t2\tYoshiyuki_Kamei\t1\nJuliette_Binoche\t1\tMatthew_Broderick\t3\nJulio_De_Brun\t1\tPatty_Schnyder\t1\nJulio_De_Brun\t1\tVernon_Forrest\t1\nJustin_Guarini\t2\tPrince_Edward\t1\nKate_Winslet\t2\tMike_Duke\t1\nKatie_Wagner\t1\tStan_Kroenke\t1\nKeith_Lowen\t1\tRobert_Evans\t2\nKeith_Lowen\t1\tSilvia_Farina_Elia\t2\nKen_Loach\t1\tTaku_Yamasaki\t1\nKevin_Crane\t1\tMike_Krzyzewski\t2\nKevin_Millwood\t1\tMitchell_Crooks\t1\nKim_Clijsters\t4\tMartin_Short\t1\nKim_Hong-gul\t1\tMilo_Djukanovic\t3\nKim_Jong-Il\t3\tRick_Reed\t1\nLance_Armstrong\t9\tMaria_Garcia\t1\nLaurent_Jalabert\t2\tVincent_Gallo\t1\nLeon_LaPorte\t1\tTed_Williams\t1\nLeon_LaPorte\t1\tTommy_Thompson\t5\nLeonardo_Fernandez\t1\tRomano_Prodi\t7\nLeticia_Dolera\t1\tTom_Glavine\t1\nLorraine_Bracco\t1\tMomcilo_Perisic\t1\nLuis_Ernesto_Derbez_Bautista\t1\tTyra_Banks\t1\nMaria_Burks\t1\tTodd_Parrott\t1\nMario_Lemieux\t1\tStan_Kroenke\t1\nMark_Everson\t1\tMartin_Sheen\t2\nMarquier_Montano_Contreras\t1\tSJ_Twu\t1\nMarsha_Sharp\t1\tSteve_Shiver\t1\nMartin_Cauchon\t2\tVitali_Klitschko\t3\nMartin_Hoellwarth\t2\tMary_Katherine_Smart\t1\nMartina_Hingis\t1\tTerry_McAuliffe\t2\nMelina_Kanakaredes\t1\tOrnella_Muti\t1\nMichael_Dell\t1\tMike_Duke\t1\nMichael_Dell\t1\tNigel_Redden\t1\nMichael_Richards\t1\tSilvia_Farina_Elia\t3\nMilan_Kucan\t1\tSalman_Khan\t1\nNancy_Kerrigan\t1\tSam_Brownback\t1\nNaomi_Campbell\t1\tTom_Ridge\t16\nNina_Jacobson\t1\tPortia_de_Rossi\t1\nNoah_Wyle\t3\tRobbie_Coltrane\t1\nNora_Bendijo\t1\tWilliam_Martin\t2\nNursultan_Nazarbayev\t1\tRobert_Bonner\t1\nPascal_Affi_Nguessan\t1\tTom_Moss\t1\nPat_Summitt\t1\tPaul_Celluci\t1\nPatty_Schnyder\t3\tPernilla_Bjorn\t1\nPatty_Schnyder\t3\tPrince_Philippe\t1\nPatty_Schnyder\t4\tRicardo_Lagos\t25\nPervez_Musharraf\t3\tRichard_Rodriguez\t1\nPhil_Gramm\t2\tStefan_Tafrov\t1\nRachel_Kempson\t1\tZorica_Radovic\t1\nRachel_Roy\t1\tSteve_Shiver\t1\nRichard_Fine\t1\tRichard_Rodriguez\t1\nRick_Reed\t1\tRuth_Bader_Ginsburg\t1\nRobbie_Naish\t1\tZhong_Nanshan\t1\nRobert_Bonner\t2\tVincent_Brooks\t2\nRobert_Downey_Jr\t1\tTommy_Shane_Steiner\t1\nRobert_Evans\t1\tTodd_Robbins\t1\nRomeo_Gigli\t1\tTom_Harkin\t4\nSaeb_Erekat\t1\tTom_Coverdale\t2\nSe_Hyuk_Joo\t1\tTom_Rouen\t1\nSergio_Garcia\t2\tThomas_Watjen\t1\nSimon_Yam\t1\tTerry_McAuliffe\t3\nSimon_Yam\t1\tTommy_Haas\t5\nStan_Kroenke\t1\tWilliam_Hyde\t1\nSteve_Ballmer\t1\tTina_Pisnik\t1\nSteve_Ballmer\t2\tVincent_Gallo\t3\nSteve_Shiver\t1\tThomas_Rupprath\t3\nTina_Fey\t1\tTodd_Parrott\t1\nAbdullah_Gul\t1\t6\nAbdullah_Gul\t1\t8\nAbdullah_Gul\t7\t14\nAbdullah_Gul\t9\t12\nAbdullah_Gul\t9\t15\nAdolfo_Rodriguez_Saa\t1\t2\nAdrien_Brody\t2\t3\nAdrien_Brody\t2\t12\nAdrien_Brody\t5\t10\nAdrien_Brody\t7\t8\nAl_Sharpton\t1\t4\nAl_Sharpton\t2\t4\nAl_Sharpton\t2\t7\nAl_Sharpton\t3\t4\nAlexandra_Stevenson\t1\t2\nAlexandra_Stevenson\t1\t3\nAlexandra_Vodjanikova\t1\t2\nAlicia_Silverstone\t1\t2\nAna_Palacio\t3\t7\nAna_Palacio\t6\t8\nAndre_Agassi\t1\t5\nAndre_Agassi\t2\t16\nAndre_Agassi\t4\t33\nAndre_Agassi\t9\t25\nAndre_Agassi\t17\t25\nAnna_Kournikova\t2\t3\nAnna_Kournikova\t2\t12\nAnna_Kournikova\t3\t8\nAnna_Kournikova\t7\t8\nAnna_Kournikova\t7\t11\nAnnette_Lu\t1\t2\nArnold_Palmer\t1\t3\nArnold_Palmer\t2\t3\nAron_Ralston\t1\t2\nArturo_Gatti\t2\t3\nBashar_Assad\t1\t3\nBashar_Assad\t2\t4\nBernardo_Segura\t1\t2\nBill_Gates\t3\t16\nBill_Gates\t7\t15\nBill_Gates\t11\t13\nBill_Gates\t13\t17\nBo_Pelini\t1\t2\nBob_Stoops\t2\t4\nBob_Stoops\t2\t5\nBobby_Robson\t1\t2\nBode_Miller\t1\t2\nCaroline_Kennedy\t1\t3\nCaroline_Kennedy\t2\t3\nCatherine_Zeta-Jones\t1\t11\nCatherine_Zeta-Jones\t4\t9\nCelso_Amorim\t1\t2\nChan_Gailey\t1\t2\nChanda_Rubin\t2\t5\nChanda_Rubin\t4\t5\nCharles_Bronson\t1\t2\nCharles_Kartman\t1\t2\nCharles_Schumer\t1\t2\nChris_Rock\t1\t2\nChristine_Baumgartner\t1\t2\nChristine_Baumgartner\t2\t4\nColin_Farrell\t1\t7\nColin_Farrell\t2\t7\nColin_Farrell\t3\t6\nColin_Farrell\t4\t8\nDalai_Lama\t1\t2\nDaniel_Radcliffe\t1\t4\nDaryl_Hannah\t1\t2\nDavid_Anderson\t1\t2\nDavid_Anderson\t1\t3\nDavid_Beckham\t1\t15\nDavid_Beckham\t9\t16\nDavid_Beckham\t11\t29\nDavid_Beckham\t13\t29\nDavid_Beckham\t15\t24\nDavid_Beckham\t20\t27\nDavid_Beckham\t27\t31\nDenzel_Washington\t2\t4\nDenzel_Washington\t3\t5\nDianne_Feinstein\t1\t2\nDianne_Feinstein\t1\t3\nDianne_Feinstein\t2\t3\nDick_Clark\t1\t2\nDick_Clark\t1\t3\nDonald_Fehr\t1\t3\nDonald_Fehr\t1\t4\nDonald_Fehr\t2\t3\nDonald_Fehr\t3\t4\nDwayne_Johnson\t1\t2\nEd_Rosenthal\t1\t2\nErik_Morales\t1\t2\nErik_Morales\t2\t3\nEvan_Rachel_Wood\t2\t3\nEvander_Holyfield\t1\t2\nEve_Pelletier\t1\t2\nFarouk_al-Sharaa\t1\t2\nFarouk_al-Sharaa\t1\t3\nFarouk_al-Sharaa\t2\t3\nFrank_Cassell\t1\t2\nFrank_Cassell\t1\t3\nFujio_Cho\t1\t4\nFujio_Cho\t2\t5\nFujio_Cho\t3\t5\nFujio_Cho\t4\t6\nFujio_Cho\t5\t6\nGao_Qiang\t1\t2\nGeoff_Hoon\t1\t2\nGeoff_Hoon\t3\t4\nGeoff_Hoon\t4\t5\nGeorge_Brumley\t1\t2\nGeorge_Papandreou\t1\t2\nGeorge_Papandreou\t1\t3\nGeorge_Papandreou\t1\t4\nGeorge_Papandreou\t3\t4\nGloria_Allred\t1\t2\nGreg_Ostertag\t1\t2\nGreg_Owen\t1\t2\nHanan_Ashrawi\t1\t2\nHarry_Kalas\t1\t2\nHayley_Tullett\t1\t2\nHoward_Dean\t1\t3\nHoward_Dean\t1\t7\nHoward_Dean\t2\t8\nHoward_Dean\t4\t5\nHoward_Dean\t5\t12\nHu_Jintao\t4\t14\nHu_Jintao\t5\t12\nHu_Jintao\t5\t15\nHu_Jintao\t11\t13\nIan_McKellen\t1\t3\nIbrahim_Jaafari\t1\t2\nIsabella_Rossellini\t1\t3\nIshaq_Shahryar\t1\t2\nIsmail_Merchant\t1\t2\nJacques_Chirac\t2\t43\nJacques_Chirac\t19\t28\nJames_Cameron\t1\t3\nJames_McGreevey\t1\t3\nJames_McGreevey\t1\t4\nJason_Alexander\t1\t2\nJason_Kidd\t2\t8\nJason_Kidd\t3\t8\nJason_Kidd\t6\t8\nJelena_Dokic\t1\t2\nJelena_Dokic\t2\t4\nJelena_Dokic\t2\t8\nJelena_Dokic\t3\t4\nJelena_Dokic\t4\t5\nJelena_Dokic\t4\t7\nJelena_Dokic\t4\t8\nJelena_Dokic\t5\t6\nJelena_Dokic\t7\t8\nJennifer_Connelly\t1\t3\nJennifer_Connelly\t1\t4\nJennifer_Connelly\t2\t4\nJennifer_Connelly\t3\t4\nJennifer_Keller\t1\t4\nJennifer_Keller\t3\t4\nJennifer_Reilly\t1\t2\nJennifer_Thompson\t1\t2\nJim_Hahn\t1\t3\nJim_Hahn\t1\t4\nJim_Hahn\t3\t4\nJohnny_Carson\t1\t2\nJorge_Batlle\t1\t2\nJorge_Batlle\t1\t3\nJorge_Rodolfo_Canicoba_Corral\t1\t2\nJuan_Ignacio_Chela\t1\t2\nJuan_Ignacio_Chela\t1\t3\nJuan_Ignacio_Chela\t2\t3\nJustin_Gatlin\t1\t2\nKaren_Mok\t1\t2\nKatie_Harman\t1\t2\nKatie_Harman\t1\t3\nKatie_Harman\t2\t3\nKenneth_Branagh\t1\t2\nKevin_Costner\t1\t3\nKevin_Costner\t2\t6\nKevin_Costner\t2\t8\nKevin_Costner\t6\t8\nLarry_Lindsey\t1\t2\nLeonardo_DiCaprio\t3\t7\nLeonardo_DiCaprio\t5\t6\nLeonardo_DiCaprio\t6\t8\nLindsay_Davenport\t2\t10\nLindsay_Davenport\t5\t9\nLisa_Ling\t1\t2\nLucy_Liu\t2\t4\nLucy_Liu\t2\t5\nLucy_Liu\t3\t5\nManfred_Stolpe\t1\t2\nMaria_Luisa_Mendonca\t1\t2\nMario_Kreutzberger\t1\t2\nMelissa_Etheridge\t1\t2\nMichael_Jordan\t1\t2\nMichael_Jordan\t1\t3\nMichael_Jordan\t2\t4\nMikhail_Youzhny\t1\t2\nMitchell_Daniels\t1\t2\nMitchell_Daniels\t1\t4\nMitchell_Daniels\t3\t4\nMohammad_Khatami\t1\t5\nMohammad_Khatami\t3\t9\nMohammad_Khatami\t8\t10\nMonique_Garbrecht-Enfeldt\t1\t3\nNatalie_Maines\t2\t5\nNatalie_Maines\t4\t5\nNelson_Mandela\t1\t3\nNorodom_Sihanouk\t1\t3\nNorodom_Sihanouk\t2\t3\nOsama_bin_Laden\t2\t4\nOsama_bin_Laden\t3\t4\nOxana_Fedorova\t1\t2\nPeter_Bacanovic\t1\t2\nPhilippe_Noiret\t1\t2\nPlacido_Domingo\t1\t2\nPlacido_Domingo\t2\t3\nPrince_William\t1\t2\nPrincess_Aiko\t1\t2\nPriscilla_Presley\t1\t2\nRichard_Haass\t1\t2\nRichard_Shelby\t1\t2\nRick_Barnes\t1\t2\nRick_Barnes\t1\t3\nRick_Dinse\t1\t3\nRick_Dinse\t2\t3\nRio_Ferdinand\t1\t2\nRita_Grande\t1\t2\nRita_Grande\t2\t3\nRobin_McLaurin_Williams\t1\t2\nSaddam_Hussein\t2\t4\nSaddam_Hussein\t2\t10\nSaddam_Hussein\t3\t11\nSaddam_Hussein\t6\t9\nSally_Field\t1\t2\nSalma_Hayek\t1\t10\nSalma_Hayek\t1\t11\nSandra_Bullock\t1\t3\nSandra_Bullock\t1\t4\nSandra_Bullock\t2\t4\nSandra_Bullock\t3\t4\nSarah_Hughes\t1\t6\nSarah_Hughes\t2\t5\nSarah_Hughes\t3\t5\nSarah_Hughes\t4\t6\nSharon_Frey\t1\t2\nSilvio_Berlusconi\t6\t30\nSilvio_Berlusconi\t8\t23\nSilvio_Berlusconi\t13\t21\nSilvio_Berlusconi\t17\t29\nSilvio_Berlusconi\t18\t25\nSilvio_Berlusconi\t23\t28\nSilvio_Berlusconi\t24\t30\nSilvio_Berlusconi\t26\t32\nSpencer_Abraham\t3\t17\nSteffi_Graf\t2\t5\nSteffi_Graf\t3\t4\nSteven_Spielberg\t1\t5\nSteven_Spielberg\t1\t6\nSteven_Spielberg\t3\t6\nSteven_Spielberg\t4\t6\nSteven_Spielberg\t4\t7\nSteven_Spielberg\t6\t7\nTheresa_May\t1\t2\nTheresa_May\t2\t3\nTippi_Hedren\t1\t2\nTodd_Haynes\t1\t2\nTodd_Haynes\t1\t3\nTodd_Haynes\t1\t4\nTodd_Haynes\t2\t4\nTony_Blair\t18\t86\nTony_Blair\t32\t48\nTony_Blair\t32\t110\nTony_Blair\t53\t102\nTony_Blair\t91\t134\nTony_Blair\t92\t133\nTony_Blair\t105\t121\nVicente_Fox\t4\t30\nVicente_Fox\t9\t16\nVicente_Fox\t11\t17\nVicente_Fox\t15\t30\nVojislav_Kostunica\t1\t3\nVojislav_Kostunica\t2\t4\nVojislav_Kostunica\t4\t7\nVojislav_Kostunica\t5\t7\nWalter_Mondale\t1\t6\nWalter_Mondale\t1\t7\nWalter_Mondale\t5\t7\nWalter_Mondale\t6\t8\nWalter_Mondale\t7\t9\nWang_Yingfan\t2\t3\nWilliam_Bratton\t1\t3\nWilliam_Donaldson\t1\t5\nWilliam_Donaldson\t3\t5\nWilliam_Donaldson\t4\t6\nXavier_Malisse\t1\t3\nXavier_Malisse\t3\t4\nXavier_Malisse\t3\t5\nYevgeny_Kafelnikov\t1\t4\nZarai_Toledo\t1\t2\nAdolfo_Rodriguez_Saa\t1\tDave_Odom\t1\nAdolfo_Rodriguez_Saa\t1\tNancy_Powell\t1\nAdrien_Brody\t3\tDamon_Dash\t1\nAhmed_Ahmed\t1\tMike_Smith\t1\nAl_Sharpton\t5\tCole_Chapman\t1\nAlberto_Sordi\t1\tJames_Cameron\t2\nAlejandro_Lerner\t1\tJesper_Parnevik\t1\nAlejandro_Lerner\t1\tTA_McLendon\t1\nAlex_Penelas\t1\tRobin_Johansen\t1\nAlex_Penelas\t2\tGretchen_Mol\t1\nAlexandra_Stevenson\t3\tRonde_Barber\t1\nAli_Adbul_Karim_Madani\t1\tCarey_Lowell\t1\nAli_Mohammed_Maher\t1\tIsabela_Moraes\t1\nAli_Mohammed_Maher\t1\tIsidro_Pastor\t1\nAlicia_Silverstone\t2\tJennifer_Thompson\t1\nAlicia_Silverstone\t2\tJonathan_Tiomkin\t1\nAlicia_Silverstone\t2\tSerge_Tchuruk\t1\nAndre_Agassi\t31\tBoris_Jordan\t1\nAndre_Techine\t1\tLloyd_Richards\t1\nAndy_Benes\t1\tDoug_Moe\t1\nAndy_Benes\t1\tMitar_Rasevic\t1\nAndy_Bryant\t1\tMike_Slive\t1\nAnna_Kournikova\t8\tColin_Farrell\t1\nAnne_ONeil\t1\tSophie\t1\nAnthony_Lee_Johnson\t1\tDave_Williams\t1\nArnold_Palmer\t1\tStephanie_Zimbalist\t1\nArnold_Palmer\t3\tCharles_Kartman\t1\nAron_Ralston\t1\tBill_Fennelly\t1\nBart_Hendricks\t1\tPhilippe_Noiret\t1\nBen_Kingsley\t1\tDaryl_Hannah\t1\nBen_Kingsley\t1\tJean_Nagel\t1\nBen_Kingsley\t1\tPerry_Farrell\t1\nBenjamin_Neulander\t1\tRobin_Tunney\t1\nBernardo_Segura\t1\tDebra_Shank\t1\nBernardo_Segura\t2\tDouglas_Paal\t1\nBernardo_Segura\t2\tJeanette_Stauffer\t1\nBill_Pryor\t1\tRonde_Barber\t1\nBob_Melvin\t1\tRichard_Hamilton\t1\nBob_Stoops\t3\tWayne_Allard\t1\nBobby_Jackson\t1\tBruce_Gebhardt\t1\nBobby_Jackson\t1\tJP_Suarez\t1\nBobby_Jackson\t1\tMadge_Overhouse\t1\nBobby_Jackson\t1\tNicola_Wells\t1\nBobby_Robson\t1\tRollie_Massimino\t1\nBode_Miller\t1\tDavid_Howard\t1\nBode_Miller\t1\tSteffi_Graf\t1\nBoris_Jordan\t1\tKim_Weeks\t1\nBoris_Jordan\t1\tVincent_Sombrotto\t1\nBrad_Alexander_Smith\t1\tJason_Alexander\t2\nBrad_Alexander_Smith\t1\tKate_Lee\t1\nBrad_Alexander_Smith\t1\tTatiana_Gratcheva\t1\nBrandon_Webb\t1\tHelmut_Panke\t1\nBrandon_Webb\t1\tLarry_Hahn\t1\nBrandon_Webb\t1\tRyan_Leaf\t1\nBrennon_Leighton\t1\tLaurel_Clark\t1\nBrett_Hawke\t1\tTeri_Files\t1\nBruce_Gebhardt\t1\tJean-Luc_Bideau\t1\nBruce_Gebhardt\t1\tMasao_Azuma\t1\nBryan_Cooley\t1\tKatie_Harman\t3\nBryan_Murray\t1\tEric_Schacht\t1\nBryan_Murray\t1\tMikhail_Youzhny\t1\nBryan_Murray\t1\tMitchell_Daniels\t2\nCamille_Colvin\t1\tIrina_Yatchenko\t1\nCarey_Lowell\t1\tCharlie_Coles\t1\nCarl_Pope\t1\tLarry_Hahn\t1\nCarolina_Barco\t1\tDaryl_Hannah\t1\nCarolina_Barco\t1\tLindsay_Davenport\t22\nCarolina_Barco\t1\tNorodom_Sihanouk\t1\nCaroline_Kennedy\t3\tHenry_Suazo\t1\nCatherine_Bell\t1\tGuillaume_Cannet\t1\nCatherine_Zeta-Jones\t10\tPier_Ferdinando_Casini\t1\nCatherine_Zeta-Jones\t11\tHayley_Tullett\t2\nCelso_Amorim\t2\tJuljia_Vysotskij\t1\nCelso_Amorim\t2\tKevin_Costner\t1\nCelso_Amorim\t2\tThomas_Stewart\t1\nChanda_Rubin\t3\tRichard_Tubb\t1\nChante_Jawan_Mallard\t1\tStephen_Glassroth\t1\nChante_Jawan_Mallard\t1\tVicente_Fox\t23\nCharles_Bronson\t2\tHu_Jintao\t4\nCharles_Kartman\t1\tDebra_Shank\t1\nCharles_Schumer\t2\tJames_Watt\t1\nCharles_Schumer\t2\tJustin_Gatlin\t2\nCharles_Schumer\t2\tLionel_Chalmers\t1\nChris_Rock\t2\tDalai_Lama\t1\nChristine_Baumgartner\t2\tVincent_Sombrotto\t1\nChristine_Baumgartner\t3\tLars_Burgsmuller\t1\nChyung_Dai-chul\t1\tDan_Reeves\t1\nCindy_Moll\t1\tDaniel_Radcliffe\t3\nCindy_Moll\t1\tJames_McPherson\t1\nCindy_Moll\t1\tRobin_Johansen\t1\nClaire_De_Gryse\t1\tDeb_Santos\t1\nClaire_Tomalin\t1\tSteve_Case\t1\nClay_Campbell\t1\tLeonardo_DiCaprio\t2\nCole_Chapman\t1\tMarisol_Martinez_Sambran\t1\nColin_Phillips\t1\tIan_McKellen\t3\nColin_Phillips\t1\tLloyd_Richards\t1\nColin_Prescot\t1\tLaurie_Hobbs\t1\nConnie_Freydell\t1\tTommy_Maddox\t1\nCraig_OClair\t1\tSteve_Avery\t1\nDamarius_Bilbo\t1\tJuljia_Vysotskij\t1\nDamon_Dash\t1\tHenry_Suazo\t1\nDaniel_Comisso_Urdaneta\t1\tLarry_Ralston\t1\nDaniel_Radcliffe\t3\tDiane_Green\t2\nDaniel_Radcliffe\t3\tRick_Barnes\t2\nDaniel_Radcliffe\t3\tVicente_Fox\t32\nDany_Heatley\t1\tRichard_Parsons\t1\nDany_Heatley\t1\tTerry_Hoeppner\t1\nDave_Odom\t1\tMaritza_Macias_Furano\t1\nDavid_Beckham\t22\tLaura_Morante\t1\nDavid_Duval\t1\tPhilippe_Noiret\t2\nDavid_Ho\t1\tDoug_Moe\t1\nDavid_Ho\t1\tErskine_Bowles\t1\nDavid_Ho\t1\tEvander_Holyfield\t1\nDavid_Howard\t1\tHugo_Conte\t1\nDenzel_Washington\t4\tHenry_Suazo\t1\nDes_Brown\t1\tEliott_Spitzer\t1\nDes_Brown\t1\tSvetislav_Pesic\t1\nDiana_Ross\t1\tRick_Rickert\t1\nDianne_Feinstein\t3\tDwayne_Johnson\t2\nDick_Clark\t3\tManfred_Stolpe\t1\nDino_Risi\t1\tGabriel_Farhi\t1\nDoc_Rivers\t1\tMelissa_Joan_Hart\t1\nDominick_Dunne\t1\tNicoletta_Braschi\t1\nDon_Flanagan\t1\tEd_Sullivan\t1\nDon_Flanagan\t1\tRatna_Sari_Dewi_Sukarno\t1\nDonald_Keyser\t1\tSalma_Hayek\t2\nDouglas_Paal\t1\tEd_Sullivan\t1\nDouglas_Paal\t1\tRichard_Hamilton\t1\nDusty_Baker\t1\tSaddam_Hussein\t2\nEd_Rendell\t1\tJamie_Dimon\t1\nEd_Rendell\t1\tRichard_Cohen\t1\nEddie_Murray\t1\tKevin_Costner\t7\nElaine_Stritch\t1\tRichard_Parsons\t1\nElena_Tihomirova\t1\tMike_Slive\t1\nElena_Tihomirova\t1\tMohammed_Abu_Sharia\t1\nEric_Schacht\t1\tJennifer_Keller\t2\nErik_Morales\t3\tWerner_Schlager\t1\nErin_Brockovich\t1\tHenry_Suazo\t1\nErin_Brockovich\t1\tMike_Carona\t1\nEvan_Rachel_Wood\t1\tSharon_Frey\t1\nEvander_Holyfield\t1\tJulio_Rossi\t1\nEvander_Holyfield\t1\tMichael_Jordan\t3\nEvander_Holyfield\t1\tMike_Carona\t1\nFatmir_Limaj\t1\tTodd_Haynes\t4\nFelicity_Huffman\t1\tNelson_Acosta\t1\nFelipe_De_Borbon\t1\tJose_Bove\t1\nFrank_Cassell\t2\tJesper_Parnevik\t1\nFrank_Cassell\t3\tRonde_Barber\t1\nFred_Durst\t1\tMarisol_Martinez_Sambran\t1\nFred_Durst\t1\tShavon_Earp\t1\nFujio_Cho\t1\tJavier_Vargas\t1\nFujio_Cho\t2\tTatsuya_Fuji\t1\nFujio_Cho\t3\tMichael_Brandon\t1\nFujio_Cho\t6\tOlene_Walker\t1\nGabriel_Farhi\t1\tLars_Burgsmuller\t1\nGao_Qiang\t2\tKenneth_Brill\t1\nGary_Stevens\t1\tWanda_Ilene_Barzee\t1\nGeoff_Hoon\t1\tOsama_bin_Laden\t3\nGeoff_Hoon\t3\tRichard_Tubb\t1\nGeoff_Hoon\t5\tThomas_Stewart\t1\nGeorge_Brumley\t1\tManfred_Stolpe\t1\nGeorge_Brumley\t1\tRyan_Leaf\t1\nGeorge_Brumley\t2\tSergei_Yushenkov\t1\nGeorge_Papandreou\t2\tTatiana_Panova\t1\nGeorge_Papandreou\t4\tLarry_Lindsey\t2\nGeorge_Papandreou\t4\tPaul_LeClerc\t1\nGhassan_Elashi\t1\tRick_Rickert\t1\nGloria_Allred\t2\tRoman_Tam\t1\nGreg_Kinsey\t1\tPriscilla_Presley\t1\nGreg_Ostertag\t2\tKevin_Costner\t6\nGreg_Owen\t1\tMark_Sisk\t1\nGreg_Owen\t2\tMike_Smith\t1\nGretchen_Mol\t1\tIsabella_Rossellini\t2\nGunilla_Backman\t1\tKathleen_Abernathy\t1\nHanan_Ashrawi\t1\tMario_Kreutzberger\t2\nHans_Leistritz\t1\tSaddam_Hussein\t18\nHans_Leistritz\t1\tSue_Grafton\t1\nHans_Peter_Briegel\t1\tTheresa_May\t2\nHarriet_Lessy\t1\tMike_Carona\t1\nHarry_Kalas\t2\tJoe_Strummer\t1\nHarry_Kalas\t2\tLewis_Booth\t1\nHayley_Tullett\t1\tIan_McKellen\t1\nHenry_Suazo\t1\tRatna_Sari_Dewi_Sukarno\t1\nHernan_Crespo\t1\tRonde_Barber\t1\nHiroyuki_Yoshino\t1\tRollie_Massimino\t1\nHu_Jintao\t6\tJerome_Jenkins\t1\nHugh_Jessiman\t1\tSolomon_Passy\t1\nHugh_Jessiman\t1\tTA_McLendon\t1\nHugo_Conte\t1\tLaurent_Woulzy\t1\nIrina_Yatchenko\t1\tKatie_Harman\t2\nIsidro_Pastor\t1\tMark_Butcher\t1\nIsmail_Merchant\t1\tMack_Brown\t2\nIsmail_Merchant\t2\tKathleen_Abernathy\t1\nIvan_Helguera\t1\tWilliam_Donaldson\t4\nIveta_Benesova\t1\tJacques_Chirac\t50\nJacques_Chirac\t20\tTzipora_Obziler\t1\nJacques_Chirac\t35\tRichard_Shelby\t2\nJames_Cameron\t1\tRichard_Shelby\t2\nJames_McGreevey\t1\tKatie_Harman\t2\nJames_McGreevey\t1\tTzipora_Obziler\t1\nJames_Sensenbrenner\t1\tJimmy_Smits\t1\nJames_Sensenbrenner\t1\tMaria_Shkolnikova\t1\nJames_Watt\t1\tPriscilla_Presley\t2\nJamie_Dimon\t1\tRobert_Korzeniowski\t1\nJason_Alexander\t1\tMike_Maroth\t1\nJason_Alexander\t1\tWayne_Allard\t1\nJason_Kidd\t7\tLouisa_Baileche\t1\nJavier_Vargas\t1\tJesse_Helms\t1\nJeanette_Gray\t1\tKeith_Fotta\t1\nJeanette_Stauffer\t1\tMarie-Josee_Croze\t1\nJeffrey_Donaldson\t1\tLeonardo_DiCaprio\t8\nJeffrey_Donaldson\t1\tPeter_Bacanovic\t1\nJennifer_Connelly\t4\tMartin_Bandier\t1\nJesper_Parnevik\t1\tJustin_Gatlin\t2\nJimmy_Smits\t1\tRobin_Johansen\t1\nJimmy_Smits\t1\tShane_Hmiel\t1\nJoe_Crede\t1\tTom_DeLay\t1\nJohn_Burkett\t1\tLeonardo_DiCaprio\t2\nJohn_McKay\t1\tMary_Sue_Coleman\t1\nJohnny_Hallyday\t1\tOlene_Walker\t1\nJonathan_Tiomkin\t1\tRita_Grande\t2\nJorge_Rodolfo_Canicoba_Corral\t1\tWayne_Allard\t1\nJose_Bove\t1\tJuergen_Trittin\t1\nJuljia_Vysotskij\t1\tPatrick_Coleman\t1\nKate_Lee\t1\tToshimitsu_Motegi\t1\nKathie_Louise_Saunders\t1\tRoberto_Lavagna\t1\nKathie_Louise_Saunders\t1\tRosalyn_Carter\t1\nKenneth_Branagh\t1\tPinar_del_Rio\t1\nKevin_Costner\t5\tStephen_Glassroth\t1\nKhader_Rashid_Rahim\t1\tRichard_Cohen\t1\nKhalid_Khannouchi\t1\tWerner_Schlager\t1\nKim_Su_Nam\t1\tTodd_Haynes\t4\nKim_Weeks\t1\tMarie-Josee_Croze\t1\nKimora_Lee\t1\tRobin_Johansen\t1\nKurt_Suzuki\t1\tScott_Hoch\t1\nLarry_Lindsey\t1\tWanda_Ilene_Barzee\t1\nLarry_Ralston\t1\tRichard_Carl\t1\nLarry_Ralston\t1\tWilliam_Donaldson\t6\nLarry_Ralston\t1\tWillie_Wilson\t1\nLaurel_Clark\t1\tLaurent_Woulzy\t1\nLaurel_Clark\t1\tPriscilla_Presley\t1\nLeandrinho_Barbosa\t1\tMelissa_Joan_Hart\t1\nLeandrinho_Barbosa\t1\tOlene_Walker\t1\nLeon_Barmore\t1\tSachin_Tendulkar\t1\nLeon_Barmore\t1\tYusaku_Miyazato\t1\nLeonard_Schrank\t1\tMarie_Haghal\t1\nLeonard_Schrank\t1\tRick_Rickert\t1\nLinda_Franklin\t1\tMelissa_Joan_Hart\t1\nLindsay_Davenport\t1\tMartin_Burnham\t1\nLindsay_Davenport\t17\tOxana_Fedorova\t3\nLionel_Chalmers\t1\tMohammad_Fares\t1\nLisa_Ling\t2\tMike_Maroth\t1\nLucy_Liu\t3\tPrince_William\t1\nMaria_Luisa_Mendonca\t2\tStephane_Delajoux\t1\nMaria_Luisa_Mendonca\t2\tTerunobu_Maeda\t1\nMaria_Shkolnikova\t1\tMartin_Rodriguez\t1\nMariana_Ohata\t1\tXavier_Malisse\t3\nMario_Kreutzberger\t1\tShavon_Earp\t1\nMario_Kreutzberger\t2\tRaul_Cubas\t1\nMaritza_Macias_Furano\t1\tQusai_Hussein\t1\nMark_Butcher\t1\tScott_Hoch\t1\nMark_Sisk\t1\tMehdi_Baala\t1\nMark_Sisk\t1\tStephen_Swindal\t1\nMasao_Azuma\t1\tMikhail_Kalashnikov\t1\nMcGuire_Gibson\t1\tRichard_Haass\t1\nMehdi_Baala\t1\tSteve_Avery\t1\nMelissa_Joan_Hart\t1\tMikhail_Kalashnikov\t1\nMelissa_Joan_Hart\t1\tSue_Grafton\t1\nMichael_Brandon\t1\tToshimitsu_Motegi\t1\nMichael_Shelby\t1\tOlene_Walker\t1\nMichel_Kratochvil\t1\tSheldon_Silver\t1\nMike_Eskew\t1\tZarai_Toledo\t1\nMike_OConnell\t1\tRoberto_Lavagna\t1\nMike_Sherman\t1\tNatalie_Maines\t3\nMike_Sherman\t1\tPaige_Fitzgerald\t1\nMilt_Heflin\t1\tPier_Ferdinando_Casini\t1\nNicholoas_DiMarzio\t1\tRichard_Parsons\t1\nNikki_McKibbin\t1\tStephen_Swindal\t1\nNikki_McKibbin\t1\tSteven_Tyler\t1\nOsama_Al_Baz\t1\tPatricia_Wartusch\t1\nOsama_Al_Baz\t1\tSandra_Day_OConner\t1\nPatricia_Phillips\t1\tThierry_Falise\t2\nPaula_Locke\t1\tTeri_Files\t1\nPeter_Bacanovic\t2\tRobert_Korzeniowski\t1\nPier_Ferdinando_Casini\t1\tRatna_Sari_Dewi_Sukarno\t1\nPriscilla_Presley\t2\tRaul_Rivero\t1\nRaaf_Schefter\t1\tRick_Dinse\t2\nRichard_Sterner\t1\tSteven_Spielberg\t2\nRick_Dinse\t2\tShavon_Earp\t1\nRoberto_Lavagna\t1\tSandra_Bullock\t4\nRod_Stewart\t1\tSteffi_Graf\t2\nRodolfo_Abalos\t1\tThierry_Falise\t3\nRoman_Tam\t1\tZalmay_Khalilzad\t1\nScott_Hoch\t1\tThomas_Stewart\t1\nSeymour_Cassell\t1\tTodd_Haynes\t4\nShaun_Rusling\t1\tVincent_Sombrotto\t1\nSheldon_Silver\t1\tXavier_Malisse\t3\nStephane_Delajoux\t1\tTristan_Gretzky\t1\nTakahiro_Mori\t1\tTony_Blair\t64\nThierry_Falise\t2\tWerner_Schlager\t1\nAaron_Sorkin\t1\t2\nAbdullah\t1\t3\nAbdullah\t2\t3\nAbdullah\t2\t4\nAbdullah\t3\t4\nAbid_Hamid_Mahmud_Al-Tikriti\t1\t2\nAbid_Hamid_Mahmud_Al-Tikriti\t1\t3\nAlan_Ball\t1\t2\nAlbert_Costa\t3\t5\nAlbert_Costa\t5\t6\nAli_Khamenei\t1\t2\nAli_Khamenei\t1\t3\nAmelia_Vega\t1\t7\nAmelia_Vega\t2\t7\nAmelia_Vega\t3\t5\nAntonio_Banderas\t1\t5\nAntonio_Banderas\t2\t5\nAntonio_Banderas\t3\t5\nArye_Mekel\t1\t2\nAzra_Akin\t1\t3\nAzra_Akin\t1\t4\nBernard_Landry\t2\t3\nBernard_Landry\t2\t4\nBernard_Landry\t3\t4\nBiljana_Plavsic\t1\t2\nBiljana_Plavsic\t1\t3\nBiljana_Plavsic\t2\t3\nBob_Hope\t1\t5\nBob_Hope\t3\t6\nBob_Hope\t4\t5\nBob_Hope\t4\t7\nBridget_Fonda\t1\t3\nBridget_Fonda\t2\t3\nCarlos_Ruiz\t1\t3\nCarlos_Ruiz\t2\t3\nCarly_Fiorina\t1\t2\nCarly_Fiorina\t1\t3\nCherie_Blair\t1\t3\nCherie_Blair\t1\t4\nCherie_Blair\t2\t4\nCherie_Blair\t3\t4\nChuck_Yeager\t1\t2\nChung_Mong-joon\t1\t2\nClaire_Hentzen\t1\t2\nClaire_Leger\t1\t2\nDarren_Clarke\t1\t2\nDavid_Caraway\t1\t2\nDavid_Leahy\t1\t2\nDick_Cheney\t2\t14\nDick_Cheney\t3\t11\nDick_Cheney\t3\t12\nDick_Cheney\t8\t10\nDino_de_Laurentis\t1\t2\nDon_Nickles\t1\t2\nDoris_Schroeder\t1\t3\nDoris_Schroeder\t2\t4\nEduardo_Duhalde\t2\t3\nEduardo_Duhalde\t2\t12\nEduardo_Duhalde\t3\t4\nEduardo_Duhalde\t6\t13\nEduardo_Duhalde\t7\t10\nEduardo_Duhalde\t10\t12\nEdwin_Edwards\t1\t3\nEric_Rosser\t1\t2\nErnie_Eves\t1\t2\nErnie_Fletcher\t1\t2\nEva_Dimas\t1\t2\nFernando_Vargas\t1\t2\nFernando_Vargas\t1\t3\nFernando_Vargas\t1\t4\nFernando_Vargas\t2\t3\nFernando_Vargas\t3\t4\nFrank_Lautenberg\t1\t2\nGeorge_HW_Bush\t1\t3\nGeorge_HW_Bush\t2\t13\nGeorge_HW_Bush\t4\t6\nGeorge_HW_Bush\t5\t8\nGeorge_HW_Bush\t9\t10\nGisele_Bundchen\t1\t2\nGlafcos_Clerides\t1\t2\nGlafcos_Clerides\t1\t3\nGlafcos_Clerides\t2\t3\nGlafcos_Clerides\t2\t4\nGreg_Gilbert\t1\t2\nHashim_Thaci\t1\t2\nHassan_Wirajuda\t1\t2\nHector_Babenco\t1\t3\nHector_Babenco\t2\t3\nHideki_Matsui\t1\t2\nHillary_Clinton\t1\t10\nHillary_Clinton\t1\t14\nHillary_Clinton\t4\t5\nHillary_Clinton\t7\t10\nHillary_Clinton\t11\t13\nHisao_Oguchi\t1\t2\nHitomi_Soga\t1\t4\nHitomi_Soga\t1\t5\nHitomi_Soga\t2\t3\nHitomi_Soga\t3\t4\nJJ_Redick\t1\t2\nJean_Brumley\t1\t2\nJean_Carnahan\t1\t2\nJeremy_Shockey\t1\t2\nJerry_Regier\t1\t3\nJerry_Regier\t2\t3\nJerry_Springer\t1\t2\nJerry_Springer\t1\t4\nJessica_Lynch\t1\t2\nJiang_Zemin\t1\t17\nJiang_Zemin\t2\t3\nJiang_Zemin\t4\t10\nJiang_Zemin\t7\t9\nJiang_Zemin\t15\t18\nJim_Harrick\t1\t2\nJiri_Novak\t3\t4\nJiri_Novak\t3\t8\nJiri_Novak\t3\t9\nJiri_Novak\t5\t6\nJiri_Novak\t5\t10\nJiri_Novak\t5\t11\nJiri_Novak\t7\t10\nJoe_Torre\t1\t3\nJoe_Torre\t2\t4\nJohn_Wolf\t1\t2\nJonathan_Edwards\t1\t6\nJonathan_Edwards\t2\t7\nJonathan_Edwards\t3\t6\nJonathan_Edwards\t5\t6\nJonathan_Edwards\t5\t7\nJonathan_Edwards\t6\t8\nJose_Manuel_Durao_Barroso\t1\t2\nJose_Manuel_Durao_Barroso\t1\t6\nJose_Manuel_Durao_Barroso\t2\t5\nJose_Manuel_Durao_Barroso\t3\t5\nJose_Manuel_Durao_Barroso\t4\t5\nJoseph_Biden\t1\t4\nJoseph_Biden\t2\t3\nJoseph_Biden\t3\t4\nJudi_Dench\t1\t2\nJudy_Genshaft\t1\t2\nKeanu_Reeves\t1\t9\nKeanu_Reeves\t4\t7\nKeanu_Reeves\t6\t9\nKeanu_Reeves\t6\t10\nKeanu_Reeves\t7\t12\nKeira_Knightley\t1\t2\nKen_Watanabe\t1\t2\nKieran_Prendergast\t1\t2\nKing_Abdullah_II\t1\t3\nKing_Abdullah_II\t1\t4\nKing_Abdullah_II\t2\t5\nKing_Abdullah_II\t3\t4\nKirk_Ferentz\t1\t2\nKurt_Busch\t1\t2\nLarry_Bowa\t1\t2\nLarry_Thompson\t1\t3\nLarry_Thompson\t1\t4\nLarry_Thompson\t2\t4\nLaura_Bush\t1\t11\nLaura_Bush\t21\t24\nLaura_Bush\t21\t39\nLaura_Bush\t26\t29\nLauren_Hutton\t1\t2\nLeslie_Ann_Woodward\t1\t2\nLeslie_Moonves\t1\t2\nLyle_Vanclief\t1\t2\nMagui_Serna\t1\t2\nMakhdoom_Amin_Fahim\t1\t3\nMakhdoom_Amin_Fahim\t2\t3\nMarc-Andre_Fleury\t1\t2\nMarco_Antonio_Barrera\t1\t5\nMarco_Antonio_Barrera\t5\t6\nMarie-Reine_Le_Gougne\t1\t2\nMarieta_Chrousala\t1\t2\nMarieta_Chrousala\t1\t3\nMarieta_Chrousala\t2\t3\nMarina_Anissina\t1\t2\nMark_Hamister\t1\t2\nMartha_Stewart\t1\t3\nMartha_Stewart\t1\t5\nMartha_Stewart\t2\t3\nMartha_Stewart\t2\t5\nMartha_Stewart\t3\t4\nMartin_Brodeur\t1\t2\nMartin_McCauley\t1\t2\nMartin_Verkerk\t1\t2\nMartin_Verkerk\t1\t3\nMartin_Verkerk\t2\t3\nMartina_McBride\t1\t3\nMartina_McBride\t2\t4\nMatt_Doherty\t1\t2\nMatt_Doherty\t1\t3\nMatt_Doherty\t2\t3\nMatthew_Perry\t1\t6\nMatthew_Perry\t2\t7\nMatthew_Perry\t3\t4\nMegawati_Sukarnoputri\t6\t23\nMegawati_Sukarnoputri\t7\t22\nMegawati_Sukarnoputri\t10\t15\nMegawati_Sukarnoputri\t11\t24\nMegawati_Sukarnoputri\t20\t24\nMegawati_Sukarnoputri\t20\t30\nMeghann_Shaughnessy\t1\t2\nMichael_Capellas\t1\t2\nMichael_Sullivan\t1\t2\nMike_Brey\t1\t2\nNaji_Sabri\t1\t6\nNaji_Sabri\t2\t4\nNaji_Sabri\t2\t7\nNaji_Sabri\t3\t8\nNaji_Sabri\t6\t7\nNanni_Moretti\t1\t2\nNastassia_Kinski\t1\t2\nNatalie_Coughlin\t2\t3\nNatalie_Coughlin\t4\t6\nNatalie_Coughlin\t5\t6\nNorah_Jones\t3\t15\nNorah_Jones\t4\t12\nNorah_Jones\t7\t15\nNorah_Jones\t9\t15\nNorah_Jones\t11\t12\nNorm_Coleman\t5\t7\nOscar_De_La_Hoya\t1\t3\nOscar_De_La_Hoya\t2\t6\nOscar_De_La_Hoya\t2\t7\nPascal_Lamy\t1\t2\nPat_Burns\t1\t2\nPaul_McCartney\t3\t4\nPaul_McCartney\t3\t5\nPaul_Wellstone\t1\t2\nPaul_Wellstone\t1\t3\nPaul_Wellstone\t2\t3\nPenelope_Cruz\t1\t2\nPenelope_Cruz\t1\t3\nPete_Rose\t1\t2\nPrince_Harry\t1\t2\nPrince_Harry\t2\t3\nPrincess_Caroline\t1\t2\nPrincess_Caroline\t2\t5\nRaquel_Welch\t1\t2\nReggie_Miller\t1\t2\nRenee_Zellweger\t2\t13\nRenee_Zellweger\t2\t16\nRenee_Zellweger\t3\t16\nRicardo_Sanchez\t1\t6\nRicardo_Sanchez\t2\t4\nRichard_Butler\t1\t2\nRubens_Barrichello\t2\t3\nRubens_Barrichello\t4\t5\nRubens_Barrichello\t4\t8\nRubens_Barrichello\t6\t11\nRubens_Barrichello\t9\t12\nSamira_Makhmalbaf\t1\t2\nSamuel_Waksal\t1\t2\nSamuel_Waksal\t1\t3\nSamuel_Waksal\t1\t4\nSamuel_Waksal\t2\t4\nScott_McClellan\t1\t3\nScott_McClellan\t2\t4\nScott_McClellan\t2\t5\nScott_Rudin\t1\t2\nShane_Warne\t1\t2\nSheila_Wellstone\t1\t2\nSheryl_Crow\t1\t3\nSilvan_Shalom\t2\t3\nSilvan_Shalom\t2\t4\nSilvan_Shalom\t2\t6\nSilvan_Shalom\t3\t4\nSilvan_Shalom\t3\t6\nSteve_Mariucci\t1\t3\nSteve_Mariucci\t2\t3\nSteven_Seagal\t1\t2\nTaha_Yassin_Ramadan\t3\t12\nTaha_Yassin_Ramadan\t7\t13\nTammy_Lynn_Michaels\t1\t2\nTheodore_Tweed_Roosevelt\t1\t2\nTheodore_Tweed_Roosevelt\t1\t3\nTheodore_Tweed_Roosevelt\t2\t3\nTom_Crean\t1\t2\nTom_Crean\t3\t5\nTom_Crean\t4\t5\nTony_Bennett\t1\t3\nTorri_Edwards\t1\t2\nTung_Chee-hwa\t1\t2\nTung_Chee-hwa\t1\t8\nTung_Chee-hwa\t2\t8\nVidar_Helgesen\t1\t2\nWarren_Buffett\t1\t2\nWarren_Buffett\t1\t3\nWen_Jiabao\t1\t12\nWen_Jiabao\t2\t11\nWen_Jiabao\t4\t7\nWen_Jiabao\t5\t6\nWen_Jiabao\t7\t9\nWen_Jiabao\t7\t12\nWen_Jiabao\t8\t12\nWen_Jiabao\t10\t11\nWen_Jiabao\t11\t12\nWesley_Clark\t1\t2\nYuri_Malenchenko\t1\t2\nAbbas_Kiarostami\t1\tFujio_Mitarai\t1\nAbdullah\t1\tTeresa_Heinz_Kerry\t1\nAbdullah\t3\tSamuel_Waksal\t1\nAbdullah\t4\tJulio_Cesar_Franco\t1\nAbid_Hamid_Mahmud_Al-Tikriti\t1\tAnjum_Hussain\t1\nAbid_Hamid_Mahmud_Al-Tikriti\t2\tDoris_Schroeder\t1\nAdam_Freier\t1\tHillary_Clinton\t3\nAdam_Freier\t1\tPrincess_Caroline\t1\nAdam_Freier\t1\tRegina_Ip\t1\nAlan_Ball\t1\tKristin_Scott_Thomas\t1\nAlan_Ball\t2\tYuri_Malenchenko\t1\nAlbert_Costa\t6\tGary_Barnett\t1\nAlbert_Costa\t6\tJohn_Marburger\t1\nAlbert_Costa\t6\tWen_Jiabao\t7\nAlberta_Lee\t1\tBabe_Ruth\t1\nAlex_Popov\t1\tKent_Rominger\t2\nAlex_Popov\t1\tMatthew_During\t1\nAli_Khamenei\t2\tRoberto_Canessa\t1\nAmelia_Vega\t1\tGina_Lollobrigida\t1\nAmelia_Vega\t5\tJim_Harrick\t1\nAmy_Pascal\t1\tEduardo_Duhalde\t7\nAmy_Pascal\t1\tHank_Azaria\t1\nAmy_Pascal\t1\tJohn_Marburger\t1\nAmy_Redford\t1\tRoman_Coppola\t1\nAmy_Redford\t1\tVictor_Kraatz\t1\nAnderson_Varejao\t1\tDennis_Oswald\t1\nAnderson_Varejao\t1\tGarth_Drabinsky\t1\nAndrei_Nikolishin\t1\tAngelica_Romero\t1\nAndrew_Bernard\t1\tDon_Nickles\t2\nAndrew_Bernard\t1\tHassan_Wirajuda\t1\nAndrew_Bernard\t1\tMark_Broxmeyer\t1\nAndrew_Fastow\t1\tLuca_Cordero_di_Montezemolo\t1\nAndrew_Fastow\t1\tMeghann_Shaughnessy\t1\nAndrew_Fastow\t1\tTomas_Malik\t1\nAndrew_Luster\t1\tEric_Rosser\t1\nAndrew_Luster\t1\tJose_Manuel_Durao_Barroso\t6\nAndrew_Luster\t1\tLisa_Murkowski\t1\nAnita_DeFrantz\t1\tCarla_Gay_Balingit\t1\nAnita_DeFrantz\t1\tPenny_Lancaster\t1\nAnjum_Hussain\t1\tDavid_Caraway\t2\nAnne_Cavers\t1\tJames_Barksdale\t1\nAnne_Cavers\t1\tStephen_Oake\t1\nAnthony_Hazen\t1\tDebra_Yang\t1\nAntonio_Catania\t1\tBarry_Bonds\t1\nAntonio_Catania\t1\tTaylyn_Solomon\t1\nAretha_Franklin\t1\tJean_Brumley\t1\nAretha_Franklin\t1\tTeruaki_Masumoto\t1\nArt_Lopez\t1\tDiane_Lane\t1\nArthur_Johnson\t1\tSelma_Phoenix\t1\nArye_Mekel\t2\tChung_Mong-joon\t1\nArye_Mekel\t2\tGeorgina_Papin\t1\nBabe_Ruth\t1\tJim_Harrick\t1\nBabe_Ruth\t1\tPete_Aldridge\t1\nBarry_Bonds\t1\tJames_Barksdale\t1\nBarry_Bonds\t1\tMickey_Sherman\t1\nBarry_Switzer\t1\tJiang_Zemin\t11\nBarry_Switzer\t1\tKirk_Ferentz\t2\nBernard_Giraudeau\t1\tKeira_Knightley\t1\nBernard_Landry\t3\tStacey_Jones\t1\nBernard_Landry\t4\tSylvia_Plachy\t1\nBiljana_Plavsic\t1\tKieran_Prendergast\t2\nBill_Cartwright\t1\tClaude_Jorda\t1\nBill_Lerach\t1\tMartin_Verkerk\t2\nBob_Hope\t1\tStanley_Ho\t1\nBob_Hope\t5\tMicah_Knorr\t1\nBob_Hope\t5\tMitchell_Potter\t1\nBob_Menendez\t1\tDavid_Caraway\t2\nBob_Menendez\t1\tLauren_Hutton\t1\nBob_Riley\t1\tDanny_Ainge\t1\nBob_Riley\t1\tNastassia_Kinski\t2\nBob_Riley\t1\tSheila_Wellstone\t2\nBrad_Wilk\t1\tPhil_Cline\t1\nBrad_Wilk\t1\tScott_Dalton\t1\nBrian_Grazier\t1\tTomas_Malik\t1\nBrian_StPierre\t1\tSteve_Mariucci\t2\nCari_Davis\t1\tDon_Henley\t1\nCari_Davis\t1\tMark_Broxmeyer\t1\nCarin_Koch\t1\tJohn_Banko\t2\nCarla_Gay_Balingit\t1\tFrank_Lautenberg\t2\nCarla_Gay_Balingit\t1\tPaula_Dobriansky\t1\nCarlos_Ruiz\t1\tPeter_Schultz\t1\nCarlos_Ruiz\t3\tJennifer_Tilly\t1\nCarly_Fiorina\t2\tPeter_Ueberroth\t1\nCatherine_Woodard\t1\tMike_Sweeney\t1\nChan_Ho_Park\t1\tXiang_Xu\t1\nChance_Mock\t1\tHerb_Ritts\t1\nChance_Mock\t1\tShafal_Mosed\t1\nChance_Mock\t1\tSimona_Hradil\t1\nChance_Mock\t1\tTroy_Jenkins\t1\nCharles_Taylor\t7\tTom_Curley\t1\nChea_Sophara\t1\tJohn_Wolf\t1\nChris_Cirino\t1\tJen_Bice\t1\nChris_Cirino\t1\tMary_Lou_Markakis\t1\nChris_Cirino\t1\tPeri_Gilpin\t1\nChristina_Sawaya\t1\tGreg_Gilbert\t1\nChung_Mong-joon\t1\tDavid_Modell\t1\nChung_Mong-joon\t1\tLuca_Cordero_di_Montezemolo\t1\nChung_Mong-joon\t1\tNick_Markakis\t1\nChung_Mong-joon\t2\tJohn_Rusnak\t1\nClaire_Leger\t1\tDavid_Caraway\t2\nClaire_Leger\t1\tJerry_Sexton\t1\nClaire_Leger\t1\tNobuyuki_Idei\t1\nClark_Randt\t1\tKatie_Boone\t1\nClark_Randt\t1\tMarc-Andre_Fleury\t1\nClemente_de_la_Vega\t1\tRon_Gonzales\t1\nColin_Campbell\t1\tFrank_Keating\t1\nColin_Campbell\t1\tJean_Carnahan\t2\nColin_Campbell\t1\tMitchell_Potter\t1\nColleen_Atwood\t1\tPenelope_Cruz\t2\nCraig_Morgan\t1\tMatthew_McConaughey\t1\nDan_Duquette\t1\tPaddy_Torsney\t1\nDaniel_Ortega\t1\tNorah_Jones\t6\nDaniel_Patrick_Moynihan\t1\tEglis_Yaima_Cruz\t1\nDaniel_Patrick_Moynihan\t1\tNewton_Carlton_Slawson\t1\nDaniel_Rouse\t1\tDoris_Schroeder\t1\nDaniel_Rouse\t1\tMike_Johanns\t1\nDaniell_Sunjata\t1\tMarc-Andre_Fleury\t2\nDanny_Ainge\t1\tLee_Ann_Terlaji\t1\nDavid_Leahy\t1\tJerry_Sexton\t1\nDavid_Scott_Morris\t1\tValerie_Thwaites\t1\nDavid_Zeplowitz\t1\tJerry_Springer\t1\nDawn_Staley\t1\tHasan_Wirayuda\t1\nDebra_Rose\t1\tJonathan_Edwards\t2\nDebra_Yang\t1\tHashim_Thaci\t2\nDebra_Yang\t1\tYekaterina_Guseva\t1\nDenis_Fassou-Nguesso\t1\tWilliam_Overlin\t1\nDerrick_Taylor\t1\tGiuseppe_Morchio\t1\nDerrick_Taylor\t1\tWilliam_Overlin\t1\nDick_Cheney\t5\tJames_Murdoch\t1\nDick_Cheney\t8\tNobuyuki_Idei\t1\nDick_Smothers\t1\tYoon_Won-Sik\t1\nDita_Von_Tesse\t1\tMohammed_Al-Douri\t12\nDon_Henley\t1\tErnie_Eves\t1\nDon_Henley\t1\tGil_Cates\t1\nDon_Henley\t1\tStephen_Frears\t1\nDon_Henley\t1\tZiwang_Xu\t1\nDonald_Regan\t1\tJohn_Gruden\t1\nDoris_Schroeder\t2\tJoe_Mantegna\t1\nEduardo_Duhalde\t1\tPaula_Dobriansky\t1\nEduardo_Duhalde\t2\tTab_Turner\t1\nEduardo_Duhalde\t13\tJames_Murdoch\t1\nEdward_Egan\t1\tErnie_Fletcher\t2\nEdward_Johnson\t1\tJessica_Capshaw\t1\nEl_Hadji_Diouf\t1\tHitomi_Soga\t2\nEmilio_Botin\t1\tLuca_Cordero_di_Montezemolo\t1\nEmilio_Botin\t1\tRobert_Hyatt\t1\nEnrique_Iglesias\t1\tGisele_Bundchen\t2\nEric_Bana\t1\tMike_Sweeney\t1\nEric_Bana\t1\tTab_Turner\t1\nEric_Benet\t1\tMohammad_Mustapha_Miro\t1\nEric_Rosser\t1\tMarc-Andre_Fleury\t2\nEric_Rosser\t1\tPeter_Chan\t1\nErnie_Eves\t2\tHana_Makhmalbaf\t1\nFernando_Vargas\t1\tJulio_Cesar_Franco\t1\nFernando_Vargas\t3\tMartin_Verkerk\t3\nFlavia_Pennetta\t1\tLarry_Flynt\t1\nFlavia_Pennetta\t1\tMicah_Knorr\t1\nFlavia_Pennetta\t1\tPaul_Wellstone\t1\nFrank_Keating\t1\tPaul_McCartney\t7\nFrank_Lautenberg\t2\tMichael_Capellas\t1\nFrank_Lautenberg\t2\tSteve_Allee\t1\nFujio_Mitarai\t1\tHarvey_Weinstein\t1\nGabriella_Bo\t1\tJeremy_Shockey\t2\nGavyn_Arthur\t1\tKevin_Hearn\t1\nGavyn_Arthur\t1\tLynne_Slepian\t1\nGavyn_Arthur\t1\tZahir_Shah\t1\nGeorge_HW_Bush\t7\tGeorge_Maxwell_Richards\t1\nGeorge_HW_Bush\t13\tPenny_Lancaster\t1\nGeorge_Maxwell_Richards\t1\tReggie_Miller\t1\nGeorgina_Papin\t1\tMary_Lou_Retton\t1\nGeorgina_Papin\t1\tSvend_Robinson\t1\nGerry_Kelly\t1\tKeira_Knightley\t1\nGiannina_Facio\t1\tPeri_Gilpin\t1\nGideon_Black\t1\tKevin_Hearn\t1\nGideon_Black\t1\tShafal_Mosed\t1\nGisele_Bundchen\t2\tPenny_Lancaster\t1\nGiuseppe_Morchio\t1\tPenny_Lancaster\t1\nGreg_Frers\t1\tMohammed_Al-Douri\t4\nGreg_Gilbert\t1\tMehmet_Ali_Sahin\t1\nGregorio_Honasan\t1\tJim_Schwarz\t1\nGregorio_Honasan\t1\tJonathan_Fine\t1\nGregorio_Honasan\t1\tMatt_Doherty\t1\nHama_Arba_Diallo\t1\tZhang_Yimou\t1\nHana_Makhmalbaf\t1\tRaquel_Welch\t1\nHassan_Wirajuda\t1\tScott_Dalton\t1\nHector_Babenco\t2\tTalisa_Bratt\t1\nHerb_Ritts\t1\tMark_Broxmeyer\t1\nHugh_Campbell\t1\tKen_Watanabe\t1\nHugh_Campbell\t1\tMasamori_Tokuyama\t1\nHugh_Campbell\t1\tTom_Foy\t1\nImran_Khan\t1\tMatt_Morris\t1\nImran_Khan\t1\tNancy_Humbert\t1\nIvan_Lee\t1\tJennifer_Furminger\t1\nJames_Hallock\t1\tRobert_Beck\t1\nJames_Murdoch\t1\tMartina_McBride\t3\nJamie_Kellner\t1\tTomas_Malik\t1\nJamie_King\t1\tLauren_Hutton\t2\nJane_Fonda\t2\tMartha_Stewart\t4\nJanet_Leigh\t1\tMarianne_Stanley\t1\nJaromir_Jagr\t1\tTroy_Jenkins\t1\nJean_Brumley\t2\tJim_Harrick\t1\nJen_Bice\t1\tJudi_Dench\t2\nJennifer_Furminger\t1\tMatthew_During\t1\nJennifer_Tilly\t1\tSerge_Klarsfeld\t1\nJennifer_Tilly\t1\tStella_Tennant\t1\nJeremy_Shockey\t2\tRobert_Beck\t1\nJerry_Regier\t2\tPaulina_Rodriguez_Davila\t1\nJerry_Regier\t3\tLee_Hyung-taik\t1\nJerry_Regier\t3\tPete_Rose\t2\nJessica_Capshaw\t1\tPenelope_Cruz\t2\nJiang_Zemin\t4\tMichelangelo_Antonioni\t1\nJiang_Zemin\t13\tRoman_Coppola\t1\nJim_Sterk\t1\tJonathan_Edwards\t3\nJim_Sterk\t1\tKen_Watanabe\t2\nJoey_Harrington\t1\tNick_Price\t1\nJohn_Lynch\t1\tMichael_Sullivan\t1\nJohn_Robbins\t1\tTom_Foy\t1\nJohn_Thune\t1\tMilan_Milutinovic\t1\nJohn_Velazquez\t1\tMarco_Antonio_Barrera\t3\nJohn_Velazquez\t1\tTammy_Lynn_Michaels\t1\nJohn_Wolf\t2\tPrince_Harry\t1\nJonathan_Byrd\t1\tMike_Matheny\t1\nJonathan_Byrd\t1\tSheikh_Ahmed_Yassin\t1\nJonathan_Horton\t1\tLee_Ann_Terlaji\t1\nJorge_Alberto_Galindo\t1\tRoger_King\t1\nJoseph_Biden\t5\tMahdi_Al_Bassam\t1\nJoseph_Biden\t5\tTung_Chee-hwa\t4\nJudy_Genshaft\t1\tShane_Warne\t1\nJules_Asner\t1\tRobert_Beck\t1\nJulien_Varlet\t1\tScott_Dalton\t1\nKate_Burton\t1\tMartha_Stewart\t2\nKate_Richardson\t1\tRoman_Coppola\t1\nKatie_Boone\t1\tUthai_Pimchaichon\t1\nKatie_Smith\t1\tLeland_Chapman\t1\nKatrin_Susi\t1\tLuca_Cordero_di_Montezemolo\t1\nKay_Bailey_Hutchison\t1\tTheodore_Tweed_Roosevelt\t3\nKieran_Prendergast\t1\tLachlan_Murdoch\t1\nKing_Abdullah_II\t4\tRobert_Hyatt\t1\nKirk_Ferentz\t2\tMilan_Milutinovic\t1\nLachlan_Murdoch\t1\tMickey_Sherman\t1\nLarry_Flynt\t1\tPhil_Cline\t1\nLarry_Greene\t1\tMike_Brey\t2\nLaurence_Tribe\t1\tUthai_Pimchaichon\t1\nLee_Ann_Terlaji\t1\tRoman_Coppola\t1\nLee_Yuan-tseh\t1\tShafal_Mosed\t1\nLee_Yuan-tseh\t1\tYuri_Malenchenko\t2\nLeland_Chapman\t1\tTheodore_Tweed_Roosevelt\t1\nLeslie_Moonves\t2\tRobert_Hyatt\t1\nLisa_Murkowski\t1\tSerge_Klarsfeld\t1\nMagui_Serna\t1\tMaura_Tierney\t1\nMahdi_Al_Bassam\t1\tMarc-Andre_Fleury\t2\nMahdi_Al_Bassam\t1\tMother_Teresa\t1\nMalak_Habbak\t1\tPrince_Harry\t3\nManuel_Pellegrini\t1\tRolf_Eckrodt\t1\nManuela_Montebrun\t1\tMartina_McBride\t2\nManuela_Montebrun\t1\tSteven_Seagal\t2\nMarion_Fahnestock\t1\tWen_Jiabao\t3\nMark_Hamister\t1\tXiang_Xu\t1\nMartha_Martinez_Flores\t1\tMike_Brey\t2\nMartha_Stewart\t5\tVictor_Kraatz\t1\nMartin_Lawrence\t1\tMickey_Sherman\t1\nMartin_Lawrence\t1\tPenny_Lancaster\t1\nMartin_McCauley\t2\tSteven_Seagal\t1\nMartin_Verkerk\t1\tSteven_Seagal\t1\nMartina_McBride\t3\tPeter_Schultz\t1\nMasamori_Tokuyama\t1\tRegina_Ip\t1\nMasamori_Tokuyama\t1\tSerge_Melac\t1\nMatt_Doherty\t2\tSaoud_Al_Faisal\t1\nMeghann_Shaughnessy\t1\tWilliam_Perry\t1\nMehmet_Ali_Sahin\t1\tPeri_Gilpin\t1\nMehmet_Ali_Sahin\t1\tRaquel_Welch\t2\nMichael_Capellas\t1\tVictor_Garber\t1\nMickey_Sherman\t1\tRoman_Coppola\t1\nMike_Brey\t2\tNick_Markakis\t1\nMike_Johanns\t1\tPascal_Lamy\t1\nMike_Matheny\t1\tNorm_Coleman\t5\nMohammad_Mustapha_Miro\t1\tSteve_Mariucci\t2\nMother_Teresa\t1\tYekaterina_Guseva\t1\nNancy_Humbert\t1\tPark_Na-kyong\t1\nNanni_Moretti\t1\tShigeru_Ishiba\t1\nNatalia_Dmitrieva\t1\tWillie_Nelson\t1\nNatalie_Juniardi\t1\tUthai_Pimchaichon\t1\nNick_Price\t1\tTab_Turner\t1\nNorm_Coleman\t4\tPeri_Gilpin\t1\nNorm_Coleman\t7\tScott_McClellan\t5\nPaddy_Torsney\t1\tTung_Chee-hwa\t9\nPark_Na-kyong\t1\tVecdi_Gonul\t1\nPatrick_Rafter\t1\tPeter_Care\t1\nPierre_Van_Hooijdonk\t1\tScott_McClellan\t1\nRegina_Ip\t1\tRohman_al-Ghozi\t1\nRenee_Zellweger\t9\tYuri_Malenchenko\t2\nRolf_Eckrodt\t2\tTeresa_Heinz_Kerry\t1\nRubens_Barrichello\t10\tStella_Tennant\t1\nSaoud_Al_Faisal\t1\tVecdi_Gonul\t1\nScott_Dalton\t1\tZach_Safrin\t1\nScott_McClellan\t2\tTom_Schnackenberg\t1\nTodd_MacCulloch\t1\tWillie_Nelson\t1\nTom_Curley\t1\tWanda_de_la_Jesus\t1\nTroy_Jenkins\t1\tWalid_Al-Awadi\t1\nWilliam_Overlin\t1\tYekaterina_Guseva\t1\nAbdoulaye_Wade\t1\t2\nAbdoulaye_Wade\t1\t3\nAbdoulaye_Wade\t2\t3\nAdam_Sandler\t1\t2\nAdam_Sandler\t1\t4\nAdam_Sandler\t2\t3\nAicha_El_Ouafi\t1\t3\nAicha_El_Ouafi\t2\t3\nAkbar_Hashemi_Rafsanjani\t1\t3\nAkbar_Hashemi_Rafsanjani\t2\t3\nAl_Pacino\t1\t2\nAl_Pacino\t1\t3\nAlex_Barros\t1\t2\nAllyson_Felix\t1\t3\nAllyson_Felix\t1\t4\nAllyson_Felix\t1\t5\nAllyson_Felix\t4\t5\nAnastasia_Myskina\t1\t2\nAndy_Roddick\t8\t12\nAndy_Roddick\t10\t15\nAndy_Roddick\t13\t15\nAnna_Nicole_Smith\t1\t2\nAntonio_Palocci\t1\t8\nAntonio_Palocci\t3\t6\nAntonio_Palocci\t4\t5\nAntonio_Palocci\t5\t7\nAntonio_Palocci\t6\t8\nArnoldo_Aleman\t1\t3\nArnoldo_Aleman\t3\t5\nAshton_Kutcher\t1\t3\nAshton_Kutcher\t2\t3\nAugusto_Roa_Bastos\t1\t2\nAung_San_Suu_Kyi\t1\t2\nBarry_Zito\t1\t2\nBill_Graham\t1\t9\nBill_Graham\t3\t4\nBill_Graham\t4\t6\nBill_Graham\t5\t6\nBob_Dole\t1\t3\nBruce_Weber\t1\t2\nCarlos_Mesa\t1\t2\nCarolyn_Dawn_Johnson\t1\t2\nCarolyn_Dawn_Johnson\t2\t3\nCeline_Dion\t3\t8\nChakib_Khelil\t1\t2\nChen_Shui-bian\t2\t4\nChen_Shui-bian\t3\t5\nChristopher_Walken\t1\t3\nChristopher_Walken\t1\t4\nClaudia_Pechstein\t1\t2\nClaudia_Pechstein\t1\t4\nClaudia_Pechstein\t3\t4\nClaudia_Pechstein\t3\t5\nClaudia_Pechstein\t4\t5\nClay_Aiken\t2\t4\nClay_Aiken\t3\t4\nClay_Aiken\t3\t5\nColin_Powell\t40\t71\nColin_Powell\t49\t234\nColin_Powell\t133\t170\nColin_Powell\t182\t198\nCristina_Fernandez\t1\t2\nDaisy_Fuentes\t2\t3\nDamon_van_Dam\t1\t2\nDan_Wheldon\t1\t2\nDavid_Coulthard\t1\t2\nDavid_Kelley\t1\t2\nDebra_Brown\t1\t2\nDennis_Erickson\t1\t2\nDerek_Lowe\t1\t2\nEddie_Sutton\t1\t2\nEdie_Falco\t1\t2\nElijah_Wood\t2\t3\nElizabeth_Hurley\t1\t4\nElizabeth_Hurley\t2\t5\nEmily_Robison\t1\t2\nEthan_Hawke\t1\t4\nEunice_Barber\t1\t2\nFelix_Mantilla\t1\t2\nFidel_Castro\t1\t18\nFidel_Castro\t3\t7\nFidel_Castro\t5\t8\nFidel_Castro\t8\t12\nFidel_Castro\t11\t13\nFrancisco_Flores\t1\t2\nFrancisco_Flores\t1\t3\nFrank_Dunham_Jr\t1\t2\nFranko_Simatovic\t1\t2\nFred_Eckhard\t1\t2\nFred_Eckhard\t1\t3\nFred_Eckhard\t2\t3\nGL_Peiris\t1\t2\nGL_Peiris\t1\t3\nGL_Peiris\t2\t3\nGL_Peiris\t2\t4\nGarry_Kasparov\t1\t2\nHassan_Nasrallah\t1\t2\nHeidi_Klum\t1\t3\nHeidi_Klum\t1\t4\nHeidi_Klum\t2\t4\nHeidi_Klum\t3\t4\nHeinz_Feldmann\t1\t2\nHeinz_Feldmann\t2\t3\nIban_Mayo\t1\t2\nImad_Moustapha\t1\t2\nInam-ul-Haq\t1\t2\nJames_Gandolfini\t1\t3\nJames_Gandolfini\t2\t3\nJanet_Thorpe\t1\t2\nJean-Pierre_Raffarin\t1\t2\nJean-Pierre_Raffarin\t1\t6\nJean-Pierre_Raffarin\t3\t4\nJean-Pierre_Raffarin\t3\t5\nJean-Pierre_Raffarin\t4\t7\nJean-Pierre_Raffarin\t5\t7\nJean-Pierre_Raffarin\t6\t7\nJeffrey_Scott_Postell\t1\t2\nJennifer_Capriati\t2\t14\nJennifer_Capriati\t7\t32\nJennifer_Capriati\t33\t42\nJob_Cohen\t1\t2\nJohn_McCormack\t1\t2\nJohn_Paul_II\t1\t4\nJohn_Paul_II\t2\t5\nJohn_Paul_II\t2\t8\nJohn_Paul_II\t4\t9\nJohn_Paul_II\t10\t11\nJohn_Ruiz\t1\t2\nJohn_Stallworth\t1\t2\nJohn_Stockton\t2\t4\nJohn_Travolta\t2\t6\nJohn_Travolta\t3\t5\nJohn_Travolta\t5\t7\nJonathan_Mostow\t1\t2\nJorge_Arce\t1\t2\nJoschka_Fischer\t1\t10\nJoschka_Fischer\t6\t11\nJoschka_Fischer\t7\t11\nJoschka_Fischer\t11\t17\nJoschka_Fischer\t15\t16\nJose_Canseco\t1\t3\nJuan_Manuel_Marquez\t1\t2\nJuan_Manuel_Marquez\t1\t3\nJuan_Manuel_Marquez\t2\t3\nJuan_Valencia_Osorio\t1\t2\nJulie_Gerberding\t9\t13\nJulie_Gerberding\t12\t15\nKate_Hudson\t1\t4\nKate_Hudson\t1\t8\nKate_Hudson\t2\t3\nKate_Hudson\t4\t9\nKate_Hudson\t6\t7\nKemal_Dervis\t1\t3\nKemal_Dervis\t2\t3\nKenneth_Evans\t1\t2\nKifah_Ajouri\t1\t2\nLarry_Lucchino\t1\t2\nLatrell_Sprewell\t1\t2\nLech_Walesa\t1\t2\nLee_Tae-sik\t1\t2\nLisa_Marie_Presley\t1\t3\nLiza_Minnelli\t2\t3\nLiza_Minnelli\t3\t4\nLiza_Minnelli\t3\t6\nLiza_Minnelli\t4\t5\nLiza_Minnelli\t5\t6\nLiza_Minnelli\t6\t7\nMadonna\t1\t4\nMadonna\t2\t3\nMadonna\t4\t5\nMariah_Carey\t3\t6\nMary_Tyler_Moore\t1\t2\nMathias_Reichhold\t1\t2\nMatt_Damon\t1\t2\nMatt_Damon\t1\t3\nMatt_Damon\t2\t4\nMatt_Damon\t3\t4\nMaureen_Fanning\t1\t2\nMelanie_Griffith\t1\t2\nMelanie_Griffith\t1\t3\nMelanie_Griffith\t2\t3\nMichael_Ballack\t1\t2\nMichael_Winterbottom\t1\t3\nMichael_Winterbottom\t2\t3\nMichelle_Collins\t1\t2\nMilo_Maestrecampo\t1\t2\nMohamed_Benaissa\t1\t2\nMohamed_ElBaradei\t2\t4\nMohamed_ElBaradei\t3\t8\nMorgan_Freeman\t1\t2\nMuhammad_Ali\t1\t3\nMuhammad_Ali\t1\t7\nMuhammad_Ali\t2\t5\nMuhammad_Ali\t6\t10\nMuhammad_Ali\t7\t9\nMukesh_Ambani\t1\t2\nMukesh_Ambani\t1\t3\nParis_Hilton\t1\t2\nPat_Cox\t1\t2\nPaul_Burrell\t3\t7\nPaul_Burrell\t5\t11\nPaul_Burrell\t8\t10\nPaul_Wolfowitz\t8\t10\nPaula_Radcliffe\t1\t2\nPaula_Radcliffe\t1\t3\nPaula_Radcliffe\t2\t3\nPaula_Radcliffe\t2\t4\nPaula_Radcliffe\t3\t4\nPaula_Radcliffe\t3\t5\nPaula_Radcliffe\t4\t5\nPaulo_Cesar_Pinheiro\t1\t2\nPedro_Solbes\t1\t3\nPedro_Solbes\t1\t4\nPedro_Solbes\t2\t3\nPedro_Solbes\t3\t4\nPete_Carroll\t1\t2\nPete_Carroll\t1\t3\nPete_Carroll\t2\t3\nPete_Sampras\t2\t12\nPete_Sampras\t2\t13\nPete_Sampras\t3\t15\nPete_Sampras\t4\t20\nPete_Sampras\t6\t7\nPete_Sampras\t6\t8\nPete_Sampras\t10\t13\nPete_Sampras\t12\t15\nPeter_Struck\t1\t5\nPeter_Struck\t2\t5\nPhil_Vassar\t1\t2\nPierre_Boulanger\t1\t2\nPrince_Willem-Alexander\t1\t2\nPrince_Willem-Alexander\t1\t3\nPrince_Willem-Alexander\t2\t3\nQueen_Elizabeth_II\t3\t7\nQueen_Elizabeth_II\t9\t12\nQueen_Elizabeth_II\t10\t11\nQueen_Elizabeth_II\t10\t12\nRay_Nagin\t1\t2\nRicardo_Maduro\t1\t2\nRichard_Branson\t1\t2\nRichard_Virenque\t1\t4\nRichard_Virenque\t1\t6\nRichard_Virenque\t1\t7\nRichard_Virenque\t2\t7\nRichard_Virenque\t2\t8\nRick_Carlisle\t2\t4\nRick_Wagoner\t1\t2\nRobbie_Williams\t1\t2\nRobbie_Williams\t1\t3\nRoberto_Carlos\t2\t3\nRoberto_Carlos\t2\t4\nRoseanne_Barr\t1\t2\nRoseanne_Barr\t2\t3\nRuben_Studdard\t1\t2\nSammy_Sosa\t1\t2\nSarah_Jessica_Parker\t1\t3\nSarah_Jessica_Parker\t2\t4\nSarah_Jessica_Parker\t3\t4\nSharon_Davis\t1\t2\nShaul_Mofaz\t1\t2\nShaul_Mofaz\t2\t3\nStan_Heath\t1\t2\nSvetlana_Koroleva\t1\t2\nTerrell_Suggs\t1\t2\nTim_Henman\t2\t12\nTim_Henman\t8\t19\nTom_Daschle\t7\t8\nTom_Daschle\t15\t21\nTom_Daschle\t15\t22\nTony_Curtis\t1\t2\nValentino_Rossi\t1\t2\nValentino_Rossi\t2\t4\nValentino_Rossi\t3\t6\nValentino_Rossi\t4\t5\nValentino_Rossi\t5\t6\nVanessa_Redgrave\t1\t3\nVanessa_Redgrave\t1\t4\nVanessa_Redgrave\t2\t5\nVanessa_Redgrave\t3\t4\nVictoria_Clarke\t1\t5\nVladimiro_Montesinos\t1\t2\nVladimiro_Montesinos\t1\t3\nVladimiro_Montesinos\t2\t3\nWayne_Ferreira\t1\t2\nWayne_Ferreira\t1\t3\nWayne_Ferreira\t1\t5\nWayne_Ferreira\t2\t5\nWayne_Ferreira\t3\t4\nWill_Smith\t1\t2\nYasser_Arafat\t1\t6\nYasser_Arafat\t1\t8\nYasser_Arafat\t2\t3\nYasser_Arafat\t2\t5\nYasser_Arafat\t3\t4\nYasser_Arafat\t3\t8\nYasser_Arafat\t4\t5\nYasser_Arafat\t5\t8\nYuri_Fedotov\t1\t2\nZoran_Djindjic\t1\t3\nZoran_Djindjic\t1\t4\nAaron_Patterson\t1\tFrank_Bell\t1\nAbdoulaye_Wade\t4\tBruce_Weber\t2\nAbner_Martinez\t1\tCarlos_Alberto\t1\nAdam_Sandler\t2\tMatthew_Ouimet\t1\nAdam_Sandler\t3\tSaeed_Anwar\t1\nAdolfo_Aguilar_Zinser\t3\tJaime_Pressly\t1\nAgnelo_Queiroz\t1\tAung_San_Suu_Kyi\t2\nAgnelo_Queiroz\t1\tDave_Barr\t1\nAicha_El_Ouafi\t3\tMichael_Lechner\t1\nAkbar_Hashemi_Rafsanjani\t1\tLarry_Harris\t1\nAl_Pacino\t2\tCharles_Cope\t1\nAlex_Barros\t1\tBrandon_Jones\t1\nAlex_Barros\t2\tWill_Smith\t2\nAlex_Ferguson\t1\tRainer_Gut\t1\nAlex_Wallau\t1\tShireen_Amir_Begum\t1\nAlexandra_Jackson\t1\tLarry_Harris\t1\nAlfonso_Portillo\t1\tBenito_Santiago\t1\nAlfonso_Portillo\t1\tFaye_Alibocus\t1\nAlfonso_Portillo\t1\tFidel_Castro\t17\nAli_Abdullah_Saleh\t1\tKhalid_Qazi\t1\nAllan_Houston\t1\tAndy_Garcia\t1\nAllan_Houston\t1\tHeidi_Klum\t1\nAllan_Houston\t1\tThomas_Mesereau_Jr\t1\nAlly_Sheedy\t1\tHugh_Carey\t1\nAlly_Sheedy\t1\tMyung_Yang\t1\nAmanda_Marsh\t1\tTony_Curtis\t2\nAnastasia_Myskina\t1\tRaul_Gonzalez\t1\nAnastasia_Myskina\t3\tLen_Jenoff\t2\nAndrzej_Tyszkiewicz\t1\tWes_Craven\t1\nAndy_Griggs\t1\tLech_Walesa\t2\nAndy_Rooney\t1\tJessica_Simpson\t1\nAnna_Nicole_Smith\t2\tMarcus_Garrettson\t1\nAntonio_Palocci\t3\tLiza_Minnelli\t1\nAntonio_Palocci\t5\tJC_Chasez\t1\nAntonio_Palocci\t5\tJose_Woldenberg\t1\nAntonio_Palocci\t6\tJohn_Geoghan\t1\nAntonio_Palocci\t8\tHans_Corell\t1\nArif_Mardin\t1\tEduardo_Fischer\t1\nArnaud_Lagardere\t1\tMelanie_Griffith\t3\nAshton_Kutcher\t2\tDaniel_Barenboim\t1\nAsif_Hanif\t1\tRobbie_Williams\t1\nAsmaa_Assad\t1\tBarry_Hinson\t1\nAung_San_Suu_Kyi\t1\tCharla_Moye\t1\nAzmi_Bishara\t1\tSammy_Sosa\t2\nBarry_Hinson\t1\tNino_DAngelo\t1\nBarry_Zito\t2\tChris_Gratton\t1\nBill_Graham\t8\tMichelle_Hofland\t1\nBill_Graham\t9\tJacqueline_Marris\t1\nBill_Readdy\t1\tBrendan_Gaughan\t1\nBill_Readdy\t1\tJaymon_Crabb\t1\nBill_Readdy\t1\tYasser_Arafat\t3\nBilly_Rork\t1\tEva_Mendes\t1\nBilly_Rork\t1\tGerman_Khan\t1\nBilly_Rork\t1\tPeter_Struck\t2\nBison_Dele\t1\tBrian_McIntyre\t1\nBob_Dole\t2\tDai_Chul_Chyung\t1\nBob_Dole\t2\tJohn_Henry\t1\nBob_Dole\t3\tChris_Gratton\t1\nBob_Dole\t3\tHugh_Carey\t1\nBob_Geldof\t1\tZoran_Djindjic\t2\nBob_Geldof\t2\tEd_Wade\t1\nBob_Holden\t1\tFernando_Leon_de_Aranoa\t1\nBob_Iger\t1\tEdie_Falco\t1\nBob_Iger\t1\tJean-Claude_Van_Damme\t1\nBrian_Clemens\t1\tBrian_Meadors\t1\nBrian_Clemens\t1\tMelanie_Griffith\t2\nBrian_Heidik\t2\tDjabir_Said-Guerni\t1\nBrian_McIntyre\t1\tHans_Corell\t1\nBrian_McIntyre\t1\tMohammed_Abulhasan\t1\nBrian_Pavlich\t1\tRuben_Wolkowyski\t1\nBrook_Robinson\t1\tTom_McClintock\t1\nBrooke_Adams\t1\tPaula_Prentiss\t1\nBrooke_Gordon\t1\tJoschka_Fischer\t12\nBruce_Weber\t1\tHal_Sellers\t1\nBryan_Thomas\t1\tJoey_Mantia\t1\nBustam_A_Zedan_Aljanabi\t1\tKajsa_Bergqvist\t1\nCalvin_Joseph_Coleman\t1\tHassan_Nasrallah\t1\nCarla_Sullivan\t1\tEdie_Falco\t1\nCarlos_Barragan\t1\tChen_Shui-bian\t3\nCarlos_Salinas\t1\tNorman_Mailer\t1\nCarlos_Salinas\t1\tSonya_Walger\t1\nCarolyn_Dawn_Johnson\t3\tLydia_Shum\t1\nCarolyn_Kuhl\t1\tPierre_Boulanger\t1\nCeline_Dion\t2\tJohn_Stallworth\t2\nCeline_Dion\t5\tLinda_Baboolal\t1\nCeline_Dion\t5\tTom_Poston\t1\nChakib_Khelil\t2\tChuck_Woolery\t1\nCharla_Moye\t1\tPatti_Balgojevich\t1\nCharles_Cope\t1\tGarry_Alejano\t1\nCharles_Holzner\t1\tEurico_Guterres\t1\nCharles_Holzner\t1\tGreg_Kinnear\t1\nChen_Shui-bian\t3\tGaston_Gaudio\t1\nChris_Gratton\t1\tMario_Vasquez_Rana\t1\nChris_Kolanas\t1\tJoshua_Gracin\t1\nClaudia_Pechstein\t2\tMireille_Jospin-Dandieu\t1\nClay_Aiken\t1\tSvetlana_Koroleva\t1\nColin_Powell\t95\tFrank_Hsieh\t1\nCraig_David\t1\tTom_McClintock\t1\nCraig_Wilson\t1\tKajsa_Bergqvist\t1\nCristina_Fernandez\t2\tStephen_Cooper\t1\nCurtis_Joseph\t1\tTerrell_Suggs\t2\nCynthia_Rowley\t1\tMichael_Friedman\t1\nDamon_van_Dam\t2\tJason_Sorens\t1\nDaniel_Barenboim\t1\tTyler_Grillo\t1\nDaniel_Bruehl\t1\tGus_Frerotte\t1\nDaniel_Bruehl\t1\tMax_Mosley\t1\nDaniel_Bruehl\t1\tRamon_Cardenas\t1\nDaniele_Bergamin\t1\tKenneth_Evans\t1\nDanielle_Spencer\t1\tRachel_Wheatley\t1\nDarcy_Regier\t1\tWilliam_Hurt\t1\nDave_Matthews\t1\tLinda_Dano\t1\nDave_Matthews\t1\tPaul_Burrell\t7\nDave_McNealey\t1\tGerald_Riley\t1\nDavid_Bisbal\t1\tTerri_Clark\t1\nDavid_Chase\t1\tEkaterina_Dmitriev\t1\nDavid_McCullough\t1\tEvo_Morales\t1\nDavid_McKiernan\t1\tFernando_Leon_de_Aranoa\t1\nDavid_McKiernan\t1\tJane_Leeves\t1\nDennis_Erickson\t2\tHisham_Halawi\t1\nDennis_Erickson\t2\tNoer_Muis\t1\nDerek_Lowe\t2\tHisham_Halawi\t1\nDerek_Lowe\t2\tMadonna\t1\nDerek_Lowe\t2\tMohamed_Benaissa\t1\nDiego_Colorado\t1\tJason_Sorens\t1\nDiego_Colorado\t1\tJohn_Gordnick\t1\nDiego_Diego_Lerman\t1\tFrancisco_Flores\t2\nDiego_Diego_Lerman\t1\tLesley_Coppin\t1\nDjabir_Said-Guerni\t1\tPaul_Tracy\t1\nDjabir_Said-Guerni\t1\tPedro_Solbes\t3\nDominik_Hrbaty\t1\tToshi_Izawa\t1\nDonald_Keck\t1\tKyoko_Nakayama\t1\nDonald_Keck\t1\tTom_Poston\t1\nDonna_Walker\t1\tJacqueline_Marris\t1\nDragan_Covic\t1\tTodd_Reid\t1\nDudley_Rogers\t1\tSyed_Ibrahim\t1\nDunn_Lampton\t1\tJessica_Simpson\t1\nDustin_Hoffman\t1\tNicole_Parker\t1\nEd_Wade\t1\tRoger_Staubach\t1\nEd_Wade\t1\tTerri_Clark\t1\nEddie_Lucio\t1\tPatti_Balgojevich\t1\nEddie_Sutton\t1\tJames_Wattana\t1\nEddie_Sutton\t1\tJeanne_Anne_Schroeder\t1\nEddie_Sutton\t2\tRonald_Ito\t1\nEduardo_Fischer\t1\tKimberly_Bruckner\t1\nEdward_Lohn\t1\tLily_Safra\t1\nEdward_Lohn\t1\tNino_DAngelo\t1\nEkaterina_Dmitriev\t1\tMitch_Kupchak\t1\nEladio_Larez\t1\tFrank_Pallone\t1\nEli_Broad\t1\tRavan_AG_Farhadi\t1\nElijah_Wood\t2\tStefano_Gabbana\t1\nElijah_Wood\t3\tMarcus_Garrettson\t1\nElijan_Ingram\t1\tMichelle_Hofland\t1\nElijan_Ingram\t1\tNastia_Liukin\t1\nElvis_Costello\t1\tJaime_Pressly\t1\nEmelie_Loit\t1\tThomas_Mesereau_Jr\t1\nEric_Staal\t1\tJerry_Lewis\t1\nErin_Hershey_Presley\t1\tFrank_Dunham_Jr\t1\nErin_Hershey_Presley\t1\tYukio_Hatoyama\t1\nEva_Mendes\t1\tLarry_Harris\t1\nFaye_Alibocus\t1\tFrank_Bell\t1\nFaye_Alibocus\t1\tTommy_Tubberville\t1\nFelix_Mantilla\t1\tJerry_Lewis\t1\nFernando_Leon_de_Aranoa\t1\tJohn_Scarlett\t1\nFernando_Leon_de_Aranoa\t1\tMike_Leach\t1\nFidel_Castro\t7\tHu_Maoyuan\t1\nFrancisco_Flores\t4\tHisham_Halawi\t1\nFrank_Bell\t1\tKhatol_Mohammad_Zai\t1\nFrank_Dunham_Jr\t1\tTom_McClintock\t1\nFrank_Hsieh\t1\tPaula_Prentiss\t1\nFrank_Pallone\t1\tJim_Wall\t1\nFrank_Pallone\t1\tMary_Tyler_Moore\t2\nFrank_Schmoekel\t1\tRonald_Ito\t1\nFranko_Simatovic\t2\tTyler_Grillo\t1\nFranz_Gsell\t1\tJohn_Scarlett\t1\nFranz_Gsell\t1\tSarah_Jessica_Parker\t2\nFred_Eckhard\t1\tRachel_Wheatley\t1\nGarry_Alejano\t1\tIban_Mayo\t1\nGarry_Alejano\t1\tMichael_Olowokandi\t1\nGarry_Alejano\t1\tMorgan_Freeman\t2\nGarry_Alejano\t1\tPeter_Struck\t5\nGary_Marshall\t1\tRashid_Qureshi\t1\nGerald_Fitch\t1\tRobin_Williams\t1\nGerald_Riley\t1\tMichael_Hagee\t1\nGerman_Khan\t1\tMorgan_Freeman\t2\nGrady_Little\t1\tRobert_Morvillo\t1\nHal_Sellers\t1\tJanet_Thorpe\t1\nHans_Corell\t1\tJohn_Gordnick\t1\nHeidi_Klum\t2\tPaul_Reiser\t1\nHeidi_Klum\t3\tPedro_Solbes\t1\nHermando_Harton\t1\tParis_Hilton\t2\nHolly_Robinson_Peete\t1\tMichael_Hagee\t1\nHoward_Ross\t1\tKajsa_Bergqvist\t1\nHoward_Ross\t1\tPatsy_Hardy\t1\nHugh_Carey\t1\tLawrence_Roberts\t1\nHugh_Carey\t1\tTracee_Treadwell\t1\nIban_Mayo\t2\tJuan_Valencia_Osorio\t1\nIban_Mayo\t2\tRosalie_Perkov\t1\nIbrahim_Al-Marashi\t1\tJohn_Travolta\t3\nIbrahim_Al-Marashi\t1\tJoshua_Gracin\t1\nImad_Moustapha\t2\tKyoko_Nakayama\t1\nIra_Einhorn\t1\tJohn_Ruiz\t2\nJacqueline_Marris\t1\tMatthew_Ouimet\t1\nJaime_Pressly\t1\tTiago_Splitter\t1\nJames_Brown\t1\tMary_Blige\t1\nJames_Brown\t1\tPaul_Reiser\t1\nJames_Mathis\t1\tYuri_Fedotov\t1\nJames_Wattana\t1\tPaul_Reiser\t1\nJames_Wattana\t1\tRon_Kirk\t1\nJames_Young\t1\tJeffrey_Scott_Postell\t2\nJames_Young\t1\tRonald_Harwood\t1\nJane_Leeves\t1\tTom_McClintock\t1\nJanet_Crawford\t1\tThomas_Scavone\t1\nJason_Sorens\t1\tLidija_Djukanovic\t1\nJason_Vale\t1\tMarcus_Garrettson\t1\nJason_Vale\t1\tZoran_Djindjic\t3\nJaymon_Crabb\t1\tTed_Christopher\t1\nJeff_Weaver\t1\tKyoko_Nakayama\t1\nJeff_Weaver\t1\tRosalie_Perkov\t1\nJeffrey_Scott_Postell\t1\tTara_Dawn_Christensen\t1\nJeffrey_Scott_Postell\t2\tLesley_Coppin\t1\nJennifer_Capriati\t26\tRuben_Wolkowyski\t1\nJim_Bunning\t1\tTerence_Newman\t1\nJim_Jeffords\t1\tPeter_Rasch\t1\nJim_Jeffords\t1\tTom_Sizemore\t1\nJob_Cohen\t1\tJohn_Stockton\t2\nJohn_Franco\t1\tPaul_Wolfowitz\t4\nJohn_Gordnick\t1\tLinda_Dano\t1\nJohn_Gordnick\t1\tPaul_Vathis\t1\nJohn_Gordnick\t1\tYasser_Arafat\t3\nJohn_Stockton\t4\tPatsy_Hardy\t1\nJohn_Travolta\t2\tLech_Walesa\t1\nJuan_Valencia_Osorio\t1\tTom_Daschle\t6\nJuergen_Schrempp\t1\tMitt_Romney\t1\nJulien_Boutter\t1\tSaeed_Anwar\t1\nKaisser_Bazan\t1\tLawrence_Vito\t1\nKaisser_Bazan\t1\tPierre_Lacroix\t1\nKajsa_Bergqvist\t1\tTayshaun_Prince\t1\nKeith_Snyder\t1\tTerri_Clark\t1\nKemal_Dervis\t3\tRoger_Staubach\t1\nKifah_Ajouri\t1\tLaurie_Pirtle\t1\nKifah_Ajouri\t1\tRaul_Gonzalez\t1\nKimberly_Bruckner\t1\tPete_Carroll\t1\nKirk_Douglas\t1\tNida_Blanca\t1\nLarry_Harris\t1\tMichael_Lechner\t1\nLarry_Lucchino\t1\tRudy_Tomjanovich\t1\nLatrell_Sprewell\t1\tRosalie_Perkov\t1\nLaura_Schlessinger\t1\tTony_Curtis\t1\nLaurie_Pirtle\t1\tRoberta_Combs\t1\nLawrence_Roberts\t1\tLynne_Thigpen\t1\nLawrence_Roberts\t1\tNick_Cassavetes\t1\nLech_Walesa\t2\tRick_Wagoner\t2\nLen_Jenoff\t2\tTom_Daschle\t7\nLew_Rywin\t1\tTerri_Clark\t1\nLinda_Dano\t1\tTerence_Newman\t1\nLydia_Shum\t1\tMario_Vasquez_Rana\t1\nLynne_Thigpen\t1\tMary_Blige\t1\nMalcolm_Glazer\t1\tNoer_Muis\t1\nMalcolm_Glazer\t1\tTabare_Vazquez\t1\nMarc_Bulger\t1\tPaul_Wolfowitz\t7\nMarcus_Garrettson\t1\tPham_Sy_Chien\t1\nMarcus_Garrettson\t1\tRoberto_Carlos\t3\nMaribel_Dominguez\t1\tMichael_Winterbottom\t3\nMarion_Barry\t1\tSteve_Peace\t1\nMark_Hogan\t1\tQueen_Elizabeth_II\t11\nMark_Hogan\t1\tRoger_Toussaint\t1\nMary_Blige\t1\tRaul_Gonzalez\t1\nMassoud_Barzani\t1\tPierre_Lacroix\t1\nMax_Mosley\t1\tRaul_Gonzalez\t1\nMelvin_Talbert\t1\tRudy_Tomjanovich\t1\nMichael_Hagee\t1\tSonya_Walger\t1\nMichael_Killeen\t1\tSammy_Sosa\t2\nMichael_Olowokandi\t1\tPete_Carroll\t2\nMichael_Winterbottom\t1\tPierre_Boulanger\t1\nMike_Price\t2\tTom_Miller\t1\nMilo_Maestrecampo\t1\tYuri_Fedotov\t1\nMilo_Maestrecampo\t2\tSteve_Peace\t1\nMilo_Maestrecampo\t3\tStacey_Dales-Schuman\t1\nMitt_Romney\t1\tNida_Blanca\t1\nMohamed_ElBaradei\t8\tRachel_Wheatley\t1\nMohammad_Aktar\t1\tRafeeuddin_Ahmed\t1\nMohammad_Aktar\t1\tTom_McClintock\t1\nMohammed_Abulhasan\t1\tStephane_Rousseau\t1\nMohammed_Abulhasan\t1\tVladimiro_Montesinos\t1\nNastia_Liukin\t1\tNicole_Parker\t1\nNastia_Liukin\t1\tSharon_Davis\t2\nNicolas_Latorre\t1\tPaula_Prentiss\t1\nNicolas_Latorre\t1\tVassilis_Xiros\t1\nNicolas_Latorre\t1\tWilliam_Delahunt\t1\nPete_Sampras\t10\tStan_Heath\t1\nPhil_Vassar\t2\tTabare_Vazquez\t1\nPhilip_Zalewski\t1\tStefan_Holm\t1\nRoberto_Carlos\t1\tYasser_Arafat\t5\nRoger_Cook\t1\tWilbert_Foy\t1\nRoger_Staubach\t1\tSeverino_Antinori\t1\nRon_Kirk\t1\tTroy_Hudson\t1\nSammy_Sosa\t2\tStan_Heath\t2\nSandra_Ceccarelli\t1\tStephen_Cooper\t1\nSandra_Ceccarelli\t1\tTom_Coughlin\t1\nShireen_Amir_Begum\t1\tSushma_Swaraj\t1\nSinead_OConnor\t1\tStephane_Rochon\t1\nAitor_Gonzalez\t1\t2\nAlec_Baldwin\t2\t4\nAllison_Janney\t1\t2\nAlvaro_Noboa\t1\t3\nAlvaro_Noboa\t2\t3\nAmanda_Coetzer\t1\t2\nAmer_al-Saadi\t1\t3\nAmer_al-Saadi\t1\t4\nAmer_al-Saadi\t2\t4\nAna_Guevara\t2\t7\nAna_Guevara\t3\t7\nAnneli_Jaatteenmaki\t1\t2\nAri_Fleischer\t6\t9\nAri_Fleischer\t7\t12\nArianna_Huffington\t1\t2\nArianna_Huffington\t1\t4\nArianna_Huffington\t2\t3\nArianna_Huffington\t2\t4\nArnaud_Clement\t1\t2\nArsinee_Khanjian\t1\t2\nArt_Howe\t1\t2\nArt_Howe\t1\t3\nArt_Howe\t1\t4\nArt_Howe\t2\t3\nArt_Howe\t3\t4\nBen_Affleck\t2\t3\nBen_Affleck\t2\t4\nBen_Affleck\t2\t7\nBen_Affleck\t3\t6\nBen_Affleck\t5\t6\nBetsy_Smith\t1\t2\nBill_Callahan\t1\t3\nBlythe_Hartley\t1\t2\nBob_Huggins\t1\t3\nBob_Huggins\t3\t4\nBobby_Goldwater\t1\t2\nBono\t1\t2\nBono\t1\t3\nBono\t2\t3\nBrad_Garrett\t1\t3\nBrad_Garrett\t2\t3\nBrad_Garrett\t2\t4\nBrian_Mulroney\t1\t2\nBud_Selig\t1\t2\nBud_Selig\t2\t3\nBud_Selig\t2\t4\nCarla_Del_Ponte\t1\t2\nCarla_Del_Ponte\t2\t4\nCarla_Del_Ponte\t2\t5\nCarla_Del_Ponte\t3\t5\nCarlos_Ghosn\t1\t2\nCarlos_Manuel_Pruneda\t1\t2\nCarlos_Manuel_Pruneda\t1\t3\nCarlos_Menem\t2\t21\nCarlos_Menem\t5\t18\nCarlos_Menem\t8\t15\nCarlos_Menem\t11\t12\nCarlos_Menem\t14\t21\nCarlos_Menem\t16\t18\nCarmen_Electra\t3\t4\nCarmen_Electra\t4\t6\nCharlotte_Rampling\t1\t2\nChick_Hearn\t1\t2\nChristine_Todd_Whitman\t2\t3\nChristine_Todd_Whitman\t5\t6\nChristopher_Reeve\t1\t3\nChuck_Amato\t1\t2\nCindy_Crawford\t2\t3\nCindy_Margolis\t1\t2\nClaire_Danes\t1\t3\nClaire_Danes\t2\t3\nConan_OBrien\t1\t2\nConan_OBrien\t2\t3\nConan_OBrien\t2\t4\nConchita_Martinez\t1\t2\nConchita_Martinez\t1\t3\nDan_Morales\t1\t2\nDan_Morales\t1\t3\nDavid_Hyde_Pierce\t1\t2\nDavid_Hyde_Pierce\t1\t3\nDavid_Hyde_Pierce\t2\t3\nDavid_Hyde_Pierce\t2\t4\nDavid_Myers\t1\t2\nDavid_Nalbandian\t1\t3\nDavid_Nalbandian\t2\t9\nDavid_Nalbandian\t3\t4\nDavid_Nalbandian\t4\t13\nDavid_Nalbandian\t11\t12\nDavid_Stern\t1\t2\nDavid_Stern\t2\t3\nDerek_Jeter\t2\t3\nDerek_Jeter\t2\t4\nDonatella_Versace\t1\t3\nDonatella_Versace\t2\t3\nDonna_Shalala\t1\t2\nEdmund_Hillary\t1\t2\nEdmund_Hillary\t1\t3\nEdmund_Hillary\t2\t3\nElisabeth_Schumacher\t1\t2\nElizabeth_Smart\t3\t5\nErin_Runnion\t1\t3\nErin_Runnion\t2\t3\nErin_Runnion\t2\t4\nErin_Runnion\t3\t4\nFernando_Henrique_Cardoso\t1\t2\nFernando_Henrique_Cardoso\t1\t3\nFernando_Henrique_Cardoso\t1\t4\nFernando_Henrique_Cardoso\t2\t7\nFernando_Henrique_Cardoso\t5\t7\nFernando_Henrique_Cardoso\t6\t7\nFrancis_Mer\t1\t2\nFranz_Fischler\t1\t2\nGary_Locke\t1\t2\nGerry_Adams\t1\t3\nGerry_Adams\t1\t7\nGerry_Adams\t2\t6\nGerry_Adams\t3\t5\nGerry_Adams\t4\t6\nGerry_Adams\t5\t6\nGianna_Angelopoulos-Daskalaki\t1\t2\nGil_de_Ferran\t1\t5\nGil_de_Ferran\t2\t4\nGil_de_Ferran\t3\t5\nGoh_Kun\t1\t2\nGrady_Irvin_Jr\t1\t2\nGunter_Pleuger\t3\t5\nGunter_Pleuger\t3\t6\nHarry_Belafonte\t1\t2\nHarry_Schmidt\t1\t3\nHarry_Schmidt\t1\t4\nHarry_Schmidt\t2\t3\nHarry_Schmidt\t3\t4\nHelen_Clark\t2\t4\nHermann_Maier\t1\t2\nIan_Thorpe\t1\t7\nIan_Thorpe\t1\t10\nIan_Thorpe\t3\t9\nIan_Thorpe\t5\t7\nIan_Thorpe\t6\t10\nIsabelle_Huppert\t1\t2\nJames_Butts\t1\t2\nJan-Michael_Gambill\t1\t2\nJan-Michael_Gambill\t2\t3\nJean-Francois_Pontal\t1\t3\nJean-Marc_de_La_Sabliere\t1\t2\nJean-Sebastien_Giguere\t1\t2\nJeb_Bush\t1\t6\nJeb_Bush\t2\t6\nJeb_Bush\t5\t7\nJeffrey_Jones\t1\t2\nJim_OBrien\t1\t2\nJim_OBrien\t1\t3\nJoe_Gatti\t1\t2\nJohn_Cusack\t1\t2\nJohn_Edwards\t1\t3\nJohn_Edwards\t1\t7\nJohn_Edwards\t2\t5\nJohn_Edwards\t3\t7\nJohn_Edwards\t4\t6\nJohn_Edwards\t4\t8\nJohn_Edwards\t6\t7\nJohn_Spencer\t1\t2\nJohn_Taylor\t1\t2\nJohn_Walsh\t1\t2\nJolanta_Kwasniewski\t1\t2\nJose_Mourinho\t1\t2\nJuergen_Peters\t1\t2\nKalpana_Chawla\t1\t4\nKalpana_Chawla\t2\t3\nKalpana_Chawla\t2\t5\nKalpana_Chawla\t3\t4\nKelli_White\t1\t2\nKim_Jin-sun\t1\t2\nLana_Clarkson\t1\t2\nLaura_Hernandez\t1\t2\nLaura_Linney\t1\t2\nLaura_Linney\t1\t3\nLaura_Linney\t2\t4\nLaura_Linney\t3\t4\nLenny_Wilkens\t1\t2\nLenny_Wilkens\t1\t3\nLenny_Wilkens\t2\t3\nLloyd_Ward\t1\t2\nMahathir_Mohamad\t1\t7\nMahathir_Mohamad\t1\t12\nMahathir_Mohamad\t6\t10\nMark_Cuban\t1\t2\nMark_Heller\t1\t2\nMark_Schweiker\t1\t2\nMarty_Mornhinweg\t1\t2\nMarty_Mornhinweg\t1\t3\nMarty_Mornhinweg\t2\t3\nMichael_Phelps\t1\t2\nMichael_Phelps\t2\t4\nMick_Jagger\t2\t4\nMiguel_Estrada\t1\t2\nMike_Myers\t1\t6\nMike_Myers\t2\t3\nMike_Myers\t2\t4\nMike_Myers\t2\t5\nNadine_Vinzens\t1\t2\nNathan_Lane\t1\t2\nNicolas_Cage\t1\t2\nNicolas_Cage\t2\t4\nNicolas_Cage\t3\t4\nNicole_Kidman\t3\t11\nNicole_Kidman\t8\t17\nNicole_Kidman\t11\t13\nNicole_Kidman\t13\t14\nNicole_Kidman\t15\t19\nOmar_Sharif\t1\t2\nOmar_Sharif\t1\t3\nOmar_Sharif\t1\t4\nOmar_Sharif\t2\t3\nParris_Glendening\t1\t2\nPatrick_Leahy\t1\t2\nPatrick_McEnroe\t1\t2\nPatrick_Stewart\t1\t2\nPaul_Gascoigne\t1\t3\nPeter_Hillary\t1\t2\nPhan_Van_Khai\t1\t2\nPhan_Van_Khai\t1\t3\nPhan_Van_Khai\t2\t3\nPrince_Claus\t1\t4\nPrince_Claus\t2\t3\nPrince_Claus\t2\t4\nRaghad_Saddam_Hussein\t1\t2\nRay_Allen\t1\t2\nRay_Allen\t2\t3\nRichard_Crenna\t1\t2\nRichard_Gere\t1\t10\nRichard_Gere\t6\t9\nRichard_Myers\t1\t2\nRichard_Myers\t1\t4\nRichard_Myers\t4\t8\nRichard_Myers\t15\t16\nRick_Romley\t1\t3\nRob_Lowe\t1\t3\nRob_Lowe\t1\t4\nRob_Lowe\t2\t3\nRob_Lowe\t3\t4\nRobby_Ginepri\t1\t2\nRobert_Witt\t1\t2\nRod_Blagojevich\t1\t2\nRolandas_Paksas\t1\t2\nRussell_Coutts\t1\t2\nRuth_Dreifuss\t1\t2\nSally_Kirkland\t1\t4\nSean_Patrick_OMalley\t1\t3\nSebastian_Saja\t1\t2\nSebastian_Saja\t1\t3\nSila_Calderon\t1\t2\nSila_Calderon\t1\t3\nSila_Calderon\t1\t4\nSila_Calderon\t2\t3\nStanley_Tong\t1\t2\nSteve_Park\t1\t2\nSusie_Castillo\t1\t2\nSylvester_Stallone\t1\t5\nSylvester_Stallone\t2\t4\nSylvester_Stallone\t3\t8\nSylvester_Stallone\t4\t5\nTakashi_Sorimachi\t1\t2\nTang_Jiaxuan\t2\t6\nTang_Jiaxuan\t2\t11\nTang_Jiaxuan\t4\t9\nTang_Jiaxuan\t5\t9\nTang_Jiaxuan\t7\t10\nTerje_Roed-Larsen\t1\t2\nThomas_Birmingham\t1\t2\nTiger_Woods\t2\t6\nTiger_Woods\t3\t21\nTiger_Woods\t5\t11\nTiger_Woods\t5\t12\nTiger_Woods\t6\t18\nTiger_Woods\t6\t21\nTiger_Woods\t9\t12\nTiger_Woods\t9\t23\nTiger_Woods\t16\t18\nTim_Curry\t1\t2\nTom_Brady\t1\t2\nToshihiko_Fukui\t1\t2\nToshihiko_Fukui\t1\t3\nUma_Thurman\t1\t3\nUma_Thurman\t2\t3\nVaclav_Klaus\t1\t2\nVanessa_Incontrada\t1\t2\nVanessa_Incontrada\t1\t3\nVanessa_Incontrada\t1\t4\nVanessa_Incontrada\t2\t3\nVanessa_Incontrada\t2\t4\nVanessa_Incontrada\t3\t4\nVin_Diesel\t1\t2\nVladimir_Spidla\t1\t2\nVladimir_Spidla\t1\t3\nVladimir_Spidla\t2\t3\nWin_Aung\t1\t3\nWin_Aung\t1\t4\nZhang_Ziyi\t1\t3\nZhang_Ziyi\t2\t3\nAdrian_Annus\t1\tJorge_Marquez-Ruarte\t1\nAdrian_Annus\t1\tPatrick_Bourrat\t1\nAdrian_Murrell\t1\tJose_Cevallos\t1\nAdrian_Murrell\t1\tPaul_Brandt\t1\nAhmed_Ibrahim_Bilal\t1\tBeatrice_Dalle\t1\nAhmed_Ibrahim_Bilal\t1\tLee_Chang-dong\t1\nAileen_Riggin_Soule\t1\tNorio_Ohga\t1\nAitor_Gonzalez\t2\tHorace_Donovan_Reid\t1\nAjit_Agarkar\t1\tJesse_James\t1\nAkbar_Al_Baker\t1\tAndrei_Konchalovsky\t1\nAkbar_Al_Baker\t1\tBobby_Goldwater\t1\nAlain_Cervantes\t1\tBob_Huggins\t3\nAlain_Cervantes\t1\tPierre_Png\t1\nAlanna_Ubach\t1\tPaul_Gascoigne\t1\nAlec_Baldwin\t4\tGoh_Kun\t2\nAlex_Holmes\t1\tBeatrice_Dalle\t1\nAlfred_Sant\t1\tRandall_Tobias\t1\nAlfredo_Moreno\t1\tDyab_Abou_Jahjah\t1\nAlfredo_Moreno\t1\tSuzanne_Torrance\t1\nAlfredo_Pena\t1\tEmmanuel_Milingo\t1\nAlvaro_Noboa\t1\tPhan_Van_Khai\t1\nAlvaro_Noboa\t2\tTimothy_Rigas\t1\nAmanda_Coetzer\t1\tBridgette_Wilson-Sampras\t2\nAmanda_Coetzer\t1\tEddie_Jordan\t1\nAmer_al-Saadi\t4\tMiguel_Cotto\t1\nAmy_Brenneman\t1\tRussell_Coutts\t2\nAmy_Brenneman\t1\tTerje_Roed-Larsen\t1\nAndrew_Firestone\t1\tHarry_Schmidt\t4\nAndrew_Firestone\t1\tIan_Campbell\t1\nAndrew_Firestone\t1\tJose_Acasuso\t1\nAndrew_Firestone\t1\tOmar_Sharif\t4\nAndy_Graves\t1\tGil_de_Ferran\t1\nAngela_Alvarado_Rosa\t1\tGerald_Calabrese\t1\nAngela_Alvarado_Rosa\t1\tJeffrey_Jones\t1\nAnneli_Jaatteenmaki\t2\tEric_Robert_Rudolph\t2\nAnneli_Jaatteenmaki\t2\tGerry_Adams\t6\nAnneli_Jaatteenmaki\t2\tJorge_Marquez-Ruarte\t1\nAnthony_Corso\t1\tJohnny_Benson\t1\nAnthony_Corso\t1\tRay_Allen\t3\nAnthony_Pico\t1\tStephanie_Cohen_Aloro\t1\nAri_Fleischer\t1\tRazali_Ismail\t1\nAri_Fleischer\t9\tJean-Marc_de_La_Sabliere\t2\nArianna_Huffington\t4\tPhilippe_Gagnon\t1\nArnaud_Clement\t1\tJeffrey_Jones\t2\nArnaud_Clement\t1\tKing_Gyanendra\t1\nArnaud_Clement\t2\tGrady_Irvin_Jr\t2\nArnold_Scott\t1\tRandy_Dryer\t1\nArt_Howe\t2\tLuciano_Bovicelli\t1\nArt_Howe\t3\tTeresa_Worbis\t1\nArtieas_Shanks\t1\tDerek_King\t1\nAstrid_Betancourt\t1\tFrederick_Madden\t1\nBarbara_De_Brun\t1\tCosmo_Iacavazzi\t1\nBarry_Collier\t1\tNarendra_Modi\t1\nBen_Affleck\t3\tPatricia_Hearst\t1\nBen_Affleck\t4\tDaniel_Scioli\t1\nBen_Affleck\t7\tMarcio_de_Souza\t1\nBen_Broussard\t1\tRudi_Voeller\t1\nBetsy_Smith\t2\tSteven_Kinlock\t1\nBetty_Williams\t1\tMary_Catherine_Correll\t1\nBianca_Jagger\t1\tDario_Camuffo\t1\nBianca_Jagger\t1\tFabricio_Oberto\t1\nBill_Callahan\t1\tGina_Gershon\t1\nBill_Kollar\t1\tGina_Gershon\t1\nBill_Kollar\t1\tJose_Miguel_Aleman\t1\nBill_Kollar\t1\tMae_Jemison\t1\nBill_Kollar\t1\tMohammed_Ashraf_Hafiz\t1\nBill_Kollar\t1\tPatty_Sheehan\t1\nBill_Parsons\t1\tDonna_Barrera\t1\nBill_Stein\t1\tVanessa_Incontrada\t4\nBlythe_Hartley\t1\tJackie_Dennis\t1\nBlythe_Hartley\t2\tGil_de_Ferran\t2\nBob_Curtis\t1\tHelen_Clark\t1\nBob_Huggins\t3\tSylvester_Stallone\t2\nBobby_Goldwater\t1\tJohn_Moxley\t1\nBobby_Goldwater\t1\tUlrich_Kueperkoch\t1\nBono\t3\tIan_Huntley\t1\nBrad_Garrett\t1\tHoda_Asfor\t1\nBrad_Garrett\t4\tWang_Nan\t1\nBrandon_Hammond\t1\tThomas_Kelly\t1\nBrandon_Robinson\t1\tGiovanny_Cordoba\t1\nBrandon_Robinson\t1\tMichael_Linscott\t1\nBrandon_Robinson\t1\tShi_Guangsheng\t1\nBrendan_Stai\t1\tDan_Guerrero\t1\nBrett_Boone\t1\tJean-Marc_de_La_Sabliere\t1\nBrett_Boone\t1\tTeresa_Worbis\t1\nBrian_Billick\t1\tIan_Huntley\t1\nBrian_Billick\t1\tJohn_Wayne\t1\nBrian_Billick\t1\tStephanie_Moore\t1\nBrian_Olson\t1\tRoberto_Tovar\t1\nBud_Selig\t1\tFranz_Fischler\t1\nBud_Selig\t3\tJohn_Duprey\t1\nCarla_Moreno\t1\tSuzanne_Torrance\t1\nCarla_Moreno\t1\tTang_Jiaxuan\t3\nCarlos_Beltran\t1\tUlrich_Kueperkoch\t1\nCarlos_Ghosn\t1\tJim_Paxson\t1\nCarlos_Ghosn\t2\tRay_Allen\t3\nCarlton_Dotson\t1\tJim_Paxson\t1\nCarlton_Dotson\t1\tPatrick_Bourrat\t1\nCarlton_Dotson\t1\tPorter_Goss\t1\nCarlton_Dotson\t1\tVyacheslav_Fetisov\t1\nCass_Ballenger\t1\tNorio_Ohga\t1\nCecile_de_France\t1\tDyab_Abou_Jahjah\t1\nCecile_de_France\t1\tTerrence_Kiel\t1\nCharles_Bell\t1\tTatjana_Gsell\t1\nCharlotte_Rampling\t1\tLana_Clarkson\t2\nChick_Hearn\t1\tMohammed_Salmane\t1\nChristopher_Reeve\t4\tPauline_Landers\t1\nChristopher_Reeve\t4\tScott_OGrady\t1\nCindy_Margolis\t1\tMark_Cuban\t2\nClaire_Danes\t2\tNadine_Vinzens\t1\nClaudio_Lopez\t1\tGabrielle_Rose\t1\nCollis_Temple_III\t1\tEva_Amurri\t1\nCollis_Temple_III\t1\tRob_Niedermayer\t1\nCollis_Temple_III\t1\tSantiago_Botero\t1\nCollis_Temple_III\t1\tSimon_Chalk\t1\nConan_OBrien\t1\tLiliana_Cavani\t1\nCorinna_Harfouch\t1\tIvo_Dubs\t1\nCorinna_Harfouch\t1\tTim_Curry\t1\nCristina_Kirchner\t1\tStefanie_De_Roux\t1\nDan_Boyle\t1\tPaul_Clark\t1\nDan_Boyle\t1\tThabo_Mbeki\t3\nDaniel_Chin\t1\tIan_Huntley\t1\nDaniel_Chin\t1\tJim_Letten\t1\nDaniel_Chin\t1\tJulia_Glass\t1\nDaniel_Scioli\t1\tLena_Katina\t1\nDaniel_Scioli\t1\tLindsay_Lohan\t1\nDario_Camuffo\t1\tEli_Stutsman\t1\nDavid_Brinkley\t1\tJeff_Bridges\t1\nDavid_Brinkley\t1\tStephen_Arigbabu\t1\nDavid_Montoya\t1\tMary_Elizabeth_Mastrantonio\t1\nDavid_Siegel\t1\tFrancis_Mer\t1\nDennis_Johnson\t1\tSatnarine_Sharma\t1\nDenys_Arcand\t1\tNadine_Vinzens\t2\nDerek_Jeter\t1\tTian_Zhuang_Zhuang\t1\nDerek_Jeter\t3\tJolanta_Kwasniewski\t2\nDerek_King\t1\tYasein_Taher\t1\nDerrick_Battie\t1\tIan_Huntley\t1\nDiego_Armando_Maradona\t1\tRobert_Gordon_Card\t1\nDon_King\t1\tThomas_Kelly\t1\nDon_King\t1\tZurab_Tsereteli\t1\nDonna_Barrera\t1\tFrancis_Mer\t2\nDonna_Shalala\t2\tSereyvuth_Kem\t1\nDuncan_Fletcher\t1\tJohn_Cusack\t2\nDuncan_Fletcher\t1\tMike_Alden\t1\nDustin_Brown\t1\tJose_Cevallos\t1\nDyab_Abou_Jahjah\t1\tJohn_Cornyn\t1\nEd_Mekertichian\t1\tPaul_Clark\t1\nEdmund_Hillary\t2\tMiguel_Cotto\t1\nElena_Likhovtseva\t1\tMarty_Mornhinweg\t2\nEli_Stutsman\t1\tKalpana_Chawla\t4\nEli_Stutsman\t1\tMarcio_de_Souza\t1\nEli_Stutsman\t1\tMichael_Phelps\t1\nElizabeth_Regan\t1\tEugene_Teslovic\t1\nEmmanuel_Milingo\t1\tEnrica_Fico\t1\nEnola_Rice\t1\tLana_Clarkson\t2\nErin_Runnion\t3\tRob_Lowe\t2\nEugene_Teslovic\t1\tGoh_Kun\t1\nEugene_Teslovic\t1\tJean-Marc_de_La_Sabliere\t2\nEva_Amurri\t1\tTanya_Holyk\t1\nFabricio_Oberto\t1\tRudi_Voeller\t1\nFelix_Sanchez\t1\tIan_Moran\t1\nFernando_Henrique_Cardoso\t1\tMichael_Phelps\t1\nFernando_Henrique_Cardoso\t8\tSherry_Fisher\t1\nFrancis_Mer\t2\tPatrick_Bourrat\t1\nFranz_Fischler\t2\tRobert_Lange\t1\nFrederick_Madden\t1\tGary_Condit\t1\nGary_Bauer\t1\tGreg_Hodge\t1\nGary_Condit\t1\tNathan_Lane\t2\nGary_Locke\t1\tMarcio_de_Souza\t1\nGen_Meredith\t1\tMatthew_Vaughan\t1\nGerry_Adams\t8\tJamir_Miller\t1\nGilles_Panizzi\t1\tJim_Piper\t1\nGina_Gershon\t1\tPatricia_Garone\t1\nGina_Gershon\t1\tZhang_Ziyi\t2\nGiovanny_Cordoba\t1\tJackie_Sherrill\t1\nGiovanny_Cordoba\t1\tKeith_Olbermann\t1\nGrady_Irvin_Jr\t2\tOracene_Williams\t1\nGraeme_Smith\t1\tJohn_Salazar\t1\nGraham_Bentley\t1\tJason_Clermont\t1\nGuillaume_Depardieu\t1\tManuel_Llorente\t1\nGunter_Pleuger\t1\tNicole_Kidman\t2\nGunter_Pleuger\t2\tRobby_Ginepri\t1\nGunter_Pleuger\t3\tVaclav_Klaus\t1\nHanns_Schumacher\t1\tMartin_Gecht\t1\nHenri_Proglio\t1\tIbrahim_Haddad\t1\nHenri_Proglio\t1\tJeffery_Hendren\t1\nHermann_Maier\t1\tPhan_Van_Khai\t1\nHermann_Maier\t2\tStephen_Arigbabu\t1\nHideki_Sato\t1\tPeter_Mugyeni\t1\nHideki_Sato\t1\tTroy_Aikman\t1\nHoda_Asfor\t1\tJuergen_Peters\t1\nHoda_Asfor\t1\tLindsay_Lohan\t1\nHorace_Donovan_Reid\t1\tRob_Lowe\t1\nHunter_Kemper\t1\tMarsha_Thomason\t1\nIan_Campbell\t1\tMike_Alden\t1\nIan_Huntley\t1\tJalen_Rose\t1\nIan_Huntley\t1\tSebastian_Saja\t2\nIan_Moran\t1\tStephanie_Cohen_Aloro\t1\nIan_Thorpe\t5\tMickey_Gilley\t1\nIgnacio_Antonio_Velasco\t1\tRich_Brooks\t1\nIran_Brown\t1\tMargaret_Caruso\t1\nIsabelle_Huppert\t1\tMarcio_de_Souza\t1\nIsabelle_Huppert\t2\tPhan_Van_Khai\t3\nIvan_Shvedoff\t1\tJosh_Childress\t1\nIvan_Shvedoff\t1\tMiguel_Estrada\t2\nIvan_Shvedoff\t1\tVojislav_Seselj\t1\nIzzat_Ibrahim\t1\tJerry_Rice\t1\nJacques_Villeneuve\t1\tWim_Duisenberg\t1\nJalen_Rose\t1\tSuzanne_Torrance\t1\nJames_Butts\t1\tNicole_Kidman\t2\nJames_Butts\t2\tJerry_Colangelo\t1\nJames_Butts\t2\tSherry_Fisher\t1\nJames_May\t1\tTrevor_McDonald\t1\nJames_May\t1\tVaclav_Klaus\t2\nJamie_Cooke\t1\tKalpana_Chawla\t5\nJamie_Cooke\t1\tMickey_Rooney\t1\nJamir_Miller\t1\tLaura_Hernandez\t1\nJana_Pittman\t1\tLiv_Tyler\t1\nJason_Clermont\t1\tJose_Carlo_Fernandez\t1\nJason_Clermont\t1\tPatty_Duke\t1\nJeff_Bridges\t1\tLandon_Donovan\t1\nJeff_Bridges\t1\tPatty_Duke\t1\nJeffery_Hendren\t1\tJeremy_Wotherspoon\t1\nJennifer_McCoy\t1\tManuel_Llorente\t1\nJennifer_McCoy\t1\tWilliam_Cocksedge\t1\nJerry_Colangelo\t1\tVin_Diesel\t2\nJerry_Rice\t1\tJoe_Gatti\t2\nJessica_Brungo\t1\tLandon_Donovan\t1\nJim_OBrien\t1\tNadine_Vinzens\t1\nJim_Paxson\t1\tRobert_Gordon_Card\t1\nJoe_Gatti\t2\tMike_Samp\t1\nJoel_Todd\t1\tJohn_Fox\t1\nJoel_Todd\t1\tMomir_Nikolic\t1\nJohn_Cornyn\t1\tJose_Mourinho\t2\nJohn_Cornyn\t1\tRobert_Weitzel\t1\nJohn_Cornyn\t1\tToshihiko_Fukui\t2\nJohn_Dallager\t1\tJose_Canseco_Sr\t1\nJohn_Spencer\t2\tStephanie_Moore\t1\nJohn_Walsh\t1\tKalpana_Chawla\t1\nJohn_Wright\t1\tSandra_Milo\t1\nJohn_Wright\t1\tTrevor_McDonald\t1\nJohnny_Benson\t1\tLana_Clarkson\t2\nJohnny_Benson\t1\tTeresa_Worbis\t1\nJolanta_Kwasniewski\t2\tMartin_Howard\t1\nJose_Canseco_Sr\t1\tJulia_Glass\t1\nJose_Mourinho\t1\tJoseph_LePore\t1\nJose_Mourinho\t2\tLeRoy_Millette_Jr\t1\nJose_Vicente_Rangel\t1\tLeuris_Pupo\t1\nJose_Vicente_Rangel\t1\tScott_OGrady\t1\nJoy_Lee_Sadler\t1\tLaurie_Chan\t1\nJoy_Lee_Sadler\t1\tNorio_Ohga\t1\nJoy_Lee_Sadler\t1\tStephanie_Moore\t1\nKaren_Pereiras\t1\tMichael_Phelps\t2\nKeith_Brown\t1\tNicole_Kidman\t17\nKeith_Brown\t1\tWilliam_Harrison\t1\nKeith_Van_Horn\t1\tSherry_Fisher\t1\nKelli_White\t1\tRudi_Voeller\t1\nKing_Gyanendra\t1\tOtto_Reich\t1\nLana_Clarkson\t1\tMike_Samp\t1\nLandon_Donovan\t1\tRobby_Ginepri\t1\nLarry_Tanenbaum\t1\tMike_Samp\t1\nLaura_Ziskin\t1\tReyyan_Uzuner\t1\nLaura_Ziskin\t1\tRobert_Gordon_Card\t1\nLeRoy_Millette_Jr\t1\tLeuris_Pupo\t1\nLee_Chang-dong\t1\tPhil_Bredesen\t1\nLiliana_Cavani\t1\tRichard_Pennington\t1\nLindsay_Lohan\t1\tMireya_Elisa_Moscoso_Rodriguez\t1\nLloyd_Ward\t2\tTina_Andrews\t1\nMark_Heller\t1\tNicolas_Kiefer\t1\nMark_Heller\t1\tParris_Glendening\t1\nMark_Heller\t1\tPeter_Hillary\t2\nMartin_Gecht\t1\tPeter_Hillary\t1\nMary_Elizabeth_Mastrantonio\t1\tVaclav_Klaus\t1\nMichael_Arif\t1\tSean_Patrick_OMalley\t3\nMichael_Linscott\t1\tTom_Brady\t2\nMick_Jagger\t3\tOracene_Williams\t1\nMo_Elleithee\t1\tTanya_Holyk\t1\nMohammed_Ashraf_Hafiz\t1\tRod_Bryden\t1\nMukhtar_Alytnbayev\t1\tOracene_Williams\t1\nPatricia_Garone\t1\tSean_Patrick_OMalley\t2\nPatricia_Hearst\t1\tScott_Dickson\t1\nPatty_Duke\t1\tSimon_Chalk\t1\nPaul_Bettany\t1\tUlrich_Kueperkoch\t1\nPaul_Gascoigne\t3\tTian_Liang\t1\nPaul_Greengrass\t1\tTim_Pawlenty\t1\nPerry_Compton\t1\tWilliam_Shatner\t1\nPeter_Camejo\t1\tRuth_Christofferson\t1\nPorter_Goss\t1\tTara_Kirk\t1\nRand_Miller\t1\tRobert_Nillson\t1\nRich_Brooks\t1\tSharess_Harrell\t1\nRichard_Pennington\t1\tRobby_Ginepri\t2\nRobert_Gordon_Card\t1\tWilliam_Shatner\t1\nRobert_Kipkoech_Cheruiyot\t1\tSally_Kirkland\t3\nRobert_Kipkoech_Cheruiyot\t1\tSteve_Park\t1\nRussell_Coutts\t1\tTian_Liang\t1\nSandra_Milo\t1\tSatnarine_Sharma\t1\nSteve_Nesbitt\t1\tWin_Aung\t4\nSylvester_Stallone\t7\tTJ_Ford\t1\nSylvie_Guillem\t1\tVadim_Devyatovskiy\t1\nTara_Kirk\t1\tWin_Aung\t1\nAaron_Peirsol\t1\t4\nAaron_Peirsol\t3\t4\nAdrian_Nastase\t1\t2\nAhmed_Chalabi\t1\t3\nAhmed_Chalabi\t1\t5\nAlbrecht_Mentz\t1\t2\nAlejandro_Toledo\t20\t36\nAlejandro_Toledo\t21\t24\nAlejandro_Toledo\t21\t30\nAlejandro_Toledo\t23\t27\nAlejandro_Toledo\t26\t29\nAlexander_Losyukov\t1\t3\nAlexander_Losyukov\t2\t3\nAlexander_Losyukov\t2\t4\nAlimzhan_Tokhtakhounov\t1\t2\nAmelie_Mauresmo\t7\t14\nAmelie_Mauresmo\t11\t17\nAmelie_Mauresmo\t14\t17\nAngelo_Reyes\t1\t2\nAngelo_Reyes\t1\t3\nBegum_Khaleda_Zia\t1\t2\nBen_Curtis\t1\t2\nBijan_Namdar_Zangeneh\t1\t2\nBill_Paxton\t1\t2\nBill_Paxton\t1\t3\nBill_Paxton\t2\t4\nBill_Paxton\t3\t4\nBilly_Crystal\t1\t2\nBilly_Crystal\t1\t3\nBilly_Crystal\t1\t5\nBilly_Crystal\t3\t5\nBilly_Graham\t1\t2\nBob_Colvin\t1\t2\nBrian_Cowen\t1\t2\nButch_Davis\t1\t2\nByron_Scott\t1\t2\nCarol_Burnett\t1\t2\nCharles_Mathews\t1\t2\nChristine_Ebersole\t1\t2\nClaudia_Schiffer\t1\t2\nCondoleezza_Rice\t1\t4\nCondoleezza_Rice\t2\t10\nCondoleezza_Rice\t4\t5\nCondoleezza_Rice\t8\t9\nCondoleezza_Rice\t9\t10\nCostas_Simitis\t1\t4\nCostas_Simitis\t1\t5\nCostas_Simitis\t3\t5\nCostas_Simitis\t4\t6\nCristina_Saralegui\t1\t2\nCruz_Bustamante\t1\t4\nCruz_Bustamante\t3\t5\nDavid_Heymann\t3\t5\nDiana_Krall\t1\t6\nDiana_Krall\t3\t4\nDiana_Munz\t1\t3\nDiana_Munz\t2\t3\nDominique_de_Villepin\t2\t13\nDominique_de_Villepin\t3\t8\nDominique_de_Villepin\t3\t10\nDominique_de_Villepin\t7\t11\nDominique_de_Villepin\t10\t14\nDominique_de_Villepin\t11\t12\nDon_Siegelman\t1\t3\nDon_Siegelman\t2\t4\nDonald_Pettit\t1\t2\nDonald_Pettit\t1\t3\nDonald_Pettit\t2\t3\nDoug_Collins\t1\t2\nEdward_James_Olmos\t1\t2\nElin_Nordegren\t1\t2\nElizabeth_Taylor\t1\t2\nEllen_DeGeneres\t1\t2\nElton_John\t1\t4\nElton_John\t2\t3\nElton_John\t3\t6\nElton_John\t5\t6\nElton_John\t5\t7\nEmma_Watson\t2\t3\nEmma_Watson\t3\t4\nEmma_Watson\t3\t5\nFabrice_Santoro\t1\t3\nFabrice_Santoro\t2\t3\nFlavia_Delaroli\t1\t2\nGeorge_Lopez\t1\t4\nGeorge_Lopez\t2\t4\nGeorge_Lopez\t2\t5\nGeorge_Lopez\t4\t5\nGerard_Depardieu\t1\t2\nGerhard_Schroeder\t5\t43\nGerhard_Schroeder\t17\t25\nGerhard_Schroeder\t27\t32\nGerhard_Schroeder\t45\t67\nGerhard_Schroeder\t66\t100\nGilberto_Rodriguez_Orejuela\t1\t3\nGilberto_Rodriguez_Orejuela\t2\t3\nGilberto_Rodriguez_Orejuela\t3\t4\nGiuseppe_Gibilisco\t1\t3\nGiuseppe_Gibilisco\t1\t4\nGiuseppe_Gibilisco\t3\t4\nGuillermo_Canas\t1\t2\nGuillermo_Canas\t1\t3\nGuillermo_Canas\t2\t4\nGuillermo_Canas\t3\t4\nHans_Blix\t7\t8\nHans_Blix\t7\t18\nHans_Blix\t7\t38\nHans_Blix\t8\t24\nHans_Blix\t9\t12\nHans_Blix\t26\t36\nHans_Blix\t27\t37\nHans_Blix\t31\t37\nHeath_Ledger\t1\t2\nHeath_Ledger\t1\t4\nHeath_Ledger\t2\t3\nHeath_Ledger\t2\t4\nHerta_Daeubler-Gmelin\t1\t2\nHilary_Duff\t1\t3\nHilary_Duff\t2\t3\nHosni_Mubarak\t6\t7\nHun_Sen\t1\t4\nHun_Sen\t2\t4\nIain_Duncan_Smith\t1\t3\nIain_Duncan_Smith\t2\t3\nIain_Duncan_Smith\t2\t4\nIain_Duncan_Smith\t3\t4\nInocencio_Arias\t1\t2\nJK_Rowling\t1\t2\nJK_Rowling\t2\t3\nJK_Rowling\t2\t4\nJK_Rowling\t3\t5\nJackie_Chan\t1\t3\nJackie_Chan\t5\t8\nJane_Kaczmarek\t1\t2\nJanet_Napolitano\t1\t2\nJanet_Napolitano\t1\t4\nJay_Leno\t1\t3\nJay_Leno\t2\t3\nJean-David_Levitte\t1\t2\nJean-David_Levitte\t1\t4\nJean-David_Levitte\t2\t5\nJean-David_Levitte\t3\t4\nJean-David_Levitte\t4\t9\nJeff_Van_Gundy\t1\t2\nJeff_Van_Gundy\t1\t3\nJeff_Van_Gundy\t2\t3\nJim_Furyk\t1\t6\nJim_Furyk\t3\t6\nJohn_Garamendi\t1\t2\nJohn_Rigas\t1\t2\nJohn_Warner\t1\t2\nJohn_Warner\t1\t3\nJohn_Warner\t2\t4\nJohn_Warner\t3\t4\nJulia_Tymoshenko\t1\t2\nJulia_Tymoshenko\t1\t3\nJulia_Tymoshenko\t2\t3\nKeith_Bogans\t1\t3\nKeith_Bogans\t2\t3\nKen_Macha\t1\t3\nKen_Macha\t2\t3\nKenneth_Bowersox\t1\t2\nKenneth_Bowersox\t1\t3\nKenneth_Bowersox\t2\t3\nKristanna_Loken\t1\t2\nKristanna_Loken\t3\t4\nKristanna_Loken\t4\t5\nLK_Advani\t1\t2\nLK_Advani\t1\t3\nLauren_Killian\t1\t2\nLennox_Lewis\t1\t2\nLennox_Lewis\t1\t3\nLili_Taylor\t1\t2\nLily_Tomlin\t1\t2\nLon_Kruger\t1\t2\nLynn_Abraham\t1\t2\nMahmoud_Abbas\t7\t11\nMahmoud_Abbas\t15\t20\nMahmoud_Abbas\t22\t27\nMark_Richt\t1\t2\nMark_Richt\t1\t3\nMary-Kate_Olsen\t1\t2\nMary-Kate_Olsen\t2\t3\nMatt_Dillon\t1\t2\nMax_Mayfield\t1\t2\nMegan_Mullally\t1\t2\nMegan_Mullally\t1\t3\nMichael_Caine\t1\t2\nMichael_Caine\t1\t3\nMichael_Caine\t3\t4\nMichael_J_Sheehan\t1\t2\nMichael_Keaton\t1\t2\nMichael_Powell\t1\t2\nMichael_Powell\t1\t3\nMichael_Powell\t1\t5\nMichael_Powell\t2\t3\nMichael_Powell\t2\t4\nMichael_Powell\t2\t5\nMichael_Powell\t4\t5\nMiguel_Contreras\t1\t2\nMike_Weir\t1\t6\nMike_Weir\t3\t11\nMikhail_Kasyanov\t1\t2\nMikhail_Kasyanov\t1\t3\nMikhail_Kasyanov\t3\t4\nMohammed_Baqir_al-Hakim\t1\t3\nMonica_Lewinsky\t1\t2\nMonica_Lewinsky\t1\t3\nMonica_Lewinsky\t2\t3\nNan_Wang\t1\t3\nNan_Wang\t2\t3\nNan_Wang\t3\t4\nNancy_Demme\t1\t2\nNancy_Reagan\t1\t2\nNaoto_Kan\t1\t3\nNaoto_Kan\t2\t3\nNatasha_McElhone\t1\t2\nNatasha_McElhone\t1\t3\nNeri_Marcore\t1\t2\nNicholas_Tse\t1\t2\nNicolas_Escude\t1\t2\nNoelle_Bush\t1\t3\nNoelle_Bush\t1\t4\nNoelle_Bush\t2\t4\nOrrin_Hatch\t1\t2\nPadraig_Harrington\t1\t3\nPadraig_Harrington\t1\t4\nPadraig_Harrington\t2\t4\nPedro_Almodovar\t1\t2\nPedro_Almodovar\t3\t5\nPedro_Almodovar\t5\t6\nPenelope_Ann_Miller\t1\t2\nPeter_Arnett\t1\t3\nPeter_Arnett\t2\t3\nPetria_Thomas\t1\t2\nPetro_Symonenko\t1\t2\nPrince_Charles\t1\t2\nPrince_Charles\t3\t4\nPrince_Charles\t3\t5\nRaoul_Ruiz\t1\t2\nRaoul_Ruiz\t2\t3\nRaoul_Ruiz\t2\t4\nRaoul_Ruiz\t3\t4\nRicky_Ponting\t1\t2\nRobert_Stack\t1\t2\nRobin_Cook\t1\t2\nRoger_Federer\t4\t5\nRoger_Federer\t4\t7\nRoger_Federer\t6\t7\nRonaldo_Luis_Nazario_de_Lima\t1\t4\nRonaldo_Luis_Nazario_de_Lima\t2\t3\nRonaldo_Luis_Nazario_de_Lima\t2\t4\nRonaldo_Luis_Nazario_de_Lima\t3\t4\nRoy_Williams\t1\t3\nRoy_Williams\t2\t4\nSally_Ride\t1\t2\nScott_McNealy\t1\t2\nScott_Peterson\t1\t2\nScott_Peterson\t1\t5\nScott_Peterson\t2\t5\nScott_Peterson\t3\t4\nScott_Ritter\t1\t2\nSean_OKeefe\t3\t4\nSean_Penn\t1\t2\nSean_Penn\t2\t3\nSebastien_Grosjean\t1\t2\nSebastien_Grosjean\t1\t4\nSharon_Stone\t1\t2\nSharon_Stone\t1\t3\nSharon_Stone\t1\t4\nSharon_Stone\t1\t5\nSharon_Stone\t2\t4\nSonia_Gandhi\t1\t3\nSonia_Gandhi\t1\t4\nSteve_Backley\t1\t2\nSteven_Hatfill\t1\t2\nTassos_Papadopoulos\t1\t3\nTaufik_Hidayat\t1\t2\nTaufik_Hidayat\t1\t3\nTaufik_Hidayat\t2\t3\nThomas_Malchow\t1\t2\nTom_Cruise\t3\t5\nTom_Cruise\t4\t10\nTom_Cruise\t6\t10\nToni_Braxton\t1\t3\nWayne_Gretzky\t1\t2\nWayne_Gretzky\t1\t4\nWilliam_Bulger\t1\t3\nWilliam_Bulger\t2\t4\nWinona_Ryder\t12\t13\nWinona_Ryder\t12\t18\nWinona_Ryder\t12\t19\nXanana_Gusmao\t1\t4\nXanana_Gusmao\t2\t3\nXanana_Gusmao\t3\t5\nXanana_Gusmao\t4\t5\nYann_Martel\t1\t2\nYashwant_Sinha\t1\t3\nYashwant_Sinha\t1\t5\nYashwant_Sinha\t5\t7\nAaron_Guiel\t1\tPascal_Rheaume\t1\nAaron_Guiel\t1\tSteve_Zahn\t1\nAdrian_Nastase\t2\tPrincess_Victoria\t1\nAhmed_Chalabi\t1\tRosario_Dawson\t1\nAhmed_Ghazi\t1\tJulia_Tymoshenko\t3\nAhmet_Demir\t1\tWally_Szczerbiak\t1\nAin_Seppik\t1\tGerhard_Schroeder\t55\nAin_Seppik\t1\tMisty_Dawn_Clymer\t1\nAin_Seppik\t1\tRaoul_Ruiz\t1\nAin_Seppik\t1\tSusan_Whelan\t1\nAishwarya_Rai\t1\tChloe_Sevigny\t1\nAishwarya_Rai\t1\tDinah_Turner\t1\nAishwarya_Rai\t1\tRosario_Dawson\t1\nAlan_Zemaitis\t1\tLauren_Killian\t1\nAlex_Cejka\t1\tTaufik_Hidayat\t2\nAlexandre_Daigle\t1\tBrent_Coles\t1\nAli_Bin_Hussein\t1\tBen_Cahoon\t1\nAli_Bin_Hussein\t1\tOswald_Gruebel\t1\nAli_Bin_Hussein\t1\tRaf_Vallone\t1\nAlimzhan_Tokhtakhounov\t1\tJeane_Kirkpatrick\t1\nAlimzhan_Tokhtakhounov\t2\tButch_Davis\t1\nAlisha_Richman\t1\tCamille_Lewis\t1\nAlisha_Richman\t1\tKaterina_Smrzova\t1\nAlisha_Richman\t1\tMiguel_Rosseto\t1\nAmelie_Mauresmo\t3\tLaura_Flessel\t1\nAmelie_Mauresmo\t18\tBob_Colvin\t1\nAna_Claudia_Talancon\t1\tPiers_Sellers\t1\nAndrea_Kiser\t1\tEllen_Barkin\t1\nAndrea_Kiser\t1\tImre_Kertasz\t1\nAndrea_Kiser\t1\tMatt_Dillon\t1\nAndrea_Kiser\t1\tYann_Martel\t2\nAndres_DAlessandro\t1\tLeticia_Van_de_Putte\t1\nAndres_DAlessandro\t1\tRonaldo_Luis_Nazario_de_Lima\t1\nAnette_Hosoi\t1\tRolf_Zimmermann\t1\nAnette_Hosoi\t1\tSheila_Taormina\t1\nAnette_Hosoi\t1\tTora_Takagi\t1\nAngelo_Reyes\t1\tChip_Knight\t1\nAngelo_Reyes\t1\tOliver_Neuville\t1\nAnne_Heche\t1\tSasha_Alexander\t1\nAnne_Heche\t1\tTanya_Lindenmuth\t1\nAntje_Buschschulte\t1\tJerry_Angelo\t1\nAnton_Balasingham\t1\tMatt_Siebrandt\t1\nAnton_Balasingham\t1\tWill_Ferrell\t1\nArmando_Avila_Panchame\t1\tMonica_Gabrielle\t1\nArmando_Avila_Panchame\t1\tRetief_Goosen\t1\nBJ_Habibie\t1\tCraig_MacTavish\t1\nBaz_Luhrmann\t1\tDanny_Avalon\t1\nBegum_Khaleda_Zia\t1\tEric_Idle\t1\nBegum_Khaleda_Zia\t1\tMichael_Andretti\t1\nBegum_Khaleda_Zia\t1\tPicabo_Street\t1\nBen_Cahoon\t1\tNate_Blackwell\t1\nBen_Cahoon\t1\tRoy_Williams\t3\nBen_Curtis\t3\tJim_Calhoun\t1\nBenicio_Del_Toro\t1\tElizabeth_Taylor\t1\nBenicio_Del_Toro\t1\tIsmail_Khan\t1\nBenicio_Del_Toro\t1\tTonya_Payne\t1\nBijan_Namdar_Zangeneh\t1\tPetro_Symonenko\t1\nBilly_Graham\t1\tKarin_Pilsaeter\t1\nBilly_Graham\t1\tPiers_Sellers\t1\nBilly_Graham\t2\tHoward_Wilkinson\t1\nBob_Colvin\t2\tJanet_Napolitano\t1\nBoris_Henry\t1\tJohn_Reid\t2\nBrandon_Boyd\t1\tJames_Brosnahan\t1\nBrandon_Boyd\t1\tNeil_Moritz\t1\nBrent_Coles\t1\tZoe_Ball\t1\nBrett_Hull\t1\tGregorio_Rosal\t1\nBrett_Hull\t1\tKirsten_Clark\t1\nBrett_Hull\t1\tRalph_Nader\t1\nBrett_Perry\t1\tNeri_Marcore\t1\nBruce_Willis\t1\tCarlos_Juarez\t1\nBruce_Willis\t1\tJim_Carrey\t1\nBruce_Willis\t1\tPetria_Thomas\t2\nBryant_Young\t1\tJim_Bollman\t1\nBryant_Young\t1\tMaurice_Cheeks\t1\nBuddy_Ryan\t1\tJames_Brosnahan\t1\nBuddy_Ryan\t1\tNancy_Reagan\t2\nButch_Davis\t2\tHerta_Daeubler-Gmelin\t2\nByron_Scott\t1\tJane_Clayson\t1\nCamille_Lewis\t1\tLincoln_Chafee\t1\nCamille_Lewis\t1\tNathirah_Hussein\t1\nCarol_Burnett\t1\tRaf_Vallone\t1\nCarol_Niedermayer\t1\tKristin_Scott\t1\nCatherine_Ndereba\t1\tJanet_Napolitano\t4\nChandrika_Kumaratunga\t1\tKevin_Satterfield\t1\nCharles_Mathews\t1\tWill_Ferrell\t1\nCharles_Mathews\t2\tKristin_Scott\t1\nCharlie_Garner\t1\tLuo_Linquan\t1\nCharlie_Williams\t1\tJulia_Tymoshenko\t1\nCheryl_Ford\t1\tChris_Cookson\t1\nChip_Knight\t1\tRonald_Post\t1\nChloe_Sevigny\t1\tEmyr_Jones_Parry\t1\nChloe_Sevigny\t1\tPetria_Thomas\t3\nChris_Cornell\t1\tDesmon_Farmer\t1\nChristine_Ebersole\t2\tPaul_Walker\t1\nChristoph_Daum\t1\tScott_Hubbard\t1\nChristopher_Conyers\t1\tMichael_Milton\t1\nChristopher_Conyers\t1\tRaoul_Ruiz\t1\nChuck_Bednarik\t1\tMario_Jardel\t1\nCindy_Zagorski\t1\tRosie_Perez\t1\nClaudia_Schiffer\t1\tLynn_Abraham\t2\nClaudia_Schiffer\t3\tLin_Yung_Hsi\t1\nColin_Cowie\t1\tMstislav_Rostropovich\t1\nCondoleezza_Rice\t2\tMehmet_Okur\t1\nCondoleezza_Rice\t7\tRyan_Nyquist\t1\nCostas_Simitis\t2\tLorraine_Fenton\t1\nCraig_MacTavish\t1\tVince_Dooley\t1\nCristina_Saralegui\t1\tDave_Robertson\t1\nCruz_Bustamante\t2\tDean_Barkley\t3\nCyndi_Thompson\t1\tNicolas_Escude\t2\nCyndi_Thompson\t2\tOwen_Nolan\t1\nDalia_Rabin-Pelosoff\t1\tSean_Combs\t1\nDaniel_Darnell\t1\tMalcolm_Jamal_Warner\t1\nDanny_Avalon\t1\tSean_Penn\t2\nDavid_Blaine\t1\tNicholas_Tse\t2\nDavid_Blaine\t1\tRamon_Delgado\t1\nDavid_Heymann\t3\tNorm_Macdonald\t1\nDavid_Surrett\t1\tMichael_Taylor\t1\nDavid_Tornberg\t1\tRicky_Ponting\t1\nDeece_Eckstein\t1\tDiana_Munz\t1\nDeece_Eckstein\t1\tTommy_Lewis\t1\nDenis_Coderre\t1\tDon_Siegelman\t1\nDenis_Coderre\t1\tJohn_Eder\t1\nDesmon_Farmer\t1\tLin_Yung_Hsi\t1\nDiana_Krall\t4\tRamon_Delgado\t1\nDick_Armey\t1\tMehmet_Okur\t1\nDinah_Turner\t1\tMekhi_Phifer\t1\nDinah_Turner\t1\tTammy_Helm\t1\nDon_Boudria\t1\tRoy_Chaderton\t1\nDon_Boudria\t1\tSananda_Maitreya\t1\nDon_Matthews\t1\tKirsten_Clark\t1\nDon_Matthews\t1\tPa_Kou_Hang\t1\nDon_Matthews\t1\tPeter_Arnett\t2\nDon_Siegelman\t2\tElizabeth_Taylor\t2\nDonald_Pettit\t1\tEdward_James_Olmos\t2\nDoug_Collins\t1\tKristanna_Loken\t5\nDyana_Calub\t1\tRonald_Post\t1\nEarl_Counter\t1\tJoe_Friedberg\t1\nEdward_Albee\t1\tNicola_Bono\t1\nEdward_Belvin\t1\tJacqueline_Gold\t1\nEdward_James_Olmos\t2\tMariano_Zabaleta\t1\nElin_Nordegren\t1\tGeorge_Brumley_III\t1\nElin_Nordegren\t1\tSamantha_Daniels\t1\nElin_Nordegren\t2\tLeszek_Miller\t3\nElisabeth_Welch\t1\tPiers_Sellers\t1\nElizabeth_Taylor\t1\tOlympia_Dukakis\t1\nEllen_DeGeneres\t2\tLorraine_Fenton\t1\nElva_Hsiao\t1\tSamantha_Daniels\t1\nEmma_Watson\t2\tHenry_Hyde\t1\nEmyr_Jones_Parry\t1\tSally_Clark\t1\nEric_Ryan_Donnelly\t1\tIain_Duncan_Smith\t1\nErnesto_Zedillo\t1\tLenny_Kravitz\t1\nErnesto_Zedillo\t1\tMegan_Mullally\t2\nErwin_Mapasseng\t1\tHilary_Duff\t3\nEvelyn_Lauder\t1\tNathan_Powell\t1\nFernando_Hierro\t1\tPrince_Charles\t2\nFlavia_Delaroli\t2\tJohn_Warner\t4\nFlavia_Delaroli\t2\tVanessa_Laine\t1\nFran_Drescher\t1\tWarren_Truss\t1\nFran_Drescher\t2\tJay_Leno\t3\nFrank_Murkowski\t1\tJames_Brosnahan\t1\nFrank_Stallone\t1\tTommy_Lewis\t1\nFrank_Stallone\t2\tToni_Braxton\t2\nGary_Coleman\t1\tKoichi_Tanaka\t1\nGary_Coleman\t1\tUri_Lopolianski\t1\nGary_Sayler\t1\tRalph_Sampson\t1\nGeorge_Brumley_III\t1\tWill_Ferrell\t1\nGeorge_Lopez\t5\tIain_Duncan_Smith\t1\nGeorgina_Bardach\t1\tHenry_Hilow\t1\nGilberto_Rodriguez_Orejuela\t3\tLennox_Lewis\t1\nGilberto_Rodriguez_Orejuela\t3\tNancy_Demme\t1\nGordon_Lightfoot\t1\tLima_Azimi\t1\nGordon_Lightfoot\t1\tRobert_Nardelli\t1\nGracia_Burnham\t1\tJim_Calhoun\t1\nGregorio_Rosal\t1\tRichard_Greenberg\t1\nGuenter_Verheugen\t1\tKaspar_Villiger\t1\nGuillermo_Canas\t1\tTim_Duncan\t2\nGuillermo_Canas\t2\tMichalis_Chrisohoides\t1\nHal_McCoy\t1\tRudolph_Holton\t1\nHank_Aaron\t1\tSteve_Valentine\t1\nHans_Eichel\t1\tJimmy_Iovine\t1\nHashan_Tillakaratne\t1\tJohn_Warner\t3\nHeath_Ledger\t2\tMelissa_Stark\t1\nHenry_Hilow\t1\tMonica_Gabrielle\t1\nHerta_Daeubler-Gmelin\t2\tKoichi_Tanaka\t1\nHilary_Duff\t1\tLuther_Htu\t1\nHun_Sen\t2\tJohn_Rigas\t2\nIdi_Amin\t1\tStephen_Silas\t1\nIsabel_Orellana\t1\tSpike_Helmick\t1\nIsmael_Miranda\t1\tJanela_Jara\t1\nIsmael_Miranda\t1\tPeter_Greenspun\t1\nIsmail_Khan\t1\tMalcolm_Jamal_Warner\t1\nJK_Rowling\t5\tSasha_Alexander\t1\nJackie_Chan\t3\tJennifer_Gratz\t1\nJacqueline_Edwards\t1\tMeg_Wakeman\t1\nJacqueline_Edwards\t1\tNoor_Mohammed\t1\nJames_Baker\t1\tMike_Tice\t1\nJames_Harris\t1\tKeith_Bogans\t2\nJames_Layug\t1\tRalph_Sampson\t1\nJane_Clayson\t1\tRene_Antonio_Leon_Rodriguez\t1\nJane_Kaczmarek\t2\tMorris_Watts\t1\nJane_Russell\t1\tMartin_ONeill\t1\nJanela_Jara\t1\tKirsten_Clark\t1\nJanela_Jara\t1\tPa_Kou_Hang\t1\nJanela_Jara\t1\tRicky_Cottrill\t1\nJanet_Napolitano\t2\tLaurie_Laychak\t1\nJavier_Camara\t1\tNate_Blackwell\t1\nJeane_Kirkpatrick\t1\tJeff_Van_Gundy\t3\nJeane_Kirkpatrick\t1\tRichard_Greenberg\t1\nJeff_Van_Gundy\t1\tRichard_Naughton\t1\nJeffrey_Katzenberg\t1\tSusan_Whelan\t1\nJennette_Bradley\t1\tTammy_Helm\t1\nJim_Furyk\t6\tLinn_Thornton\t1\nJohn_Eastman\t1\tRicky_Ponting\t1\nJohn_F_Kennedy_Jr\t2\tNathan_Powell\t1\nJohn_Garamendi\t1\tPetro_Symonenko\t2\nJohn_Madden\t1\tSara_Silverman\t1\nJose_Luis_Rodriguez_Zapatero\t1\tRene_Antonio_Leon_Rodriguez\t1\nJose_Luis_Rodriguez_Zapatero\t1\tSteve_Lenard\t1\nJose_Santos\t1\tMichael_Boyce\t1\nJoseph_Kabila\t1\tRose_Linkins\t1\nJuan_Francisco_Palencia\t1\tKristanna_Loken\t2\nJuan_Francisco_Palencia\t1\tWarren_Truss\t1\nJuan_Roman_Riquelme\t1\tRalph_Sampson\t1\nJulia_Tymoshenko\t2\tLuis_Sanchez\t1\nKarin_Pilsaeter\t1\tMike_Flanagan\t1\nKarin_Pilsaeter\t1\tPetria_Thomas\t3\nKeith_Bogans\t2\tMartin_ONeill\t1\nKelly_Leigh\t1\tSpike_Helmick\t1\nKen_Macha\t3\tTommy_Lewis\t1\nKenneth_Carlsen\t1\tRobin_Cook\t1\nKevin_Borseth\t1\tMichael_Caine\t4\nKoichi_Tanaka\t1\tRicardo_Lopez_Murphy\t1\nKristin_Scott\t1\tMax_Mayfield\t2\nLaura_Flessel\t1\tOwen_Nolan\t1\nLauren_Killian\t2\tTommy_Lewis\t1\nLaurie_Laychak\t1\tPa_Kou_Hang\t1\nLawrence_Di_Rita\t1\tMekhi_Phifer\t1\nLennox_Lewis\t3\tMonte_Kiffin\t1\nLeon_Lai\t1\tMonica_Lewinsky\t1\nLeon_Lai\t1\tSun_Myung_Moon\t1\nLily_Tomlin\t1\tMarcos_Daniel_Jimenez\t1\nLily_Tomlin\t2\tSim_Yong\t1\nLinn_Thornton\t1\tSherri_Coale\t1\nLinn_Thornton\t1\tTom_Cruise\t2\nLloyd_Mudiwa\t1\tSebastien_Grosjean\t1\nLois_Smart\t1\tTavis_Smiley\t1\nLuis_Sanchez\t1\tPetro_Symonenko\t1\nLuo_Linquan\t1\tMartin_ONeill\t1\nLuther_Htu\t1\tSteve_Karsay\t1\nLynn_Abraham\t1\tMichael_Keaton\t2\nLynn_Abraham\t2\tMariano_Zabaleta\t1\nMark_Richt\t3\tWilton_Gregory\t1\nMartha_Smith\t1\tRay_Sherman\t1\nMartin_ONeill\t1\tMike_Weir\t11\nMary-Kate_Olsen\t1\tSim_Yong\t1\nMatt_Siebrandt\t1\tRodney_Dangerfield\t1\nMaurice_Cheeks\t1\tSteve_Austin\t1\nMehmet_Okur\t1\tRandy_Travis\t1\nMichael_McNeely\t1\tSean_Combs\t1\nMichael_Milton\t1\tWilfredo_Moreno\t1\nMichael_Powell\t1\tScott_Weiland\t1\nMiguel_Rosseto\t1\tPascal_Rheaume\t1\nMiguel_Rosseto\t1\tRicky_Ponting\t2\nMike_Flanagan\t1\tMohammed_Baqir_al-Hakim\t2\nMike_Tice\t1\tPatti_Smith\t1\nMohammed_Baqir_al-Hakim\t2\tTatyana_Tomashova\t1\nMufti_Mohammad_Syed\t1\tRaoul_Ruiz\t4\nNancy_Demme\t1\tRoger_Mahony\t1\nNancy_Reagan\t1\tRafael_Bielsa\t1\nNatasha_McElhone\t2\tRobert_Nardelli\t1\nNathirah_Hussein\t1\tSusan_Whelan\t1\nNeil_Moritz\t1\tRoy_Williams\t2\nNeil_Moritz\t1\tXanana_Gusmao\t5\nNelson_Shanks\t1\tPedro_Martinez\t1\nNelson_Shanks\t1\tRen_Qingjin\t1\nNoor_Mohammed\t1\tScott_Weiland\t1\nOswald_Gruebel\t1\tRichard_Penniman\t1\nParthiv_Patel\t1\tTonya_Payne\t1\nPauley_Perrette\t1\tRoy_Williams\t4\nPeter_Arnett\t2\tRodney_Dangerfield\t1\nPeter_Greenspun\t1\tRod_Thorn\t1\nPeter_Harvey\t1\tWarren_Truss\t1\nRaja_Ramani\t1\tRichard_Greenberg\t1\nRaja_Ramani\t1\tWill_Young\t1\nRalph_Sampson\t1\tSamantha_Daniels\t1\nRaoul_Ruiz\t3\tTirunesh_Dibaba\t1\nRen_Qingjin\t1\tWilton_Gregory\t1\nRicardo_Lopez_Murphy\t2\tRoberto_Robaina\t1\nRicky_Ponting\t1\tRonaldo_Luis_Nazario_de_Lima\t4\nRobin_Cook\t1\tWilton_Gregory\t1\nRoger_Federer\t4\tSteve_Backley\t2\nRonald_Post\t1\tSteve_Karsay\t1\nRyan_Nyquist\t1\tWinona_Ryder\t22\nSally_Clark\t1\tScott_Ritter\t2\nSamantha_Daniels\t1\tTaufik_Hidayat\t3\nSherri_Coale\t1\tTroy_Garity\t1\nSteve_Valentine\t1\tToni_Braxton\t2\nTammy_Helm\t1\tTom_Smothers\t1\nTanya_Lindenmuth\t1\tTora_Takagi\t1\nToni_Braxton\t3\tYann_Martel\t2\nAdam_Scott\t1\t2\nAhmad_Masood\t1\t2\nAlan_Mulally\t1\t2\nAlexander_Rumyantsev\t1\t2\nAli_Abbas\t1\t2\nAmanda_Bynes\t1\t2\nAmanda_Bynes\t1\t3\nAmanda_Bynes\t1\t4\nAmanda_Bynes\t2\t3\nAndrei_Mikhnevich\t1\t2\nAngela_Merkel\t1\t2\nAngela_Merkel\t4\t5\nAngelina_Jolie\t1\t15\nAngelina_Jolie\t2\t11\nAngelina_Jolie\t8\t15\nAngelina_Jolie\t9\t15\nAngelina_Jolie\t11\t20\nAnthony_LaPaglia\t1\t2\nArlen_Specter\t1\t2\nAtal_Bihari_Vajpayee\t4\t6\nBarry_Alvarez\t1\t2\nBill_Belichick\t1\t2\nBill_Sizemore\t1\t2\nBoris_Yeltsin\t1\t2\nBritney_Spears\t4\t11\nBruce_Van_De_Velde\t1\t2\nCamilla_Parker_Bowles\t1\t2\nCarolina_Kluft\t1\t2\nCarson_Palmer\t1\t3\nCarson_Palmer\t2\t3\nCatherine_Deneuve\t1\t4\nCatherine_Deneuve\t2\t5\nCatherine_Deneuve\t3\t5\nCesar_Maia\t1\t2\nCharles_Moose\t10\t12\nChen_Liang_Yu\t1\t2\nChoi_Sung-hong\t1\t5\nChoi_Sung-hong\t2\t4\nChoi_Sung-hong\t3\t4\nChristina_Aguilera\t1\t2\nChristina_Aguilera\t1\t4\nChristina_Aguilera\t2\t4\nClara_Harris\t1\t5\nClara_Harris\t2\t4\nCoretta_Scott_King\t1\t2\nCoretta_Scott_King\t1\t3\nCoretta_Scott_King\t2\t3\nCourtney_Love\t1\t2\nDaniel_Day-Lewis\t1\t3\nDaniel_Day-Lewis\t2\t3\nDaniela_Hantuchova\t1\t2\nDebra_Messing\t1\t2\nDennis_Kucinich\t2\t7\nDick_Latessa\t1\t2\nDonald_Rumsfeld\t39\t110\nDonald_Rumsfeld\t51\t83\nDonald_Rumsfeld\t60\t67\nEduard_Shevardnadze\t1\t5\nEdward_Lu\t4\t6\nEdwina_Currie\t1\t2\nEdwina_Currie\t2\t4\nElizabeth_Shue\t1\t2\nEllen_Engleman\t1\t2\nEmma_Thompson\t1\t2\nEmma_Thompson\t1\t3\nEmma_Thompson\t2\t3\nEmmit_Smith\t1\t2\nFayssal_Mekdad\t1\t3\nFayssal_Mekdad\t1\t4\nFrances_Fisher\t1\t2\nFrank_Griswold\t1\t2\nGary_Forsee\t1\t2\nGloria_Macapagal_Arroyo\t3\t12\nGloria_Macapagal_Arroyo\t3\t25\nGloria_Macapagal_Arroyo\t8\t23\nGregory_Hines\t1\t2\nGus_Van_Sant\t1\t2\nGus_Van_Sant\t1\t3\nGwendal_Peizerat\t1\t2\nGwendal_Peizerat\t1\t3\nHal_Gehman\t2\t4\nHannah_Stockbauer\t1\t2\nHarrison_Ford\t1\t12\nHeizo_Takenaka\t1\t7\nHeizo_Takenaka\t3\t8\nHeizo_Takenaka\t3\t9\nHichiro_Naemura\t1\t2\nHipolito_Mejia\t1\t3\nHipolito_Mejia\t1\t4\nHolly_Hunter\t2\t6\nHolly_Hunter\t3\t7\nIgor_Ivanov\t5\t16\nIntisar_Ajouri\t2\t3\nJack_Nicholson\t1\t3\nJames_Blake\t1\t10\nJames_Blake\t4\t6\nJames_Blake\t5\t9\nJames_Kelly\t4\t5\nJames_Kopp\t2\t4\nJames_Smith\t1\t2\nJean_Chretien\t2\t39\nJean_Chretien\t6\t40\nJean_Chretien\t8\t35\nJean_Chretien\t19\t28\nJean_Chretien\t28\t52\nJean_Chretien\t29\t37\nJean_Chretien\t34\t36\nJeffrey_Immelt\t1\t2\nJennifer_Aniston\t1\t7\nJennifer_Aniston\t1\t16\nJennifer_Aniston\t6\t21\nJerry_Falwell\t1\t2\nJesse_Harris\t1\t3\nJesse_Harris\t2\t3\nJoan_Claybrook\t1\t2\nJoe_Calzaghe\t1\t2\nJoe_Nichols\t1\t3\nJoe_Nichols\t2\t4\nJoe_Nichols\t3\t4\nJoerg_Haider\t1\t2\nJohn_Abizaid\t1\t2\nJohn_Abizaid\t1\t7\nJohn_Abizaid\t2\t3\nJohn_Abizaid\t4\t7\nJohn_Abizaid\t4\t8\nJohn_Abizaid\t5\t6\nJohn_Jumper\t1\t2\nJohn_Mayer\t1\t2\nJohn_Mayer\t1\t3\nJohn_Negroponte\t5\t26\nJohn_Negroponte\t8\t17\nJohn_Negroponte\t28\t30\nJohn_Reilly\t1\t2\nJohn_Rowland\t1\t2\nJohnny_Depp\t1\t2\nJon_Corzine\t1\t2\nJose_Dirceu\t1\t2\nJose_Sarney\t1\t3\nJoseph_Estrada\t1\t3\nJoseph_Estrada\t2\t3\nJuan_Carlos_Ferrero\t9\t17\nJude_Law\t1\t2\nKatherine_Harris\t1\t2\nKatherine_Harris\t1\t4\nKatherine_Harris\t3\t4\nKelly_Clarkson\t1\t2\nKiki_Vandeweghe\t1\t2\nKofi_Annan\t8\t14\nKofi_Annan\t8\t32\nKofi_Annan\t13\t25\nLance_Bass\t1\t4\nLance_Bass\t2\t4\nLance_Bass\t2\t5\nLance_Bass\t4\t5\nLaurent_Gbagbo\t1\t2\nLee_Soo-hyuck\t1\t2\nLeslie_Caldwell\t2\t3\nLi_Zhaoxing\t2\t7\nLiu_Mingkang\t1\t2\nLuciano_Pavarotti\t1\t2\nLuis_Gonzalez_Macchi\t1\t2\nLuis_Gonzalez_Macchi\t2\t4\nLuis_Gonzalez_Macchi\t3\t4\nLuis_Gonzalez_Macchi\t3\t5\nLuis_Horna\t1\t4\nLuis_Horna\t2\t4\nLuiz_Inacio_Lula_da_Silva\t2\t9\nLuiz_Inacio_Lula_da_Silva\t2\t39\nLuiz_Inacio_Lula_da_Silva\t4\t8\nLuiz_Inacio_Lula_da_Silva\t7\t36\nLuiz_Inacio_Lula_da_Silva\t10\t19\nLuiz_Inacio_Lula_da_Silva\t11\t44\nLuiz_Inacio_Lula_da_Silva\t28\t44\nMadeleine_Albright\t1\t2\nMadeleine_Albright\t2\t3\nMarcus_Gronholm\t1\t2\nMarissa_Jaret_Winokur\t1\t2\nMark_Geragos\t1\t2\nMark_Philippoussis\t2\t7\nMark_Philippoussis\t3\t11\nMark_Philippoussis\t4\t6\nMark_Philippoussis\t4\t9\nMark_Philippoussis\t6\t7\nMark_Philippoussis\t6\t9\nMark_Philippoussis\t7\t9\nMarkus_Naslund\t1\t2\nMartha_Lucia_Ramirez\t2\t4\nMartha_Lucia_Ramirez\t3\t4\nMeryl_Streep\t14\t15\nMesut_Yilmaz\t1\t2\nMichael_Schumacher\t2\t13\nMichael_Schumacher\t2\t17\nMichael_Schumacher\t10\t11\nMichael_Schumacher\t13\t18\nMichel_Temer\t1\t2\nMichelle_Yeoh\t1\t2\nMichelle_Yeoh\t2\t5\nMonica_Seles\t1\t3\nMonica_Seles\t2\t6\nMonica_Seles\t4\t5\nMoshe_Katsav\t1\t2\nMoshe_Katsav\t2\t3\nMuhammad_Saeed_al-Sahhaf\t2\t5\nMuhammad_Saeed_al-Sahhaf\t3\t4\nMuhammad_Saeed_al-Sahhaf\t3\t5\nNancy_Sinatra\t1\t2\nNicanor_Duarte_Frutos\t3\t6\nNicanor_Duarte_Frutos\t3\t7\nNicanor_Duarte_Frutos\t3\t11\nPatti_Labelle\t2\t3\nPaul_Pierce\t1\t2\nPaul_Shanley\t2\t3\nPhil_Mickelson\t1\t2\nPrincess_Anne\t1\t2\nPrincess_Elisabeth\t1\t2\nPriscilla_Owen\t1\t2\nQueen_Rania\t2\t3\nRachel_Hunter\t1\t4\nRachel_Hunter\t2\t3\nRachel_Hunter\t3\t4\nRafael_Ramirez\t1\t2\nRafael_Ramirez\t2\t3\nRafael_Ramirez\t2\t4\nRalph_Lauren\t1\t2\nRecep_Tayyip_Erdogan\t2\t16\nRecep_Tayyip_Erdogan\t17\t19\nReese_Witherspoon\t3\t4\nRichard_Armitage\t2\t5\nRichard_Armitage\t6\t7\nRichard_Armitage\t6\t9\nRichard_Armitage\t8\t9\nRichard_Gephardt\t2\t10\nRichard_Gephardt\t3\t11\nRichard_Gephardt\t5\t9\nRichard_Gephardt\t10\t11\nRichard_Norton-Taylor\t1\t2\nRichie_Adubato\t1\t2\nRobert_Bullock\t1\t2\nRobert_Mueller\t4\t5\nRobert_Mugabe\t1\t2\nRobert_Zoellick\t2\t3\nRobert_Zoellick\t3\t7\nRoberto_Benigni\t1\t2\nRoh_Moo-hyun\t28\t32\nRoman_Polanski\t2\t3\nRoman_Polanski\t4\t6\nRon_Howard\t1\t2\nRonald_Reagan\t1\t3\nRonald_Reagan\t2\t3\nRosemarie_Stack\t1\t2\nRoy_Jones_Jr\t1\t2\nRupert_Murdoch\t1\t2\nSaburo_Kawabuchi\t1\t2\nSam_Mendes\t1\t2\nSam_Torrance\t1\t2\nSam_Torrance\t1\t3\nSam_Torrance\t2\t3\nSergei_Ivanov\t1\t3\nSergio_Vieira_De_Mello\t1\t2\nSergio_Vieira_De_Mello\t4\t9\nSergio_Vieira_De_Mello\t7\t8\nSergio_Vieira_De_Mello\t8\t11\nShannon_OBrien\t1\t2\nSheila_Fraser\t1\t2\nShimon_Peres\t1\t3\nShimon_Peres\t3\t4\nShimon_Peres\t4\t7\nSourav_Ganguly\t1\t3\nStanley_McChrystal\t1\t3\nStanley_McChrystal\t2\t3\nSteve_Lavin\t1\t4\nStrom_Thurmond\t1\t3\nSurakait_Sathirathai\t1\t2\nSusan_Collins\t1\t2\nTariq_Aziz\t3\t5\nTerry_Stotts\t1\t2\nThaksin_Shinawatra\t5\t6\nThomas_OBrien\t3\t9\nTim_Chapman\t1\t2\nTom_Hanks\t1\t7\nTom_Hanks\t4\t6\nTom_Hanks\t4\t9\nTom_Hanks\t5\t6\nTom_Reilly\t1\t2\nTom_Reilly\t2\t3\nTommy_Franks\t2\t4\nTommy_Franks\t4\t8\nValery_Giscard_dEstaing\t1\t2\nValery_Giscard_dEstaing\t1\t6\nVanessa_Williams\t1\t2\nVanessa_Williams\t2\t3\nVictoria_Beckham\t1\t2\nVictoria_Beckham\t1\t3\nVictoria_Beckham\t2\t3\nVladimir_Putin\t16\t21\nVladimir_Putin\t22\t31\nWarren_Beatty\t1\t2\nYasar_Yakis\t1\t4\nYoko_Ono\t1\t4\nYoko_Ono\t2\t4\nAJ_Lamas\t1\tChris_Penn\t1\nAhmed_Qureia\t1\tStanley_McChrystal\t3\nAhmet_Necdet_Sezer\t1\tJohn_Rowe\t1\nAlan_Dreher\t1\tEmily_Mason\t1\nAlan_Dreher\t1\tFrancisco_Santos\t1\nAlan_Dreher\t1\tRobert_Bullock\t2\nAlan_Mulally\t2\tTomomi_Morita\t1\nAlan_Stonecipher\t1\tLuis_Gonzalez\t1\nAlberto_Ruiz_Gallardon\t1\tJames_Smith\t2\nAlessandra_Cerna\t1\tJohn_Darby\t1\nAlessandra_Cerna\t1\tJohn_Rowland\t2\nAlessandra_Cerna\t1\tMarina_Canetti\t1\nAlessandra_Cerna\t1\tRandy_Jackson\t1\nAlessandra_Cerna\t1\tRichard_Jewell\t1\nAlex_Cabrera\t1\tFred_Huff\t1\nAlex_Cabrera\t1\tTommy_Franks\t9\nAlex_Corretja\t1\tJacky_Cheung\t1\nAlexandra_Spann\t1\tBeth_Blough\t1\nAli_Hammoud\t1\tRandy_Jackson\t1\nAlmeida_Baptista\t1\tJan_Peter_Balkenende\t1\nAlmeida_Baptista\t1\tJason_Mewes\t1\nAlmeida_Baptista\t1\tTaoufik_Mathlouthi\t1\nAmanda_Bynes\t2\tGrant_Rossenmeyer\t1\nAmy_Cotton\t1\tMatt_Walters\t1\nAmy_Cotton\t1\tRoberto_Guaterroma\t1\nAndrew_Jarecki\t1\tBarbara_Boxer\t1\nAndrew_Jarecki\t1\tTessa_Jowell\t1\nAndy_North\t1\tEric_Hinske\t1\nAndy_North\t1\tMarina_Kuptsova\t1\nAndy_North\t1\tPhil_Bennett\t1\nAngela_Merkel\t2\tHal_Gehman\t1\nAngela_Merkel\t3\tAnna_Jones\t1\nAngela_Merkel\t3\tFrank_Griswold\t1\nAnna_Jones\t1\tRay_Romano\t8\nAnthony_LaPaglia\t1\tRoberto_Guaterroma\t1\nArlen_Specter\t1\tBill_Butler\t1\nArlen_Specter\t2\tBarbara_Boxer\t1\nAtal_Bihari_Vajpayee\t3\tRuben_Sierra\t1\nAtsushi_Sato\t1\tMonica_Serra\t1\nBaburam_Bhattari\t1\tMuhammad_Saeed_al-Sahhaf\t4\nBarry_Alvarez\t1\tJohn_Jones\t1\nBill_Belichick\t1\tJohn_Petty\t1\nBill_Belichick\t1\tPhillipe_Comtois\t1\nBill_Belichick\t2\tRoger_Machado\t1\nBill_Byrne\t1\tBill_Sizemore\t1\nBill_Curry\t1\tEllen_Martin\t1\nBill_Curry\t1\tRichard_Langille\t1\nBill_Curry\t1\tRoberto_Guaterroma\t1\nBilly_Beane\t1\tTom_Welch\t1\nBoris_Trajkovski\t1\tLaurent_Gbagbo\t2\nBrad_Brownell\t1\tHussam_Mohammed_Amin\t1\nBrandon_Fails\t1\tChristian_Lirette\t1\nBrandon_Fails\t1\tEllen_Engleman\t2\nBrandon_Inge\t1\tEric_Lloyd\t1\nBrenda_Magana\t1\tNikolay_Davydenko\t1\nBrian_Jordan\t1\tJoe_Cravens\t1\nBrian_Lara\t1\tJohn_Darby\t1\nBrian_Lara\t1\tStanley_Nelson\t1\nCalvin_Harrison\t1\tLuis_Gonzalez_Macchi\t3\nCalvin_Harrison\t1\tRichard_Gephardt\t9\nCalvin_Harrison\t1\tSuzanne_Fox\t1\nCamilla_Parker_Bowles\t2\tGustavo_Franco\t1\nCarina_Lau_Ka-ling\t1\tLin_Yi-fu\t1\nCarlos_Ortega\t3\tLionel_Hampton\t1\nCarolina_Kluft\t3\tGwen_Stefani\t1\nCarson_Palmer\t3\tRichard_Jewell\t1\nCatherine_Deneuve\t4\tJade_Jagger\t1\nCatriona_Le_May_Doan\t1\tCraig_Burley\t1\nCatriona_Le_May_Doan\t1\tPhil_Mickelson\t1\nCharlie_Deane\t1\tQueen_Silvia\t1\nCharlotte_Church\t1\tKaoru_Hasuike\t1\nCharlotte_Church\t1\tSourav_Ganguly\t1\nCheryl_Hines\t1\tDu_Qinglin\t1\nCheryl_Hines\t1\tLane_Odom\t1\nChin-Hui_Tsao\t1\tRosemarie_Stack\t1\nChoi_Sung-hong\t4\tDebra_Messing\t1\nChoi_Sung-hong\t4\tFrederique_van_der_Wal\t1\nChris_Penn\t1\tPhil_Bennett\t1\nChris_Penn\t1\tTaoufik_Mathlouthi\t1\nChristian_Lirette\t1\tSargis_Sargsian\t1\nChristina_Aguilera\t2\tJoshua_Harapko\t1\nChristina_Aguilera\t4\tJerry_Falwell\t2\nChristopher_Amolsch\t1\tSteve_Pagliuca\t1\nChristopher_Matero\t1\tValery_Giscard_dEstaing\t1\nClaudine_Farrell\t1\tMike_Miller\t2\nClive_Woodward\t1\tDouglas_Faneuil\t1\nClive_Woodward\t1\tJose_Sarney\t2\nCoretta_Scott_King\t1\tRobert_Torricelli\t1\nCori_Enghusen\t1\tErnie_Stewart\t1\nCourtney_Love\t1\tJennifer_Aniston\t3\nCourtney_Love\t1\tRuben_Sierra\t1\nCraig_Burley\t1\tStanley_McChrystal\t3\nDaniel_Coats\t1\tKathryn_Grayson\t1\nDaniel_Day-Lewis\t3\tScott_Yates\t1\nDaniela_Hantuchova\t1\tJan_Peter_Balkenende\t1\nDanny_Green\t1\tRodrigo_Rato\t1\nDarin_Erstad\t1\tSteve_Fehr\t1\nDaryl_Smith\t1\tReese_Witherspoon\t4\nDavid_Hanson\t1\tRichard_Norton-Taylor\t1\nDavid_Hilt\t1\tHipolito_Mejia\t3\nDennis_Franchione\t1\tHugh_Miller\t1\nDennis_Kucinich\t3\tSam_Torrance\t2\nDennis_Kucinich\t4\tRadovan_Karadzic\t1\nDennis_Kucinich\t6\tIain_Anderson\t1\nDerek_Bond\t1\tJohn_Jumper\t1\nDiane_Ladd\t1\tTrevor_Watson\t1\nDick_Latessa\t1\tJohn_Burnett\t1\nDick_Latessa\t2\tMartha_Beatriz_Roque\t1\nDidier_Defago\t1\tJerry_Falwell\t2\nDon_Hewitt\t1\tGuennadi_Chipouline\t1\nDonald_Carty\t1\tErnie_Stewart\t1\nDonald_Carty\t1\tJeffrey_Immelt\t2\nDonald_Carty\t1\tVladimir_Putin\t34\nDu_Qinglin\t1\tMeryl_Streep\t7\nDustan_Mohr\t1\tEdward_Flynn\t1\nDustan_Mohr\t1\tEnrik_Vendt\t1\nDustan_Mohr\t1\tNikolay_Davydenko\t1\nDustan_Mohr\t1\tSourav_Ganguly\t5\nDustan_Mohr\t1\tTheo_Angelopoulos\t1\nE_Clay_Shaw\t1\tJerry_Jones\t1\nEduard_Shevardnadze\t3\tMartha_Lucia_Ramirez\t1\nEdward_Flynn\t1\tMadeleine_Albright\t2\nEdward_Lu\t1\tRobert_Zoellick\t7\nEdwina_Currie\t4\tEric_Hinske\t2\nElena_de_Chavez\t1\tJack_Goodman\t1\nElizabeth_Shue\t1\tOdai_Hussein\t1\nElizabeth_Shue\t2\tPrincess_Hisako\t1\nElizabeth_Shue\t2\tTerry_Stotts\t1\nEllen_Engleman\t1\tGuennadi_Chipouline\t1\nEllen_Saracini\t1\tRay_Romano\t6\nElsa_Zylberstein\t2\tMatt_Braker\t1\nElvis_Stojko\t1\tJerry_Falwell\t1\nElvis_Stojko\t1\tRobert_Mueller\t5\nEmma_Thompson\t3\tNathan_Doudney\t1\nEmmit_Smith\t2\tRafael_Ramirez\t4\nEnrik_Vendt\t1\tLane_Odom\t1\nEnrique_Oliu\t1\tMarkus_Naslund\t1\nEnrique_Oliu\t1\tWilliam_McDonough\t1\nEric_Hinske\t1\tJuan_Antonio_Samaranch\t1\nEric_Lloyd\t1\tJessica_Alba\t2\nEric_Lloyd\t1\tValery_Giscard_dEstaing\t1\nErnie_Harwell\t1\tQueen_Beatrix\t3\nFelipe_Perez_Roque\t2\tMC_Hammer\t1\nFrank_Griswold\t1\tYana_Klochkova\t1\nFrank_Zappa\t1\tMarkus_Naslund\t1\nFrederique_van_der_Wal\t1\tPedro_Mahecha\t1\nFrederique_van_der_Wal\t1\tRaja_Zafar-ul-Haq\t1\nGary_Leon_Ridgway\t1\tRobert_Wagner\t1\nGary_Leon_Ridgway\t1\tScott_Yates\t1\nGary_Leon_Ridgway\t1\tYana_Klochkova\t1\nGene_Keady\t1\tMark_Sacco\t1\nGeorge_Gregan\t1\tJohn_Negroponte\t27\nGlen_DaSilva\t1\tRachel_Hunter\t4\nGlen_DaSilva\t1\tRobert_Mugabe\t2\nGlen_Sather\t1\tLeslie_Caldwell\t3\nGlen_Sather\t1\tTrevor_Watson\t1\nGoran_Zivkovic\t1\tLee_Soo-hyuck\t2\nGoran_Zivkovic\t1\tMartha_Sahagun_de_Fox\t1\nGoran_Zivkovic\t1\tShane_Reynolds\t1\nGrant_Rossenmeyer\t1\tTrevor_Watson\t1\nGregory_Hines\t1\tMarcus_Gronholm\t2\nGuennadi_Chipouline\t1\tTom_Lantos\t1\nGuillermo_Ortiz\t1\tNestor_Santillan\t1\nGuillermo_Ortiz\t2\tStrom_Thurmond\t2\nGus_Van_Sant\t3\tNatalie_Stewart\t1\nGwen_Stefani\t1\tHugh_Miller\t1\nGwendal_Peizerat\t3\tTurner_Stevenson\t1\nHal_Gehman\t1\tScott_Yates\t1\nHamad_Bin_Isa_al-Khalifa\t1\tMarta_Dominguz\t1\nHarrison_Ford\t2\tMarcus_Gronholm\t1\nHarvey_Wachsman\t1\tNarayan_Singh_Pun\t1\nHeather_Locklear\t1\tJohn_Mayer\t3\nHeather_Locklear\t1\tPablo_Khulental\t1\nHichiro_Naemura\t2\tRichard_Jewell\t1\nHipolito_Mejia\t3\tJim_Ahern\t1\nHolly_Hunter\t3\tJoshua_Perper\t1\nHugh_Hefner\t1\tSam_Mendes\t1\nIain_Anderson\t1\tJames_Kopp\t2\nIain_Anderson\t1\tRecep_Tayyip_Erdogan\t12\nIlan_Goldfajn\t1\tJennifer_Aniston\t17\nIlie_Nastase\t1\tMichael_Lopez-Alegria\t1\nIntisar_Ajouri\t3\tLin_Yi-fu\t1\nItamar_Franco\t1\tJessica_Alba\t1\nJack_Goodman\t1\tKirsten_Dunst\t1\nJack_Goodman\t1\tSaburo_Kawabuchi\t2\nJack_Nicholson\t1\tPat_Wharton\t1\nJack_Valenti\t1\tShinzo_Abe\t1\nJake_Plummer\t1\tJose_Dirceu\t2\nJakob_Kellenberger\t1\tLara_Logan\t1\nJakob_Kellenberger\t1\tPedro_Mahecha\t1\nJames_Maguire\t1\tRonald_Reagan\t1\nJames_Smith\t2\tKyra_Sedgwick\t1\nJason_Statham\t1\tKwame_Kilpatrick\t1\nJawad_Boulus\t1\tNarayan_Singh_Pun\t1\nJean-Rene_Fourtou\t1\tRoh_Moo-hyun\t28\nJeannette_Biedermann\t1\tKenny_Brack\t1\nJennifer_Granholm\t1\tTrudi_Lacey\t1\nJerelle_Kraus\t1\tWarren_Beatty\t1\nJesus_Cardenal\t1\tPablo_Khulental\t1\nJim_Hendry\t1\tLarry_Beinfest\t1\nJoan_Claybrook\t2\tPablo_Latras\t1\nJoaquin_Sanchez\t1\tRichard_Armitage\t1\nJoe_Cocker\t1\tMartha_Beatriz_Roque\t1\nJoe_Cocker\t1\tRandy_Jackson\t1\nJoe_Cravens\t1\tSam_Mendes\t1\nJohn_Barnett\t1\tKathryn_Grayson\t1\nJohn_Darby\t1\tMasum_Turker\t3\nJohn_Ferguson\t1\tPaul_Schrader\t1\nJohn_Paul_DeJoria\t1\tPaul_Pierce\t1\nJohn_Reilly\t2\tPrincess_Hisako\t1\nJohn_Rowland\t2\tSteve_Kerr\t1\nJohnny_Depp\t1\tLeo_Mullin\t1\nJohnny_Depp\t1\tTrudi_Lacey\t1\nJohnny_Htu\t1\tRoger_Machado\t1\nJose_Dirceu\t1\tRobert_Torricelli\t3\nJuan_Antonio_Samaranch\t1\tStefan_Koubek\t1\nJuergen_Braehmer\t1\tShawn_Bradley\t1\nJuergen_Braehmer\t1\tTravis_Rudolph\t1\nKathryn_Grayson\t1\tQueen_Beatrix\t4\nKathryn_Grayson\t1\tRuben_Sierra\t1\nKathryn_Grayson\t1\tShannon_OBrien\t2\nKatie_Holmes\t1\tPark_Jung_Sung\t1\nKenny_Brack\t1\tLin_Yi-fu\t1\nKwame_Kilpatrick\t1\tShannon_OBrien\t2\nKyra_Sedgwick\t1\tReese_Witherspoon\t3\nKyra_Sedgwick\t1\tRichard_Hellfant\t1\nKyra_Sedgwick\t1\tWilbert_Elki_Meza_Majino\t1\nLance_Bass\t3\tQueen_Rania\t5\nLara_Logan\t1\tTurner_Stevenson\t1\nLaszlo_Kovacs\t1\tLuke_Ridnour\t1\nLaszlo_Kovacs\t1\tOlesya_Bonabarenko\t2\nLee_Byung-woong\t1\tWilliam_Hochul\t2\nLee_Soo-hyuck\t1\tRobert_Bullock\t1\nLeslie_Caldwell\t1\tShane_Reynolds\t1\nLeslie_Caldwell\t2\tTurner_Stevenson\t1\nLi_Zhaoxing\t4\tSusan_Sarandon\t4\nLinda_Mason\t1\tRupert_Murdoch\t2\nLiu_Mingkang\t2\tPedro_Pauleta\t1\nLiu_Ye\t1\tRuben_Sierra\t1\nLiu_Ye\t1\tSteve_Alford\t1\nLoretta_Lynn_Harper\t1\tMichel_Temer\t2\nLuis_Gonzalez\t1\tWarren_Beatty\t1\nMadeleine_Albright\t2\tMartha_Lucia_Ramirez\t2\nMaha_Habib\t1\tPrincess_Elisabeth\t1\nMarc_Anthony\t1\tMichael_Pfleger\t1\nMarcus_Gronholm\t1\tTeresa_Graves\t1\nMarcus_Gronholm\t1\tTommy_Franks\t8\nMarina_Canetti\t1\tSaied_Hadi_al_Mudarissi\t1\nMario_Alfaro-Lopez\t1\tRichard_Armitage\t6\nMario_Alfaro-Lopez\t1\tTom_Lantos\t1\nMark_Dacey\t1\tTurner_Stevenson\t1\nMark_Dacey\t2\tSteve_Cox\t1\nMark_Kelly\t1\tMark_Lazarus\t1\nMark_Lazarus\t1\tRonnie_Jagday\t1\nMark_Sacco\t1\tTono_Suratman\t1\nMarkus_Naslund\t1\tRobert_Wagner\t1\nMartin_Kristof\t1\tTaia_Balk\t1\nMatt_Anderson\t1\tSeth_Gorney\t1\nMatt_Braker\t1\tSurakait_Sathirathai\t1\nMatt_Roney\t1\tWilbert_Elki_Meza_Majino\t1\nMichael_Bolton\t1\tRobert_Bullock\t2\nMichael_Pfleger\t1\tRobert_Ehrlich\t2\nMichael_Schumacher\t17\tNatalie_Imbruglia\t1\nMichael_Shane_Jolly\t1\tTrudi_Lacey\t1\nMichel_Temer\t1\tPaul_Shanley\t1\nMichelle_Yeoh\t5\tSaburo_Kawabuchi\t1\nMike_Helton\t1\tOctavio_Lara\t1\nMike_Miller\t2\tToby_Keith\t1\nMonica_Seles\t2\tQueen_Beatrix\t4\nNancy_Sinatra\t1\tSargis_Sargsian\t1\nPablo_Khulental\t1\tRosemarie_Stack\t2\nPark_Jung_Sung\t1\tRobert_Bullock\t2\nPaul_Pierce\t2\tRobert_Bullock\t2\nPedro_Pauleta\t1\tRobert_Tyrrell\t1\nPedro_Pauleta\t1\tTommy_Franks\t14\nPhil_Morris\t1\tPriscilla_Owen\t2\nPhil_Morris\t1\tRoberto_Guaterroma\t1\nPhil_Morris\t1\tYuri_Luzhkov\t1\nQueen_Rania\t3\tRonnie_Jagday\t1\nRadovan_Karadzic\t1\tRichard_Langille\t1\nRandy_Jackson\t1\tSteve_Alford\t1\nReese_Witherspoon\t1\tSam_Torrance\t1\nReese_Witherspoon\t2\tToni_Jennings\t1\nRina_Lazo\t1\tRonald_Reagan\t1\nRobert_Ehrlich\t2\tRon_Lantz\t1\nRobert_Mugabe\t1\tTessa_Jowell\t1\nRobert_Torricelli\t3\tTaoufik_Mathlouthi\t1\nRobert_Tyrrell\t1\tYuri_Luzhkov\t1\nRobert_Wagner\t1\tTommy_Franks\t11\nRobin_Wright_Penn\t1\tSam_Torrance\t3\nRobin_Wright_Penn\t1\tYoko_Ono\t6\nRogelio_Ramos\t1\tRyan_Newman\t1\nRoman_Polanski\t4\tToby_Keith\t1\nRonnie_Jagday\t1\tSidney_Kimmel\t1\nScott_Yates\t1\tSteve_Cox\t1\nSean_Patrick_Thomas\t1\tWilliam_Hochul\t1\nSharon_Osbourne\t2\tShimon_Peres\t6\nStefan_Koubek\t1\tSteve_Alford\t1\nTeri_Garr\t1\tYana_Klochkova\t1\nWarren_Beatty\t2\tWilliam_McDonough\t1\nAleksander_Kwasniewski\t1\t2\nAleksander_Kwasniewski\t2\t4\nAleksander_Kwasniewski\t3\t4\nAli_Naimi\t1\t2\nAli_Naimi\t1\t5\nAli_Naimi\t2\t8\nAmanda_Beard\t1\t2\nAndrew_Cuomo\t1\t2\nArnold_Schwarzenegger\t8\t31\nArnold_Schwarzenegger\t9\t39\nArnold_Schwarzenegger\t11\t41\nArnold_Schwarzenegger\t12\t37\nArnold_Schwarzenegger\t13\t39\nArnold_Schwarzenegger\t22\t33\nArnold_Schwarzenegger\t28\t41\nBernard_Lord\t1\t2\nBeth_Jones\t1\t2\nBranko_Crvenkovski\t2\t3\nBrigitte_Boisselier\t1\t2\nBruce_Springsteen\t1\t2\nBruce_Springsteen\t1\t3\nBruce_Springsteen\t2\t3\nBruce_Springsteen\t2\t4\nCalista_Flockhart\t1\t5\nCalista_Flockhart\t4\t6\nCameron_Diaz\t1\t3\nCameron_Diaz\t3\t6\nCarol_Moseley_Braun\t1\t2\nCarrie-Anne_Moss\t1\t3\nCarrie-Anne_Moss\t1\t5\nCarrie-Anne_Moss\t2\t5\nCarrie-Anne_Moss\t3\t5\nCarrie-Anne_Moss\t4\t5\nCharlton_Heston\t1\t5\nCharlton_Heston\t2\t5\nCharlton_Heston\t4\t6\nChris_Bell\t1\t2\nChung_Mong-hun\t1\t2\nCiro_Gomes\t1\t2\nCiro_Gomes\t2\t5\nCiro_Gomes\t3\t5\nColin_Montgomerie\t1\t4\nColin_Montgomerie\t2\t3\nColin_Montgomerie\t2\t5\nColin_Montgomerie\t4\t5\nDavid_Trimble\t1\t4\nDavid_Trimble\t1\t5\nDavid_Trimble\t3\t4\nDavid_Wolf\t1\t2\nDemetrius_Ferraciu\t1\t2\nDennis_Powell\t1\t2\nDesiree_Lemosi\t1\t2\nDolma_Tsering\t1\t2\nDoug_Melvin\t1\t2\nEdward_Norton\t1\t2\nEmanuel_Ginobili\t2\t3\nEric_Clapton\t1\t2\nFabiola_Zuluaga\t1\t2\nFaye_Dunaway\t1\t2\nFerenc_Madl\t1\t2\nFernando_Gonzalez\t1\t5\nFernando_Gonzalez\t1\t8\nFernando_Gonzalez\t2\t6\nFilippo_Inzaghi\t1\t2\nFilippo_Inzaghi\t1\t3\nFilippo_Inzaghi\t2\t3\nFrancis_George\t1\t2\nFranz_Beckenbauer\t1\t2\nFranz_Muentefering\t1\t2\nFranz_Muentefering\t3\t4\nGary_Bergeron\t1\t2\nGeorge_Foreman\t1\t2\nGeorge_Pataki\t1\t3\nGeorge_Pataki\t3\t4\nGeorge_Pataki\t3\t5\nGeorge_Roy_Hill\t1\t2\nGonzalo_Sanchez_de_Lozada\t7\t8\nGonzalo_Sanchez_de_Lozada\t7\t10\nGonzalo_Sanchez_de_Lozada\t8\t11\nGonzalo_Sanchez_de_Lozada\t8\t12\nGregory_Geoffroy\t1\t2\nGuillermo_Coria\t7\t13\nGuillermo_Coria\t19\t22\nHabib_Rizieq\t1\t3\nHabib_Rizieq\t2\t3\nHamid_Karzai\t1\t3\nHamid_Karzai\t4\t13\nHamid_Karzai\t19\t22\nHilmi_Ozkok\t1\t2\nHorst_Koehler\t1\t2\nHorst_Koehler\t1\t3\nHorst_Koehler\t2\t3\nHoward_Schultz\t1\t2\nIlan_Ramon\t1\t2\nJavier_Solana\t4\t8\nJavier_Solana\t6\t9\nJavier_Solana\t6\t10\nJay_Garner\t1\t3\nJean-Claude_Braquet\t1\t2\nJean-Claude_Trichet\t1\t2\nJean_Charest\t1\t10\nJean_Charest\t2\t11\nJean_Charest\t7\t10\nJean_Charest\t8\t13\nJean_Charest\t8\t17\nJefferson_Perez\t1\t2\nJim_Edmonds\t1\t2\nJohn_Kerry\t1\t5\nJohn_Kerry\t3\t4\nJohn_Kerry\t4\t12\nJohn_Kerry\t9\t13\nJohn_Malkovich\t1\t2\nJohn_Malkovich\t1\t3\nJohn_McCallum\t1\t2\nJohn_McEnroe\t1\t2\nJohn_Rosa\t1\t3\nJohnny_Unitas\t1\t2\nJong_Wook_Lee\t3\t4\nJose_Maria_Aznar\t1\t13\nJose_Maria_Aznar\t6\t13\nJose_Maria_Aznar\t6\t20\nJose_Maria_Aznar\t15\t23\nJose_Maria_Aznar\t17\t22\nJulianne_Moore\t4\t9\nJulianne_Moore\t6\t16\nJulianne_Moore\t6\t19\nJulianne_Moore\t7\t18\nJulianne_Moore\t12\t15\nJulio_Iglesias_Jr\t1\t2\nJustin_Timberlake\t1\t2\nJustin_Timberlake\t1\t3\nJustin_Timberlake\t5\t6\nJustin_Timberlake\t6\t8\nJustine_Pasek\t2\t5\nJustine_Pasek\t2\t6\nJustine_Pasek\t6\t7\nKathleen_Glynn\t1\t2\nKim_Dae-jung\t1\t3\nKim_Dae-jung\t1\t5\nKim_Dae-jung\t2\t3\nKim_Dae-jung\t4\t6\nKirk_Johnson\t1\t2\nKirk_Johnson\t1\t3\nKirk_Johnson\t2\t3\nKosuke_Kitajima\t1\t2\nKurt_Russell\t1\t2\nLarry_Coker\t1\t4\nLarry_Coker\t2\t4\nLarry_Ellison\t1\t2\nLarry_Ellison\t1\t3\nLawrence_MacAulay\t1\t2\nLeBron_James\t1\t4\nLeBron_James\t1\t5\nLeBron_James\t3\t4\nLeBron_James\t4\t5\nLea_Fastow\t1\t2\nLee_Hoi-chang\t1\t2\nLee_Hoi-chang\t2\t4\nLi_Peng\t2\t6\nLi_Peng\t4\t7\nLi_Peng\t4\t8\nLi_Peng\t4\t9\nLim_Dong-won\t1\t2\nLindsay_Benko\t1\t2\nLou_Piniella\t1\t3\nLou_Piniella\t2\t3\nLucio_Gutierrez\t1\t2\nLucio_Gutierrez\t3\t10\nLucio_Gutierrez\t6\t7\nLucio_Gutierrez\t6\t8\nLucio_Gutierrez\t8\t13\nLuis_Figo\t2\t3\nLuis_Figo\t2\t4\nLuke_Walton\t1\t2\nMarat_Safin\t1\t2\nMarat_Safin\t1\t3\nMarat_Safin\t2\t3\nMariana_Pollack\t1\t3\nMariana_Pollack\t2\t3\nMartin_McGuinness\t3\t4\nMasahiko_Nagasawa\t1\t2\nMichael_Chiklis\t1\t4\nMichael_Chiklis\t1\t5\nMichael_Chiklis\t2\t3\nMichael_Chiklis\t2\t4\nMichael_Chiklis\t3\t5\nMichael_Chiklis\t4\t5\nMichael_Douglas\t1\t2\nMichael_Douglas\t1\t3\nMichael_Douglas\t2\t4\nMichael_Douglas\t3\t6\nMichael_Douglas\t4\t5\nMichael_Kostelnik\t1\t2\nMichael_Leavitt\t1\t2\nMichelle_Branch\t1\t2\nMichelle_Kwan\t1\t4\nMichelle_Kwan\t4\t5\nMichelle_Kwan\t6\t8\nMike_Montgomery\t1\t2\nMike_Tyson\t1\t3\nMikhail_Wehbe\t1\t3\nMinnie_Driver\t1\t2\nMiyako_Miyazaki\t1\t2\nMuammar_Gaddafi\t1\t2\nMunir_Akram\t1\t2\nNadia_Petrova\t1\t2\nNadia_Petrova\t1\t3\nNadia_Petrova\t1\t4\nNadia_Petrova\t2\t3\nNadia_Petrova\t3\t4\nNadia_Petrova\t4\t5\nNancy_Pelosi\t1\t7\nNancy_Pelosi\t2\t9\nNancy_Pelosi\t4\t15\nNancy_Pelosi\t12\t14\nNia_Vardalos\t1\t3\nNia_Vardalos\t3\t4\nNia_Vardalos\t3\t5\nNicholas_Byron\t1\t2\nNikki_Reed\t1\t2\nOlivia_Newton-John\t1\t2\nParadorn_Srichaphan\t2\t4\nParadorn_Srichaphan\t4\t5\nPascal_Quignard\t1\t3\nPascal_Quignard\t2\t3\nPatrice_Chereau\t1\t2\nPedro_Malan\t1\t5\nPedro_Malan\t3\t5\nPeter_Harrison\t1\t2\nRainer_Schuettler\t1\t4\nRainer_Schuettler\t2\t3\nRainer_Schuettler\t2\t4\nRaymond_Odierno\t1\t2\nRebecca_Romijn-Stamos\t1\t2\nRebecca_Romijn-Stamos\t1\t3\nRebecca_Romijn-Stamos\t1\t4\nRebecca_Romijn-Stamos\t3\t4\nRichard_Krajicek\t1\t3\nRichard_Krajicek\t2\t3\nRick_Santorum\t1\t2\nRick_Santorum\t1\t3\nRick_Santorum\t2\t3\nRick_Stansbury\t2\t3\nRob_Marshall\t1\t3\nRob_Marshall\t1\t6\nRob_Marshall\t2\t4\nRobert_Blackwill\t1\t2\nRobert_Duvall\t2\t8\nRobert_Horan\t1\t2\nRobert_Redford\t3\t4\nRobert_Redford\t7\t8\nRobinson_Stevenin\t1\t2\nRoger_Clemens\t1\t2\nSadie_Frost\t1\t2\nSaparmurat_Niyazov\t1\t2\nSarah_Michelle_Gellar\t1\t2\nSarah_Michelle_Gellar\t1\t3\nSarah_Michelle_Gellar\t2\t3\nSerena_Williams\t1\t41\nSerena_Williams\t3\t32\nSerena_Williams\t14\t40\nSerena_Williams\t41\t47\nSergey_Lavrov\t1\t3\nSergey_Lavrov\t1\t6\nSergey_Lavrov\t2\t4\nSergey_Lavrov\t3\t5\nSergey_Lavrov\t3\t7\nSergey_Lavrov\t4\t8\nShane_Mosley\t1\t2\nSheila_Copps\t2\t3\nSheila_Copps\t3\t4\nShia_LaBeouf\t1\t2\nSteve_Nash\t1\t3\nSteve_Nash\t1\t4\nSteve_Nash\t2\t4\nSteve_Nash\t2\t5\nSteve_Spurrier\t1\t2\nSteve_Waugh\t1\t2\nSusilo_Bambang_Yudhoyono\t1\t2\nSusilo_Bambang_Yudhoyono\t1\t3\nSusilo_Bambang_Yudhoyono\t1\t4\nSusilo_Bambang_Yudhoyono\t3\t4\nSuzanne_Gaudet\t1\t2\nThomas_Bjorn\t1\t2\nTim_Conway\t1\t2\nTim_Conway\t1\t3\nTim_Robbins\t1\t5\nTim_Robbins\t2\t4\nTim_Robbins\t3\t5\nTom_Craddick\t1\t3\nTom_Craddick\t2\t4\nTom_Craddick\t3\t4\nTracee_Ellis_Ross\t1\t2\nVenus_Williams\t2\t9\nVivica_Fox\t1\t2\nWilliam_Ford_Jr\t1\t2\nWilliam_Ford_Jr\t2\t6\nWilliam_Ford_Jr\t5\t6\nWilliam_Rehnquist\t1\t2\nYossi_Beilin\t1\t2\nAaron_Eckhart\t1\tAkiko_Morigami\t1\nAaron_Eckhart\t1\tAnFernce_Negron\t1\nAaron_Eckhart\t1\tSadie_Frost\t1\nAbdel_Aziz_Al-Hakim\t1\tJoe_Darrell\t1\nAbdullah_al-Attiyah\t1\tRachel_Wadsworth\t1\nAbdullah_al-Attiyah\t2\tJohn_Lisowski\t1\nAbraham_Foxman\t1\tDoug_Melvin\t2\nAbraham_Foxman\t1\tNikki_Reed\t1\nAdam_Rich\t1\tJean-Claude_Trichet\t1\nAdam_Rich\t1\tJohn_Goold\t1\nAdam_Rich\t1\tLisa_Girman\t1\nAdam_Rich\t1\tRoger_Clemens\t1\nAdam_Rich\t1\tSuzanne_Somers\t1\nAdrian_Fernandez\t1\tNicolas_Massu\t1\nAiysha_Smith\t1\tYossi_Beilin\t1\nAkiko_Morigami\t1\tShane_Mosley\t1\nAlastair_Johnston\t1\tAleksander_Kwasniewski\t4\nAlastair_Johnston\t1\tBill_Duffey\t1\nAlbert_Brooks\t1\tRobinson_Stevenin\t1\nAlbert_Brooks\t1\tSheila_Copps\t3\nAleksander_Kwasniewski\t1\tGuangdong_Ou_Guangyuan\t1\nAleksander_Kwasniewski\t2\tGeorge_Plimpton\t1\nAleksander_Kwasniewski\t2\tJuan_Jose_Lucas\t1\nAleksander_Kwasniewski\t3\tBilly_Crawford\t1\nAleksander_Voloshin\t1\tKristen_Rivera\t1\nAlessandro_Nesta\t1\tPaul_Kelleher\t1\nAlfredo_di_Stefano\t1\tChris_Moore\t1\nAlfredo_di_Stefano\t1\tMaryn_McKenna\t1\nAlfredo_di_Stefano\t1\tShamai_Leibowitz\t1\nAli_Naimi\t5\tMorris_Dees\t1\nAline_Chretien\t1\tGuillermo_Coria\t17\nAmy_Yasbeck\t1\tChawki_Armali\t1\nAnFernce_Negron\t1\tKristen_Rivera\t1\nAndrew_Cuomo\t2\tTodd_Petit\t1\nAnil_Ramsook\t1\tTakeo_Hiranuma\t1\nAnnie_Chaplin\t1\tCharles_Tannok\t1\nAntanas_Valionis\t1\tWilliam_Rehnquist\t1\nAvril_Lavigne\t1\tShia_LaBeouf\t2\nBarbara_Becker\t1\tChris_Noth\t1\nBarbara_Becker\t1\tFranz_Beckenbauer\t2\nBarbora_Strycova\t1\tChristiane_Wulff\t1\nBarry_Diller\t1\tMeles_Zenawi\t1\nBartosz_Kizierowski\t1\tFaye_Wong\t1\nBen_Wallace\t1\tNia_Vardalos\t5\nBernard_Lord\t1\tJoxel_Garcia\t1\nBernard_Lord\t2\tBing_Crosby\t1\nBeyonce_Knowles\t1\tMaurice_Papon\t1\nBill_Duffey\t1\tJong_Wook_Lee\t1\nBill_Guerin\t1\tJulie_Goodenough\t1\nBill_Herrion\t1\tFernando_Valenzuela\t1\nBill_Herrion\t1\tJohnny_Unitas\t2\nBill_Richardson\t1\tGeorge_McCloud\t1\nBilly_Andrade\t1\tKellie_Coffey\t1\nBilly_Crawford\t1\tJim_Edmonds\t2\nBilly_Edelin\t1\tHimmler_Rebu\t1\nBing_Crosby\t1\tStephen_Webster\t1\nBixente_LIzarazu\t1\tChris_Bell\t2\nBixente_LIzarazu\t1\tTodd_Wike\t1\nBlythe_Danner\t2\tHank_McKinnell\t1\nBob_Eskridge\t1\tMarco_Pantani\t1\nBob_Hartley\t1\tLou_Piniella\t3\nBob_Krueger\t1\tGordana_Grubin\t1\nBob_Krueger\t1\tMariana_Pollack\t1\nBob_Sulkin\t1\tBranko_Crvenkovski\t3\nBobby_Kielty\t1\tRobert_Horan\t2\nBrajesh_Mishra\t1\tMark_Podlesny\t1\nBrandon_Knight\t1\tClaudia_Cardinale\t1\nBrandon_Knight\t1\tPhil_Donahue\t1\nBrandon_Lloyd\t1\tCha_Yung-gu\t1\nBrandon_Lloyd\t1\tJames_Coburn\t1\nBrian_Schneider\t1\tMichael_Rolinee\t1\nBruce_Springsteen\t4\tIon_Tiriac\t1\nCameron_Diaz\t2\tShia_LaBeouf\t1\nCameron_Diaz\t5\tNadia_Petrova\t2\nCarla_Gugino\t1\tKelly_Osbourne\t1\nCarla_Gugino\t1\tKenny_Chesney\t1\nCarla_Gugino\t1\tMichael_Douglas\t3\nCarla_Gugino\t1\tMiguel_Aldana_Ibarra\t1\nCarlos_Fasciolo\t1\tDebbie_Allen\t1\nCarol_Williams\t1\tGorden_Tallis\t1\nCarrie-Anne_Moss\t2\tHoracio_Julio_Pina\t1\nCarrie-Anne_Moss\t4\tMichael_Goldrich\t1\nCasey_Crowder\t1\tKeiko_Sofia_Fujimori\t1\nCasey_Crowder\t1\tPhoenix_Chang\t1\nCha_Yung-gu\t1\tTakeo_Hiranuma\t1\nCharlene_Barshefsky\t1\tJames_Coburn\t1\nCharles_Tannok\t1\tLarry_Coker\t4\nCharlie_Hunnam\t1\tHestrie_Cloette\t1\nCharlie_Hunnam\t1\tVeronica_Lake\t1\nCharlton_Heston\t4\tDesiree_Lemosi\t1\nChawki_Armali\t1\tShoshannah_Stern\t1\nChris_Bell\t2\tPharrell_Williams\t1\nChris_Forsyth\t1\tNikki_Reed\t2\nChris_Neil\t1\tJohn_Kerry\t14\nChris_Noth\t1\tTakeshi_Kitano\t1\nChristine_Arron\t1\tRobert_Duvall\t5\nChristine_Arron\t1\tSteve_McManaman\t1\nChuck_Hagel\t1\tJeff_Roehm\t1\nChuck_Hagel\t1\tMargaret_Hasley\t1\nChuck_Hagel\t1\tSebastian_Porto\t1\nCliff_Ellis\t1\tJohn_Lisowski\t1\nClifford_Etienne\t1\tPharrell_Williams\t1\nClifford_Etienne\t1\tRay_Lewis\t1\nClive_Lloyd\t1\tHarland_Braun\t1\nColin_Montgomerie\t1\tHoracio_Julio_Pina\t1\nDaniel_Montenegro\t1\tGustavo_Cisneros\t1\nDaniel_Montenegro\t1\tNadia_Petrova\t4\nDaniel_Montenegro\t1\tOmar_Khan_Sharif\t1\nDaniel_Montenegro\t1\tRick_Santorum\t1\nDanny_Glover\t1\tMorris_Dees\t1\nDanny_Glover\t1\tPatrice_Chereau\t2\nDavid_Trimble\t4\tJohn_Elway\t1\nDavid_Wolf\t2\tEmanuel_Ginobili\t4\nDavid_Wolf\t2\tKathleen_Glynn\t2\nDavid_Wolf\t2\tVenus_Williams\t6\nDebbie_Allen\t1\tSebastian_Cuattrin\t1\nDemetrius_Ferraciu\t2\tEdward_Seaga\t1\nDenise_Johnson\t1\tNikki_Cascone\t1\nDenise_Johnson\t2\tEmanuel_Ginobili\t3\nDenise_Johnson\t2\tFilippo_Inzaghi\t2\nDennis_Powell\t1\tHorst_Koehler\t3\nDennis_Powell\t1\tMichael_Chiklis\t2\nDesiree_Lemosi\t2\tDion_Glover\t1\nDion_Glover\t1\tMichael_Weiss\t1\nDoug_Melvin\t1\tGustavo_Cisneros\t1\nDoug_Melvin\t3\tEmma_Nicholson\t1\nDoug_Racine\t1\tMarisol_Breton\t1\nEd_Book\t1\tNur_Jaafar\t1\nEd_Case\t1\tSadam_Hassan\t1\nEdward_Seaga\t1\tGeorge_Roy_Hill\t1\nEdward_Seaga\t1\tSarah_Price\t1\nEileen_Spina\t1\tJeff_Bzdelik\t1\nEkke_Hard_Forberg\t1\tNikki_Reed\t1\nElena_Bereznaya\t1\tLene_Espersen\t1\nElena_Bereznaya\t1\tMario_Lobo_Zagallo\t1\nElena_Bereznaya\t1\tRick_Stansbury\t2\nElisha_Cuthbert\t1\tMariana_Pollack\t2\nEliza_Manningham-Buller\t1\tLawrence_MacAulay\t2\nEric_Clapton\t2\tNiall_Connolly\t1\nEric_Taino\t1\tMichael_Goldrich\t1\nFarida_Ragoonanan\t1\tJorge_Enrique_Jimenez\t1\nFelix_Trinidad\t1\tJoe_Darrell\t1\nFelix_Trinidad\t1\tJustine_Pasek\t4\nFernando_Valenzuela\t1\tLuis_Figo\t3\nFernando_Valenzuela\t1\tNicolas_Macrozonaris\t1\nFilippo_Inzaghi\t1\tMohammed_Al_Hindi\t1\nFilippo_Inzaghi\t1\tShanna_Zolman\t1\nFrancis_Ricciardone\t1\tSven_Goran_Eriksson\t1\nFranz_Beckenbauer\t1\tGerald_Ford\t1\nFranz_Beckenbauer\t2\tRick_Bragg\t1\nGeorge_Foreman\t2\tRalph_Goodale\t1\nGeorge_Pataki\t1\tJames_Dingemans\t1\nGeorge_Pataki\t2\tMasahiko_Nagasawa\t2\nGeorge_Plimpton\t1\tXimena_Bohorquez\t1\nGerald_Ford\t1\tKurt_Budke\t1\nGerald_Ford\t1\tLi_Peng\t1\nGiselle_Estefania_Tavarelli\t1\tJohn_Sununu\t1\nGiulio_Andreotti\t1\tKurt_Russell\t2\nGiulio_Andreotti\t1\tMichael_Denzel\t1\nGonzalo_Sanchez_de_Lozada\t3\tShannyn_Sossamon\t1\nGraciano_Rocchigiani\t1\tJuan_Jose_Lucas\t1\nGregory_Geoffroy\t1\tSybille_Schmid\t1\nGregory_Geoffroy\t2\tKosuke_Kitajima\t1\nGregory_Geoffroy\t2\tWycliffe_Grousbeck\t1\nGuangdong_Ou_Guangyuan\t1\tLi_Ruihuan\t1\nGuangdong_Ou_Guangyuan\t1\tNicole\t1\nGustavo_Cisneros\t1\tSteve_Blake\t1\nGustavo_Noboa\t1\tLea_Fastow\t2\nHabib_Hisham\t1\tPat_Rochester\t1\nHabib_Hisham\t1\tPaul_Wilson\t1\nHabib_Rizieq\t1\tOlivia_Newton-John\t2\nHabib_Rizieq\t3\tKenny_Chesney\t1\nHal_Sutton\t2\tKellie_Coffey\t1\nHarland_Braun\t1\tKathryn_Tucker\t1\nHassanal_Bolkiah\t1\tMichael_Leavitt\t1\nHestrie_Cloette\t1\tNicholas_Byron\t2\nHitoshi_Tanaka\t1\tRamon_Ponce_de_Leon\t1\nHoracio_Julio_Pina\t1\tZaini_Abdullah\t1\nHuang_Suey-Sheng\t1\tLucrecia_Orozco\t1\nHuang_Suey-Sheng\t1\tPaul_Cerjan\t1\nHuang_Suey-Sheng\t1\tRobinson_Stevenin\t1\nIan_Knop\t1\tMichel_Minard\t1\nIlan_Ramon\t3\tTatiana_Kennedy_Schlossberg\t1\nIon_Tiriac\t1\tLawrence_MacAulay\t1\nIsmail_Abu_Shanab\t1\tMichael_Denzel\t1\nIsmail_Abu_Shanab\t1\tRebecca_Romijn-Stamos\t1\nJack_Welch\t1\tKeizo_Yamada\t1\nJames_Dingemans\t1\tRobert_Duvall\t5\nJames_Dingemans\t1\tWilliam_Morrow\t1\nJamie_Lee_Curtis\t1\tWilliam_Joppy\t1\nJamie_Martin\t1\tPatrick_Ewing\t1\nJan_Bjoerklund\t1\tLi_Ruihuan\t1\nJan_Paul_Miller\t1\tParadorn_Srichaphan\t8\nJay_Garner\t3\tReggie_Sanders\t1\nJeff_Bzdelik\t1\tZach_Parise\t1\nJerry_Oliver\t1\tRudolf_Schuster\t1\nJerry_Oliver\t1\tStefaan_Declerk\t1\nJerry_Sloan\t1\tJulianne_Moore\t9\nJerry_Sloan\t1\tKeiko_Sofia_Fujimori\t1\nJerry_Sloan\t1\tNikki_Cascone\t1\nJim_Anderson\t1\tJose_Luis_Santiago_Vasconcelos\t1\nJim_Anderson\t1\tMikhail_Wehbe\t1\nJoaquim_Levy\t1\tJudy_Vassar\t1\nJoe_Leonard\t1\tKristen_Rivera\t1\nJohn_Baldacci\t1\tNona_Gaye\t1\nJohn_Baldacci\t1\tShia_LaBeouf\t1\nJohn_Elway\t1\tMahmoud_Diyab_al-Ahmed\t1\nJohn_Kerry\t9\tRaja_Ibrahim\t1\nJohn_Kerry\t14\tPat_Rochester\t1\nJohn_Lisowski\t1\tMichelle_Kwan\t1\nJohn_Malkovich\t2\tParadorn_Srichaphan\t7\nJohn_Malkovich\t3\tMona_Locke\t1\nJohn_Malkovich\t3\tRichard_Palmer\t1\nJohn_McCallum\t1\tOliver_Phelps\t1\nJohn_McCallum\t2\tRick_Bragg\t1\nJohn_McEnroe\t2\tShane_Mosley\t1\nJohn_Prescott\t1\tWill_Ofenheusle\t1\nJohnnie_Lynn\t1\tLarry_Coker\t4\nJohnnie_Lynn\t1\tRichard_Palmer\t1\nJohnny_Unitas\t1\tMark_Foley\t1\nJonathan_Karsh\t1\tSamantha_Ledster\t1\nJoxel_Garcia\t1\tLena_Olin\t1\nJoy_Bryant\t1\tRichard_Chamberlain\t1\nJulianne_Moore\t4\tShia_LaBeouf\t1\nJulio_Iglesias_Jr\t1\tRamon_Ponce_de_Leon\t1\nJustin_Timberlake\t1\tSuzanne_Somers\t1\nKathleen_Glynn\t2\tSusilo_Bambang_Yudhoyono\t1\nKathryn_Morris\t1\tMinnie_Driver\t2\nKathryn_Tucker\t1\tStella_McCartney\t1\nKatie_Couric\t1\tSanjay_Gupta\t1\nKeiko_Sofia_Fujimori\t1\tSureyya_Ayhan\t1\nKellie_Coffey\t1\tTodd_Petit\t1\nKenny_Chesney\t1\tSteve_Coogan\t1\nKevin_Tarrant\t1\tMarisol_Breton\t1\nKristen_Rivera\t1\tValdas_Adamkus\t2\nKurt_Russell\t2\tMahmoud_Diyab_al-Ahmed\t1\nKurt_Tanabe\t1\tWilliam_Jackson\t1\nKyle_McLaren\t1\tSofia_Milos\t1\nKyle_McLaren\t1\tWill_Ofenheusle\t1\nKyle_Shewfelt\t1\tLarry_Coker\t2\nLawrence_Foley\t1\tRachel_Wadsworth\t1\nLea_Fastow\t1\tUday_Hussein\t1\nLesia_Burlak\t1\tNur_Jaafar\t1\nLori_Berenson\t1\tRudolf_Schuster\t1\nLucio_Angulo\t1\tSarah_Price\t1\nLucio_Gutierrez\t10\tPedro_Malan\t5\nMargaret_Hasley\t1\tMichael_Denzel\t1\nMark_Redman\t1\tStephen_Funk\t1\nMark_Salter\t1\tShanna_Zolman\t1\nMartin_Luther_King_III\t1\tMaryn_McKenna\t1\nMary_Bono\t1\tTodd_Wike\t1\nMatt_LeBlanc\t1\tRobert_Redford\t2\nMauro_Viza\t1\tWilliam_Jackson\t1\nMax_Baucus\t1\tParadorn_Srichaphan\t5\nMax_Baucus\t1\tYossi_Beilin\t2\nMeles_Zenawi\t1\tNawabzada_Nasrullah_Khan\t1\nMelissa_Mulloy\t1\tPaula_Abdul\t1\nMelissa_Mulloy\t1\tRoger_Lyons\t1\nMichael_Chiklis\t1\tMohammed_Al_Hindi\t1\nMichael_Chiklis\t1\tSteve_Rush\t1\nMichael_Doleac\t1\tNur_Jaafar\t1\nMichael_Goldrich\t1\tSuzanne_Somers\t1\nMichael_Kahn\t1\tRick_Caruso\t1\nMichel_Minard\t1\tSuzanne_Gaudet\t1\nMichelle_Bachelet\t1\tSami_Al-Arian\t1\nMiguel_Angel_Rodriguez\t1\tSasha_Cohen\t1\nMike_Bryan\t1\tShanna_Zolman\t1\nMike_Montgomery\t1\tRay_Lewis\t1\nMilton_Wynants\t1\tStuart_Townsend\t1\nMiyako_Miyazaki\t2\tMunir_Akram\t2\nMorris_Dees\t1\tShamai_Leibowitz\t1\nMorris_Dees\t1\tSuzie_McConnell_Serio\t1\nNathalie_Gagnon\t1\tRichard_Reid\t1\nNicklas_Lidstrom\t1\tNorman_Jewison\t1\nNicklas_Lidstrom\t1\tSadie_Frost\t3\nNicole_Hiltz\t1\tZaini_Abdullah\t1\nNona_Gaye\t1\tPaul_Cerjan\t1\nOscar_Bolanos\t1\tPhil_Donahue\t1\nOscar_Bolanos\t1\tTatiana_Kennedy_Schlossberg\t1\nPascal_Quignard\t3\tPatrick_Ewing\t2\nPat_Rochester\t1\tPhoenix_Chang\t1\nPat_Rochester\t1\tWill_Ofenheusle\t1\nPaul_Farley\t1\tPlaton_Lebedev\t1\nPaula_Abdul\t1\tRobert_Vowler\t1\nPharrell_Williams\t1\tTyrone_Medley\t1\nPhoenix_Chang\t1\tPlaton_Lebedev\t1\nRachel_Wadsworth\t1\tRichard_Palmer\t1\nRaymond_Odierno\t1\tRichard_Reid\t1\nReggie_Sanders\t1\tRick_Santorum\t2\nRichard_Chamberlain\t1\tSteve_Patterson\t1\nRichard_Ward\t1\tSteve_Redgrave\t1\nRobert_Vowler\t1\tTab_Baldwin\t1\nRoy_Rogers\t1\tSteven_Feldman\t1\nScott_Rolen\t1\tWilliam_Murabito\t1\nSofia_Milos\t1\tSteve_Nash\t3\nSofia_Milos\t1\tWill_Ofenheusle\t1\nSonja_Kesselschlager\t1\tTim_Robbins\t3\nTakeo_Hiranuma\t1\tTy_Votaw\t1\nTed_Washington\t1\tXimena_Bohorquez\t1\nTy_Votaw\t1\tWilliam_Webster\t1\nAdrian_McPherson\t1\t2\nAl_Davis\t1\t2\nAl_Gore\t2\t6\nAl_Gore\t4\t6\nAlan_Greenspan\t1\t2\nAlan_Greenspan\t1\t5\nAlan_Greenspan\t3\t4\nAlastair_Campbell\t1\t5\nAlastair_Campbell\t2\t4\nAlexander_Downer\t1\t2\nAlexander_Downer\t1\t3\nAlexander_Downer\t1\t4\nAlexander_Downer\t3\t4\nAlice_Fisher\t1\t2\nAlison_Lohman\t1\t2\nAlvaro_Silva_Calderon\t1\t2\nAlvaro_Silva_Calderon\t1\t3\nAlvaro_Uribe\t7\t20\nAlvaro_Uribe\t8\t25\nAlvaro_Uribe\t12\t13\nAlvaro_Uribe\t20\t28\nAnders_Ebbeson\t2\t3\nAndrew_Bunner\t1\t2\nAnibal_Ibarra\t1\t3\nAntonio_Trillanes\t1\t3\nAntonio_Trillanes\t2\t3\nAsa_Hutchinson\t1\t2\nBarbara_Walters\t1\t3\nBarbara_Walters\t1\t4\nBarbara_Walters\t3\t4\nBen_Howland\t1\t2\nBen_Howland\t1\t3\nBen_Howland\t3\t4\nBenazir_Bhutto\t1\t4\nBenazir_Bhutto\t2\t3\nBenazir_Bhutto\t2\t4\nBill_Simon\t5\t9\nBill_Simon\t11\t15\nBilly_Sollie\t1\t2\nBoris_Berezovsky\t1\t2\nBrooke_Shields\t1\t2\nBulent_Ecevit\t1\t4\nBulent_Ecevit\t1\t5\nBulent_Ecevit\t2\t6\nBulent_Ecevit\t4\t6\nCandie_Kung\t1\t2\nCandie_Kung\t1\t4\nCarlo_Ancelotti\t1\t2\nCarlo_Ancelotti\t2\t3\nCarlos_Moya\t8\t17\nCarlos_Moya\t10\t18\nCarlos_Vives\t1\t4\nCarlos_Vives\t2\t4\nCarson_Daly\t1\t2\nCate_Blanchett\t1\t2\nCate_Blanchett\t1\t3\nCate_Blanchett\t1\t4\nCate_Blanchett\t2\t3\nCate_Blanchett\t2\t4\nChok_Tong_Goh\t1\t2\nChris_Byrd\t1\t2\nChris_Cooper\t1\t2\nChris_Tucker\t1\t2\nChristine_Gregoire\t1\t4\nChristine_Gregoire\t2\t3\nChristine_Gregoire\t2\t4\nChristopher_Patten\t1\t2\nClint_Eastwood\t1\t4\nClint_Eastwood\t1\t6\nConstance_Marie\t1\t2\nConstance_Marie\t1\t3\nDennis_Hastert\t2\t3\nDennis_Hastert\t3\t6\nDennis_Hastert\t4\t6\nDennis_Hastert\t5\t6\nDolly_Parton\t1\t2\nDoug_Duncan\t1\t2\nEdward_Kennedy\t1\t2\nEdward_Kennedy\t2\t3\nEdward_Said\t1\t2\nElena_Bovina\t1\t2\nElena_Bovina\t1\t3\nElena_Bovina\t2\t3\nEliane_Karp\t1\t3\nEliane_Karp\t2\t3\nEliane_Karp\t2\t4\nEliane_Karp\t3\t4\nElvis_Presley\t1\t2\nErika_Harold\t1\t3\nErika_Harold\t2\t3\nErika_Harold\t3\t4\nErika_Harold\t4\t5\nErnie_Els\t1\t3\nErnie_Els\t1\t4\nErnie_Els\t2\t3\nFranco_Dragone\t1\t2\nFrank_Solich\t1\t4\nFrank_Solich\t2\t5\nFrank_Solich\t3\t4\nGabriel_Batistuta\t1\t2\nGary_Carter\t1\t2\nGary_Carter\t1\t3\nGary_Doer\t1\t2\nGary_Doer\t2\t3\nGeorge_Tenet\t1\t2\nGeorge_Voinovich\t1\t3\nGeorge_Voinovich\t2\t3\nGeorgi_Parvanov\t1\t2\nGoldie_Hawn\t1\t7\nGoldie_Hawn\t2\t3\nGoldie_Hawn\t3\t7\nGoldie_Hawn\t6\t7\nGoran_Persson\t1\t2\nGro_Harlem_Brundtland\t1\t2\nGuillaume_Soro\t1\t2\nGwyneth_Paltrow\t1\t5\nGwyneth_Paltrow\t1\t6\nGwyneth_Paltrow\t2\t6\nGwyneth_Paltrow\t3\t6\nHee-Won_Han\t1\t2\nHerb_Sendek\t1\t3\nHerb_Sendek\t3\t4\nHoward_Smith\t1\t2\nHugh_Grant\t5\t8\nHugh_Grant\t6\t9\nJack_Straw\t25\t28\nJames_Franco\t1\t2\nJames_Ivory\t1\t2\nJames_Schultz\t1\t2\nJames_Traficant\t1\t2\nJames_Traficant\t2\t3\nJan_Ullrich\t1\t4\nJan_Ullrich\t2\t6\nJan_Ullrich\t3\t6\nJane_Pauley\t1\t2\nJason_Jennings\t1\t2\nJavier_Weber\t1\t2\nJennifer_Rodriguez\t1\t2\nJeong_Se-hyun\t2\t6\nJeong_Se-hyun\t3\t7\nJeong_Se-hyun\t6\t8\nJeong_Se-hyun\t7\t9\nJeong_Se-hyun\t8\t9\nJo_Dee_Messina\t1\t2\nJoe_Lieberman\t8\t11\nJoe_Lieberman\t9\t10\nJoe_Mantello\t1\t2\nJohn_Allen_Muhammad\t2\t9\nJohn_Allen_Muhammad\t5\t7\nJohn_Allen_Muhammad\t6\t10\nJohn_Blaney\t1\t2\nJohn_Brady\t1\t2\nJohn_Howard\t5\t15\nJohn_Howard\t12\t17\nJohnny_Tapia\t1\t2\nJohnny_Tapia\t2\t3\nJorge_Valdano\t1\t2\nJoseph_Deiss\t1\t3\nJunichiro_Koizumi\t1\t53\nJunichiro_Koizumi\t26\t55\nJunichiro_Koizumi\t29\t45\nKate_Capshaw\t1\t2\nKathryn_Bigelow\t1\t2\nKevin_Spacey\t1\t2\nKevin_Spacey\t1\t3\nKim_Ryong-sung\t6\t8\nKim_Ryong-sung\t8\t11\nKlaus_Zwickel\t1\t2\nKristen_Breitweiser\t2\t3\nLaila_Ali\t2\t3\nLarry_Brown\t1\t3\nLarry_Brown\t2\t4\nLarry_Brown\t2\t7\nLarry_Brown\t4\t7\nLarry_Brown\t6\t7\nLarry_Johnson\t1\t2\nLars_Von_Trier\t1\t2\nLars_Von_Trier\t2\t3\nLeander_Paes\t1\t2\nLiam_Neeson\t1\t3\nLiam_Neeson\t2\t3\nLino_Oviedo\t1\t3\nLino_Oviedo\t2\t3\nLudivine_Sagnier\t1\t3\nLudivine_Sagnier\t3\t4\nLynne_Cheney\t1\t2\nLynne_Cheney\t2\t3\nMaggie_Smith\t1\t2\nMarcelo_Salas\t1\t2\nMariangel_Ruiz_Torrealba\t1\t2\nMarisa_Tomei\t1\t2\nMary_Steenburgen\t1\t2\nMel_Brooks\t1\t2\nMel_Gibson\t1\t2\nMian_Khursheed_Mehmood_Kasuri\t2\t3\nMian_Khursheed_Mehmood_Kasuri\t3\t4\nMichael_Moore\t1\t2\nMichael_Moore\t2\t3\nMichel_Duclos\t1\t2\nMichelle_Pfeiffer\t1\t2\nMireya_Moscoso\t2\t3\nMireya_Moscoso\t2\t5\nMireya_Moscoso\t4\t5\nNabil_Shaath\t1\t3\nNabil_Shaath\t2\t3\nNaomi_Watts\t1\t18\nNaomi_Watts\t6\t9\nNaomi_Watts\t13\t18\nNatalie_Cole\t1\t3\nNatalie_Cole\t2\t3\nNathalie_Baye\t1\t2\nNathalie_Baye\t1\t4\nNathalie_Baye\t2\t4\nNathalie_Baye\t3\t4\nOleksandr_Moroz\t1\t2\nOscar_Elias_Biscet\t1\t2\nOswaldo_Paya\t1\t3\nOswaldo_Paya\t3\t4\nPatricia_Clarkson\t1\t2\nPatricia_Clarkson\t1\t3\nPatricia_Clarkson\t2\t3\nPatricia_Clarkson\t2\t4\nPatrick_Roy\t1\t2\nPaul-Henri_Mathieu\t1\t2\nPaul-Henri_Mathieu\t1\t3\nPaul_Byrd\t1\t2\nPaul_Kagame\t1\t2\nPeter_Costello\t1\t2\nPeter_Greenaway\t1\t2\nPrince_Naruhito\t1\t2\nPrince_Naruhito\t1\t3\nPrince_Naruhito\t2\t3\nPrincess_Masako\t1\t2\nPupi_Avati\t2\t3\nQueen_Latifah\t1\t3\nQueen_Latifah\t2\t4\nQueen_Latifah\t3\t4\nRachel_Griffiths\t2\t3\nRalph_Firman\t1\t2\nRalph_Klein\t1\t2\nRanil_Wickremasinghe\t2\t3\nRick_Pitino\t1\t3\nRick_Pitino\t2\t4\nRick_Pitino\t3\t4\nRicky_Martin\t1\t2\nRita_Moreno\t1\t2\nRobert_De_Niro\t1\t4\nRobert_De_Niro\t3\t6\nRobert_Kocharian\t4\t5\nRoberto_Marinho\t2\t3\nRoger_Moore\t3\t5\nRon_Dittemore\t1\t2\nRon_Dittemore\t1\t3\nRon_Dittemore\t4\t6\nRudolph_Giuliani\t1\t20\nRudolph_Giuliani\t2\t5\nRudolph_Giuliani\t3\t20\nRudolph_Giuliani\t4\t17\nRudolph_Giuliani\t15\t20\nRussell_Simmons\t1\t2\nRussell_Simmons\t1\t4\nRussell_Simmons\t2\t4\nSean_Astin\t1\t3\nSean_Astin\t2\t3\nShaukat_Aziz\t1\t2\nSilvio_Fernandez\t1\t2\nSophia_Loren\t1\t2\nSophia_Loren\t1\t3\nSophia_Loren\t1\t7\nSophia_Loren\t6\t7\nStellan_Skarsgard\t1\t2\nTamara_Brooks\t1\t2\nThomas_Fargo\t1\t2\nThomas_Fargo\t1\t3\nThomas_Fargo\t2\t3\nThomas_Fargo\t2\t4\nThomas_Fargo\t3\t4\nTim_Allen\t2\t3\nTim_Allen\t3\t4\nTony_Shalhoub\t1\t2\nTony_Shalhoub\t1\t3\nTracy_McGrady\t1\t2\nVicente_Fernandez\t2\t3\nVicente_Fernandez\t4\t5\nVince_Gill\t1\t2\nWolfgang_Schuessel\t1\t4\nWolfgang_Schuessel\t3\t4\nWu_Yi\t1\t2\nWu_Yi\t1\t3\nWu_Yi\t2\t3\nYao_Ming\t2\t4\nYao_Ming\t5\t6\nYao_Ming\t5\t8\nYao_Ming\t6\t7\nYoriko_Kawaguchi\t3\t5\nYu_Shyi-kun\t1\t3\nYu_Shyi-kun\t1\t4\nYu_Shyi-kun\t2\t3\nZhang_Wenkang\t1\t2\nZinedine_Zidane\t4\t6\nAbdullah_Nasseef\t1\tBruce_Paltrow\t1\nAbdullah_Nasseef\t1\tHoward_Smith\t2\nAbdullah_Nasseef\t1\tJan_De_Bont\t1\nAbdullah_Nasseef\t1\tJim_Nochols\t1\nAbdullah_Nasseef\t1\tOleg_Romantsev\t1\nAdam_Kennedy\t1\tCharlie_Sheen\t1\nAdrian_McPherson\t2\tEduardo_Chillida\t1\nAl_Davis\t1\tJulian_Fantino\t1\nAlan_Greenspan\t4\tKent_McCord\t1\nAlastair_Campbell\t4\tLi_Ka-shing\t1\nAlexa_Vega\t1\tTony_Shalhoub\t1\nAlexander_Downer\t2\tZeljko_Rebraca\t1\nAlexander_Downer\t3\tLuis_Berrondo\t1\nAlexandra_Pelosi\t1\tKen_Kutaragi\t1\nAlexandre_Herchcovitch\t1\tKaren_Clarkson\t1\nAlice_Fisher\t1\tGene_Sauers\t1\nAlicia_Witt\t1\tJorge_Moreno\t1\nAlicia_Witt\t1\tLino_Oviedo\t1\nAllan_Wagner\t1\tLarry_Campbell\t1\nAllan_Wagner\t1\tRita_Moreno\t1\nAlvaro_Silva_Calderon\t2\tStepan_Demirchian\t1\nAlvaro_Uribe\t14\tPatricia_Clarkson\t1\nAna_Sebastiao\t1\tMarcos_Cafu\t1\nAna_Sebastiao\t1\tRaza_Rabbani\t1\nAndrea_De_Cruz\t1\tDionne_Warwick\t1\nAndrea_De_Cruz\t1\tIsmail_Cem\t1\nAndrea_De_Cruz\t1\tNatalya_Sazanovich\t1\nAndrea_De_Cruz\t1\tYoon_Young-kwan\t1\nAndres_Manuel_Lopez_Obrador\t1\tJim_Parque\t1\nAndres_Manuel_Lopez_Obrador\t1\tNorman_Mineta\t1\nAndrew_Bunner\t2\tOscar_Elias_Biscet\t2\nAndrew_Weissmann\t1\tErnie_Els\t2\nAndy_Warhol\t1\tEdith_Masai\t1\nAndy_Warhol\t1\tPaul-Henri_Mathieu\t2\nAnibal_Ibarra\t2\tDavid_Przybyszewski\t1\nAnthony_Ervin\t1\tJuan_Roman_Carrasco\t1\nAntonio_Elias_Saca\t1\tPeter_Holmberg\t1\nAntonio_Elias_Saca\t1\tThomas_Fargo\t4\nAntonio_Trillanes\t1\tKatrin_Cartlidge\t1\nAntonio_Trillanes\t3\tTerry_Gilliam\t1\nAsa_Hutchinson\t2\tGary_Sinise\t1\nAscencion_Barajas\t1\tChris_Hernandez\t1\nAshley_Judd\t1\tJoan_Jett\t1\nAshley_Postell\t1\tCassandra_Heise\t1\nAshley_Postell\t1\tTony_Clement\t1\nAshraf_Ghani\t1\tBoris_Berezovsky\t1\nAshraf_Ghani\t1\tQian_Qichen\t1\nAsif_Ali_Zardari\t1\tSteny_Hoyer\t1\nAssad_Ahmadi\t1\tPercy_Gibson\t1\nBarbara_Walters\t1\tJewel_Howard-Taylor\t1\nBarbara_Walters\t1\tPeter_Greenaway\t1\nBarry_Williams\t1\tWang_Fei\t1\nBenazir_Bhutto\t4\tJane_Pauley\t2\nBenazir_Bhutto\t5\tKaren_Clarkson\t1\nBijan_Darvish\t1\tFranco_Dragone\t1\nBijan_Darvish\t2\tFrank_Taylor\t1\nBilal_Erdogan\t1\tLubomir_Zaoralek\t1\nBill_Self\t1\tYang_Jianli\t1\nBill_Simon\t1\tEdward_Said\t2\nBilly_Gilman\t1\tHoward_Smith\t2\nBilly_Sollie\t1\tMark_Swartz\t1\nBilly_Sollie\t2\tHussein_Malik\t1\nBlas_Ople\t1\tEvan_Marriott\t1\nBlas_Ople\t1\tFelipe_Fernandez\t1\nBlas_Ople\t1\tPeter_Costello\t1\nBob_Cantrell\t1\tGerard_Kleisterlee\t1\nBob_Cantrell\t1\tMary_Landrieu\t3\nBob_Goldman\t1\tLeigh_Winchell\t1\nBob_Goldman\t1\tMaggie_Smith\t1\nBoris_Berezovsky\t2\tLeander_Paes\t1\nBrad_Gushue\t1\tJohannes_Rau\t1\nBrad_Miller\t1\tIrina_Lobacheva\t1\nBrad_Miller\t1\tPercy_Gibson\t1\nBrenda_van_Dam\t1\tNorbert_van_Heyst\t1\nBrian_Cashman\t1\tDelphine_Chuillot\t1\nBrian_Cashman\t1\tRussell_Simmons\t3\nBrian_Cook\t1\tMatt_Welsh\t1\nBruno_Junquiera\t1\tOscar_DLeon\t1\nBulent_Ecevit\t6\tEduardo_Romero\t1\nBulent_Ecevit\t6\tGilberto_Simoni\t1\nCandie_Kung\t1\tSteve_Allan\t1\nCarlo_Ancelotti\t1\tJohn_Tyson\t1\nCarlos_Vives\t2\tRandy_Johnson\t1\nCaroline_Dhavernas\t1\tEvgeni_Plushenko\t1\nCaroline_Dhavernas\t1\tJeremy_Fogel\t1\nCarson_Daly\t1\tJohn_Moe\t1\nCarson_Daly\t1\tTracy_Wyle\t1\nCassandra_Heise\t1\tShaukat_Aziz\t2\nCate_Blanchett\t3\tGina_Centrello\t1\nCate_Blanchett\t3\tRyan_Goodman\t1\nCatherine_Donkers\t1\tEminem\t1\nCedric_Benson\t1\tMarcus_Allen\t1\nCedric_Benson\t1\tRobert_Lee_Yates_Jr\t1\nCedric_Benson\t1\tStacy_Nelson\t1\nChistian_Stahl\t1\tEliane_Karp\t1\nChris_Cooper\t2\tIrfan_Ahmed\t1\nChris_Cooper\t2\tRick_Bland\t1\nChris_Hernandez\t1\tMauricio_Pochetino\t1\nChris_Hernandez\t1\tTonga\t1\nChris_Hernandez\t1\tWolfgang_Schuessel\t1\nChris_Tucker\t2\tJennifer_Pena\t1\nChris_Tucker\t2\tTakuma_Sato\t1\nChris_Whitney\t1\tTom_Scully\t1\nChristine_Gregoire\t4\tRobert_Lee_Yates_Jr\t1\nChristine_Gregoire\t4\tWang_Hailan\t1\nChristine_Rau\t1\tJerry_Hall\t1\nChristine_Rau\t1\tMel_Brooks\t1\nChristopher_Russell\t1\tColleen_OClair\t1\nChristopher_Whittle\t1\tFelipe_Fernandez\t1\nColleen_OClair\t1\tTom_Hanusik\t1\nCurtis_Rodriguez\t1\tJohn_Blaney\t2\nCurtis_Rodriguez\t1\tKathleen_Kennedy_Townsend\t3\nDale_Bosworth\t1\tFrank_Taylor\t1\nDale_Bosworth\t1\tVladimir_Golovlyov\t1\nDan_Quayle\t1\tJim_Ryan\t1\nDan_Quayle\t1\tNick_Turner\t1\nDan_Quayle\t1\tWilliam_Umbach\t1\nDanny_Morgan\t1\tJeff_George\t1\nDanny_Morgan\t1\tJohn_Allen_Muhammad\t10\nDarla_Moore\t1\tPaul_Johnson\t1\nDarrell_Royal\t1\tLouis_Van_Gaal\t1\nDave_McGinnis\t1\tMichel_Therrien\t1\nDavid_Przybyszewski\t1\tElena_Bovina\t2\nDelphine_Chuillot\t1\tJim_Parque\t1\nDemetrin_Veal\t1\tRobert_Hanssen\t1\nDennis_Hastert\t5\tLubomir_Zaoralek\t1\nDewayne_White\t1\tJoe_DeLamielleure\t1\nDick_Posthumus\t1\tJeff_George\t1\nDick_Posthumus\t1\tJim_Wong\t1\nDin_Samsudin\t1\tPupi_Avati\t2\nDionne_Warwick\t1\tJanine_Pietsch\t1\nDominique_Perben\t1\tOsmond_Smith\t1\nDoug_Duncan\t1\tKevin_Spacey\t2\nDoug_Duncan\t2\tJohn_Allen_Muhammad\t2\nEddy_Hartenstein\t1\tLyudmila_Putin\t1\nEddy_Hartenstein\t1\tMatthias_Sammer\t1\nEddy_Hartenstein\t1\tSabah_Al-Ahmad_Al-Jaber_Al-Sabah\t1\nEduardo_Chillida\t1\tStephen_Crampton\t1\nEduardo_Romero\t1\tRobert_Kocharian\t5\nEdward_Greenspan\t1\tRoy_Halladay\t1\nEdward_Greenspan\t1\tSidney_Poitier\t1\nEdward_Kennedy\t1\tMathilda_Karel_Spak\t1\nEdward_Kennedy\t2\tJennifer_Pena\t1\nEdward_Said\t1\tFrank_Abagnale_Jr\t1\nEminem\t1\tWolfgang_Clement\t1\nEnrique_Bolanos\t4\tJanine_Pietsch\t1\nEnrique_Bolanos\t4\tLiam_Neeson\t2\nErnie_Els\t2\tMarcus_Allen\t1\nEvgeni_Plushenko\t1\tQueen_Sofia\t1\nEvgeni_Plushenko\t1\tRiek_Blanjaar\t1\nFranco_Dragone\t2\tLouis_Van_Gaal\t1\nFranco_Frattini\t1\tIrina_Lobacheva\t1\nFrank_Abagnale_Jr\t1\tNate_Hybl\t1\nFrank_Shea\t1\tRob_Moore\t1\nFrank_Taylor\t1\tJason_Jennings\t1\nGabriel_Batistuta\t1\tPeter_Costello\t1\nGabriel_Jorge_Ferreia\t1\tZulfiqar_Ahmed\t1\nGary_Doer\t3\tWang_Hailan\t1\nGary_Sinise\t1\tRoy_Halladay\t1\nGene_Hackman\t1\tQueen_Noor\t1\nGene_Sauers\t1\tGina_Centrello\t1\nGeoff_Dixon\t1\tJean_Todt\t1\nGeorge_Allen\t1\tRoy_Halladay\t1\nGeorge_Allen\t1\tWan_Yanhai\t1\nGeorge_Harrison\t1\tRobert_Lee_Yates_Jr\t1\nGeorgi_Parvanov\t1\tLuis_Fonsi\t1\nGianni_Agnelli\t1\tMarco_Irizarry\t1\nGilberto_Simoni\t1\tJulio_Cesar_Chavez\t1\nGong_Ruina\t1\tHong_Myung\t1\nGong_Ruina\t1\tQian_Qichen\t1\nGro_Harlem_Brundtland\t2\tTurner_Gill\t1\nHector_Grullon\t1\tJeong_Se-hyun\t9\nHenk_Bekedam\t1\tKoichi_Haraguchi\t1\nHenk_Bekedam\t1\tManuel_Gehring\t1\nHenk_Bekedam\t1\tMichael_Kirby\t1\nHiroki_Gomi\t1\tKenneth_Cooper\t1\nHiroki_Gomi\t1\tSophia_Loren\t2\nIrina_Lobacheva\t1\tSteve_Allan\t1\nIsmail_Cem\t1\tLinda_Amicangioli\t1\nJack_Osbourne\t1\tKent_McCord\t1\nJack_Straw\t1\tManuel_Gehring\t1\nJack_Straw\t3\tNorman_Mineta\t1\nJames_Ballenger\t1\tRaza_Rabbani\t1\nJames_Coviello\t1\tJudith_Nathan\t1\nJames_Coviello\t1\tRobert_F_Kennedy_Jr\t1\nJames_Morris\t2\tSilvio_Fernandez\t2\nJames_Schultz\t1\tTim_Curley\t1\nJames_W_Kennedy\t1\tJohn_Connolly\t1\nJames_W_Kennedy\t1\tToutai_Kefu\t1\nJames_Williams\t1\tPhillip_Seymor_Hoffmann\t1\nJames_Williams\t1\tShaun_Pollock\t1\nJan_Ullrich\t3\tJavier_Weber\t1\nJane_Menelaus\t1\tJunichiro_Koizumi\t42\nJane_Menelaus\t1\tSophia_Loren\t1\nJason_Petty\t1\tMayumi_Moriyama\t1\nJean_Todt\t1\tRoger_Etchegaray\t1\nJennifer_Pena\t1\tSonia_Lopez\t1\nJennifer_Pena\t1\tTony_LaRussa\t1\nJennifer_Rodriguez\t1\tTerry_Gilliam\t1\nJennifer_Rodriguez\t2\tJoanna_Poitier\t1\nJennifer_Rodriguez\t2\tTony_Fernandes\t1\nJerome_Golmard\t1\tKristin_Chenoweth\t1\nJewel_Howard-Taylor\t1\tKen_Kutaragi\t1\nJim_Parque\t1\tMichael_Adams\t1\nJim_Parque\t1\tRachel_Leigh_Cook\t1\nJim_Ryan\t1\tLuis_Berrondo\t1\nJimmy_Gobble\t1\tRobert_De_Niro\t5\nJoan_Collins\t1\tZydrunas_Ilgauskas\t1\nJoan_Jett\t1\tKevin_James\t1\nJoanna_Poitier\t1\tMichael_Moore\t1\nJoe_Lieberman\t10\tJoe_Mantello\t1\nJohannes_Rau\t1\tOleksandr_Moroz\t1\nJohn_Connolly\t1\tMel_Gibson\t1\nJohn_Connolly\t1\tMichael_Moore\t3\nJohn_Connolly\t1\tNorman_Mineta\t1\nJohn_Connolly\t1\tUzi_Even\t1\nJohn_Cruz\t1\tSean_Astin\t3\nJohn_Cruz\t1\tSteven_Briggs\t1\nJohn_Hartson\t1\tOscar_Elias_Biscet\t2\nJoseph_Deiss\t1\tTony_Fernandes\t1\nJoseph_Lopez\t1\tRick_Pitino\t1\nJulian_Fantino\t1\tQuin_Snyder\t1\nJulio_Cesar_Chavez\t1\tTom_Brennan\t1\nJunichi_Inamoto\t1\tOleg_Romantsev\t1\nJunichiro_Koizumi\t20\tTony_Fernandes\t1\nKaren_Clarkson\t1\tKristen_Breitweiser\t3\nKarol_Kucera\t1\tQian_Qichen\t1\nKarol_Kucera\t1\tTurner_Gill\t1\nKatrin_Cartlidge\t1\tTony_LaRussa\t1\nKeith_Osik\t1\tPupi_Avati\t1\nKenneth_Cooper\t1\tNorman_Mineta\t1\nKent_McCord\t1\tNatasha_Henstridge\t1\nKevin_James\t1\tRoy_Halladay\t1\nKevin_James\t1\tSuzanne_Haik_Terrell\t1\nKevin_James\t1\tYang_Jianli\t1\nKevin_Spacey\t2\tRay_Evernham\t1\nKoji_Uehara\t1\tRob_Moore\t1\nKrishna_Bhadur_Mahara\t1\tPeter_Holmberg\t1\nKrishna_Bhadur_Mahara\t1\tSilvio_Fernandez\t2\nKristen_Breitweiser\t1\tTatiana_Shchegoleva\t1\nLaila_Ali\t3\tTony_Fernandes\t1\nLarry_Johnson\t1\tTerry_Gilliam\t1\nLarry_Johnson\t2\tMarc_Racicot\t1\nLarry_Johnson\t2\tTom_Hanusik\t1\nLars_Von_Trier\t1\tZhang_Wenkang\t2\nLeander_Paes\t1\tRalph_Firman\t1\nLeo_Ramirez\t1\tSabah_Al-Ahmad_Al-Jaber_Al-Sabah\t1\nLeonardo_Del_Vecchio\t1\tMaggie_Smith\t1\nLeonardo_Del_Vecchio\t1\tTatiana_Shchegoleva\t1\nLiam_Neeson\t1\tPaul_Kagame\t2\nLokendra_Bahadur_Chand\t1\tSteffeny_Holtz\t1\nLouis_Van_Gaal\t1\tNatasha_Henstridge\t1\nLubomir_Zaoralek\t1\tLuis_Berrondo\t1\nLubomir_Zaoralek\t1\tWilliam_Umbach\t1\nLuis_Berrondo\t1\tRita_Moreno\t2\nLuis_Fonsi\t1\tOscar_DLeon\t1\nLuis_Fonsi\t1\tSteven_Briggs\t1\nLuis_Rosario_Huertas\t1\tMary_Steenburgen\t2\nMakiko_Tanaka\t1\tPeter_Greenaway\t1\nManijeh_Hekmat\t1\tRoger_Winter\t1\nManijeh_Hekmat\t1\tT_Boone_Pickens\t1\nMarcelo_Salas\t2\tTara_VanDerveer\t1\nMarco_Irizarry\t1\tYang_Jianli\t1\nMariangel_Ruiz_Torrealba\t3\tPupi_Avati\t1\nMarisa_Tomei\t2\tPeter_Costello\t2\nMark_Polansky\t1\tMiranda_Gaddis\t1\nMary_Landrieu\t3\tPercy_Gibson\t1\nMathilda_Karel_Spak\t1\tMauricio_Macri\t1\nMathilda_Karel_Spak\t1\tTamara_Brooks\t2\nMatt_Welsh\t1\tRandy_Johnson\t1\nMel_Brooks\t2\tShoshana_Johnson\t1\nMichael_Kirby\t1\tRanil_Wickremasinghe\t2\nMichael_Sheehan\t1\tRobert_Hanssen\t1\nMichel_Duclos\t1\tQuin_Snyder\t1\nMichel_Duclos\t1\tSuh_Young-hoon\t1\nMike_Gable\t1\tMohamed_Hammam\t1\nMikhail_Khodorkovsky\t1\tRita_Moreno\t2\nMireya_Moscoso\t4\tSan_Lan\t1\nMohamed_Hammam\t1\tRoger_Moore\t4\nNabil_Shaath\t3\tSilvie_Cabero\t1\nNaomi_Hayashi\t1\tPrakash_Hinduja\t1\nNatalya_Sazanovich\t1\tPupi_Avati\t4\nNikki_Teasley\t1\tRyan_Goodman\t1\nOleksandr_Moroz\t1\tRobert_De_Niro\t1\nOscar_DLeon\t1\tSteven_Curtis_Chapman\t1\nPaul_Byrd\t1\tWolfgang_Schwarz\t1\nPaul_Wollnough\t1\tPhilip_Cummings\t1\nPaul_Wollnough\t1\tYuvraj_Singh\t1\nPenelope_Taylor\t1\tWang_Fei\t1\nPeter_Caruana\t1\tPhilip_Cummings\t1\nPhillip_Seymor_Hoffmann\t1\tSilvio_Fernandez\t1\nPhillips_Idowu\t1\tPrince_Naruhito\t2\nPrincess_Masako\t2\tThomas_Wilkens\t1\nQuin_Snyder\t1\tVagit_Alekperov\t1\nRanil_Wickremasinghe\t3\tStacy_Nelson\t1\nReina_Hayes\t1\tSteffeny_Holtz\t1\nRick_Pitino\t3\tTony_Clement\t1\nRicky_Martin\t2\tRoger_Etchegaray\t1\nRobert_F_Kennedy_Jr\t1\tRon_Dittemore\t1\nSidney_Poitier\t1\tSvend_Aage_Jensby\t1\nAbdel_Nasser_Assidi\t1\t2\nAi_Sugiyama\t1\t2\nAi_Sugiyama\t1\t4\nAi_Sugiyama\t4\t5\nAldo_Paredes\t1\t2\nAlejandro_Avila\t1\t2\nAlejandro_Avila\t1\t3\nAlex_Sink\t2\t3\nAllen_Iverson\t1\t2\nAmram_Mitzna\t1\t2\nAndrew_Niccol\t1\t2\nAndy_Hebb\t1\t2\nAnne_Krueger\t1\t2\nAnne_McLellan\t1\t3\nAnne_McLellan\t2\t3\nAnnette_Bening\t1\t2\nAnthony_Hopkins\t1\t2\nAriel_Sharon\t16\t45\nArminio_Fraga\t1\t6\nArminio_Fraga\t2\t4\nArminio_Fraga\t3\t6\nArminio_Fraga\t4\t6\nArt_Hoffmann\t1\t2\nAshanti\t1\t3\nAshanti\t1\t4\nAshanti\t2\t5\nAshanti\t3\t5\nAshanti\t4\t5\nAugustin_Calleri\t1\t2\nAugustin_Calleri\t2\t4\nAugustin_Calleri\t3\t4\nBertie_Ahern\t1\t2\nBertie_Ahern\t1\t4\nBertie_Ahern\t1\t5\nBertie_Ahern\t2\t3\nBertie_Ahern\t3\t5\nBill_Clinton\t2\t4\nBill_Clinton\t6\t8\nBill_Clinton\t6\t10\nBill_Clinton\t8\t10\nBill_Clinton\t9\t12\nBill_Clinton\t10\t29\nBill_Clinton\t18\t28\nBill_McBride\t4\t7\nBill_McBride\t4\t10\nBill_Parcells\t1\t2\nBinyamin_Ben-Eliezer\t3\t5\nBinyamin_Ben-Eliezer\t5\t6\nBinyamin_Ben-Eliezer\t6\t7\nBrendan_Hansen\t1\t2\nBrian_Wells\t1\t2\nCarlos_Quintanilla_Schmidt\t1\t2\nCarolina_Moraes\t1\t2\nCecilia_Bolocco\t1\t2\nCecilia_Bolocco\t1\t3\nCecilia_Bolocco\t2\t3\nCesar_Gaviria\t2\t4\nCesar_Gaviria\t2\t5\nCesar_Gaviria\t3\t6\nCesar_Gaviria\t3\t7\nCesar_Gaviria\t4\t6\nCharlie_Zaa\t1\t2\nChita_Rivera\t1\t2\nChristian_Longo\t1\t2\nChristian_Longo\t1\t3\nChristian_Wulff\t1\t2\nColin_Jackson\t1\t2\nDarrell_Issa\t1\t2\nDarrell_Porter\t1\t2\nDave_Campo\t1\t3\nDavid_Dodge\t1\t2\nDavid_Heyman\t1\t2\nDavid_Spade\t1\t2\nDavid_Wells\t1\t5\nDavid_Wells\t1\t6\nDavid_Wells\t1\t7\nDavid_Wells\t2\t6\nDavid_Wells\t5\t6\nDebbie_Reynolds\t1\t3\nDebbie_Reynolds\t2\t4\nDexter_Jackson\t1\t2\nDiana_Taurasi\t1\t2\nDonald_Evans\t1\t2\nDuane_Lee_Chapman\t1\t2\nEd_Smart\t1\t3\nEileen_Coparropa\t1\t2\nEileen_Coparropa\t1\t3\nEileen_Coparropa\t2\t3\nElizabeth_Dole\t1\t3\nElizabeth_Dole\t2\t4\nFred_Funk\t1\t2\nGabriel_Valdes\t1\t2\nGary_Winnick\t1\t2\nGeno_Auriemma\t1\t2\nGeorge_Karl\t1\t2\nGeorge_Robertson\t2\t3\nGeorge_Robertson\t3\t19\nGeorge_Robertson\t7\t19\nGeorge_Robertson\t11\t12\nGeorge_Ryan\t1\t4\nGeorge_Ryan\t2\t3\nGeorge_W_Bush\t7\t65\nGeorge_W_Bush\t16\t482\nGeorge_W_Bush\t145\t150\nGeorge_W_Bush\t145\t238\nGeorge_W_Bush\t203\t247\nGloria_Trevi\t1\t2\nGloria_Trevi\t2\t3\nGloria_Trevi\t2\t4\nGordon_Campbell\t1\t2\nGreg_Rusedski\t1\t2\nGreg_Rusedski\t2\t3\nGreg_Rusedski\t2\t4\nGreg_Rusedski\t3\t4\nGustavo_Kuerten\t1\t2\nGustavo_Kuerten\t2\t3\nGuy_Hemmings\t1\t2\nHalle_Berry\t6\t7\nHalle_Berry\t6\t9\nHalle_Berry\t7\t9\nHeather_Mills\t2\t3\nHeather_Mills\t2\t4\nHeidi_Fleiss\t1\t2\nHeidi_Fleiss\t1\t3\nHenrique_Meirelles\t1\t2\nIva_Majoli\t1\t2\nJake_Gyllenhaal\t3\t5\nJake_Gyllenhaal\t4\t5\nJames_Cunningham\t1\t2\nJames_Cunningham\t1\t3\nJames_Cunningham\t2\t3\nJames_Parker\t1\t2\nJames_Wolfensohn\t2\t5\nJason_Lezak\t1\t2\nJay_Rasulo\t1\t2\nJean-Claude_Juncker\t1\t2\nJennifer_Lopez\t1\t3\nJennifer_Lopez\t2\t16\nJennifer_Lopez\t3\t10\nJennifer_Lopez\t3\t14\nJesse_Jackson\t1\t3\nJesse_Jackson\t5\t8\nJesse_Jackson\t7\t8\nJesse_James_Leija\t1\t2\nJesse_Ventura\t2\t3\nJia_Qinglin\t1\t2\nJim_Tressel\t1\t2\nJim_Tressel\t1\t4\nJim_Tressel\t2\t4\nJoan_Laporta\t1\t6\nJoan_Laporta\t6\t7\nJoan_Laporta\t6\t8\nJoe_Dumars\t1\t2\nJohn_Ashcroft\t3\t5\nJohn_Ashcroft\t13\t34\nJohn_Ashcroft\t42\t43\nJohn_Bolton\t6\t7\nJohn_Bolton\t11\t16\nJohn_Swofford\t1\t2\nJohn_Swofford\t1\t3\nJohn_Timoney\t1\t2\nJon_Gruden\t1\t2\nJon_Gruden\t2\t5\nJon_Gruden\t3\t6\nJon_Gruden\t3\t7\nJulie_Taymor\t1\t2\nKamal_Kharrazi\t1\t5\nKamal_Kharrazi\t2\t3\nKamal_Kharrazi\t2\t6\nKarin_Stoiber\t1\t2\nKim_Yong-il\t1\t2\nKim_Yong-il\t1\t3\nKimi_Raikkonen\t1\t3\nKimi_Raikkonen\t2\t3\nKjell_Magne_Bondevik\t1\t3\nKobe_Bryant\t1\t2\nKurt_Warner\t1\t2\nKurt_Warner\t1\t4\nKurt_Warner\t2\t4\nKurt_Warner\t3\t5\nKwon_Yang-sook\t1\t3\nKwon_Yang-sook\t2\t3\nLee_Jun\t1\t2\nLeonid_Kuchma\t1\t2\nLeonid_Kuchma\t1\t3\nLeonid_Kuchma\t2\t3\nLeonid_Kuchma\t2\t5\nLeonid_Kuchma\t4\t5\nLina_Krasnoroutskaya\t1\t2\nLisa_Raymond\t1\t2\nLord_Hutton\t1\t2\nLuiz_Felipe_Scolari\t1\t2\nLynn_Redgrave\t2\t3\nMagdalena_Maleeva\t1\t2\nMagdalena_Maleeva\t1\t3\nMagdalena_Maleeva\t2\t3\nMarcelo_Ebrard\t1\t2\nMarcelo_Ebrard\t1\t3\nMarcelo_Rios\t1\t3\nMarcelo_Rios\t1\t4\nMarcelo_Rios\t2\t3\nMarcelo_Rios\t3\t4\nMarcelo_Rios\t3\t5\nMaria_Shriver\t1\t7\nMaria_Shriver\t1\t8\nMaria_Shriver\t2\t6\nMaria_Shriver\t2\t8\nMaria_Shriver\t3\t8\nMarilyn_Monroe\t1\t2\nMario_Cipollini\t1\t2\nMark_Hurlbert\t1\t5\nMark_Hurlbert\t2\t3\nMark_Hurlbert\t2\t4\nMartin_Scorsese\t2\t5\nMartin_Scorsese\t3\t4\nMarwan_Barghouthi\t1\t2\nMichael_Bloomberg\t1\t12\nMichael_Bloomberg\t3\t5\nMichael_Bloomberg\t7\t11\nMichael_Bloomberg\t11\t13\nMichael_Chang\t1\t3\nMichael_Chang\t5\t6\nMichael_Jackson\t1\t6\nMichael_Jackson\t2\t3\nMichael_Jackson\t2\t11\nMichael_Jackson\t2\t12\nMichael_Jackson\t11\t12\nMichael_Patrick_King\t1\t2\nMichelle_Rodriguez\t1\t2\nMike_Babcock\t1\t2\nMike_Martz\t1\t3\nMike_Scioscia\t1\t2\nMikulas_Dzurinda\t1\t2\nMiroljub\t1\t2\nNasser_al-Kidwa\t1\t2\nNick_Nolte\t1\t2\nNick_Nolte\t1\t3\nNick_Nolte\t1\t5\nNick_Nolte\t2\t4\nNick_Nolte\t3\t4\nOJ_Simpson\t1\t2\nOprah_Winfrey\t1\t2\nOprah_Winfrey\t2\t3\nOrlando_Bloom\t2\t3\nOzzy_Osbourne\t1\t3\nPaul_Coppin\t1\t2\nPaul_Martin\t1\t6\nPaul_Martin\t1\t7\nPaul_McNulty\t1\t2\nPaul_ONeill\t1\t3\nPaul_ONeill\t5\t7\nPaul_Patton\t1\t2\nPaula_Zahn\t1\t2\nPierce_Brosnan\t1\t5\nPierce_Brosnan\t3\t7\nPierce_Brosnan\t6\t9\nPierce_Brosnan\t9\t14\nPierre_Pettigrew\t1\t3\nRalf_Schumacher\t5\t8\nRicky_Barnes\t1\t2\nRita_Wilson\t1\t4\nRob_Schneider\t1\t2\nRobbie_Fowler\t1\t2\nRobert_Blake\t1\t3\nRobert_Blake\t1\t4\nRobert_Blake\t5\t6\nRogerio_Romero\t1\t2\nRupert_Grint\t1\t3\nSalman_Rushdie\t1\t3\nSalman_Rushdie\t2\t3\nScott_Sullivan\t1\t2\nScott_Wolf\t1\t2\nSepp_Blatter\t1\t2\nSepp_Blatter\t1\t3\nSepp_Blatter\t2\t3\nSimon_Cowell\t1\t2\nSlobodan_Milosevic\t1\t3\nSlobodan_Milosevic\t2\t3\nSlobodan_Milosevic\t3\t4\nStacy_Dragila\t1\t2\nStephen_Ambrose\t1\t2\nStephen_Daldry\t1\t2\nStephen_Friedman\t1\t2\nTheo_Epstein\t1\t2\nThomas_Wyman\t1\t2\nTim_Floyd\t1\t2\nTom_Watson\t1\t3\nTom_Watson\t2\t3\nTommy_Robredo\t1\t3\nTommy_Robredo\t2\t3\nTony_Parker\t1\t2\nTony_Stewart\t1\t6\nTony_Stewart\t2\t3\nTony_Stewart\t4\t5\nTony_Stewart\t4\t6\nVladimir_Voltchkov\t1\t2\nWang_Yi\t1\t2\nZafarullah_Khan_Jamali\t1\t2\nZhu_Rongji\t1\t3\nZhu_Rongji\t2\t8\nAaron_Tippin\t1\tEnos_Slaughter\t1\nAaron_Tippin\t1\tJuan_Carlos_Ortega\t1\nAaron_Tippin\t1\tMarlon_Devonish\t1\nAdam_Ant\t1\tJohn_Perrota\t1\nAdam_Ant\t1\tNoel_Forgeard\t1\nAdam_Ant\t1\tRichard_Regenhard\t1\nAdam_Mair\t1\tDaniel_Osorno\t1\nAdoor_Gopalakarishnan\t1\tNathalia_Gillot\t1\nAlain_Ducasse\t1\tPaul_ONeill\t2\nAlan_Greer\t1\tAlan_Trammell\t1\nAlan_Greer\t1\tBob_Hayes\t1\nAlan_Trammell\t1\tHeidi_Fleiss\t2\nAlan_Trammell\t1\tJulie_Taymor\t2\nAldo_Paredes\t1\tSuzanne_Mubarak\t1\nAldo_Paredes\t2\tZafarullah_Khan_Jamali\t1\nAlecos_Markides\t1\tDarryl_Stingley\t1\nAlecos_Markides\t1\tWolfgang_Schneiderhan\t1\nAlejandro_Avila\t3\tBenjamin_Franklin\t1\nAlejandro_Avila\t3\tDarrell_Porter\t1\nAlek_Wek\t1\tBarbara_Bodine\t1\nAlek_Wek\t1\tNasser_al-Kidwa\t1\nAlek_Wek\t1\tRay_Bradbury\t1\nAlina_Kabaeva\t1\tDonald_Trump\t1\nAlina_Kabaeva\t1\tJayson_Williams\t2\nAlyse_Beaupre\t1\tElmar_Brok\t1\nAlyse_Beaupre\t1\tHelo_Pinheiro\t1\nAlyse_Beaupre\t1\tHunter_Bates\t1\nAmbrose_Lee\t1\tBen_Chandler\t1\nAmy_Gale\t1\tHerman_Edwards\t1\nAnastasia_Kelesidou\t1\tBrendan_Hansen\t2\nAnastasia_Kelesidou\t1\tThomas_Wyman\t2\nAndrew_Niccol\t1\tPrince_Felipe\t1\nAndrew_Sabey\t1\tFederico_Castelan_Sayre\t1\nAndrew_Sabey\t1\tGreg_Rusedski\t1\nAndy_Madikians\t1\tJon_Gruden\t1\nAndy_Madikians\t1\tPedro_Alvarez\t1\nAndy_Madikians\t1\tPierce_Brosnan\t1\nAndy_Perez\t1\tElena_Dementieva\t1\nAndy_Perez\t1\tStephen_Joseph\t1\nAngie_Martinez\t1\tRuth_Pearce\t1\nAnn_Godbehere\t1\tTom_Watson\t1\nAnne_McLellan\t1\tTim_Howard\t1\nAnnette_Bening\t1\tRoss_Verba\t1\nAnthony_Hopkins\t2\tOrlando_Bloom\t1\nAntonio_Bernardo\t1\tBilly_Donovan\t1\nAntonio_Bernardo\t1\tDwain_Kyles\t1\nAntonio_Bernardo\t1\tElizabeth_Hill\t1\nAntonio_Bernardo\t1\tGuy_Hemmings\t1\nAntonio_Bernardo\t1\tKareena_Kapoor\t1\nAnzori_Kikalishvili\t1\tCarlos_Quintanilla_Schmidt\t2\nAnzori_Kikalishvili\t1\tEarl_Fritts\t1\nAnzori_Kikalishvili\t1\tSalman_Rushdie\t1\nAram_Adler\t1\tCesar_Gaviria\t3\nAram_Adler\t1\tDeepa_Mehta\t1\nArie_Haan\t1\tTony_Parker\t2\nAriel_Sharon\t30\tDavid_Ballantyne\t1\nArt_Hoffmann\t2\tJuan_Carlos_Ortega\t1\nAtiabet_Ijan_Amabel\t1\tJohn_Perrota\t1\nAugustin_Calleri\t3\tLee_Jun\t2\nBarry_Nakell\t1\tMaria_Simon\t1\nBasdeo_Panday\t1\tFilippo_Volandri\t1\nBen_Betts\t1\tKimi_Raikkonen\t3\nBen_Braun\t1\tCecilia_Chang\t1\nBen_Braun\t1\tHorace_Newcomb\t1\nBen_Chandler\t1\tLarry_Hagman\t1\nBen_Lee\t1\tHorace_Newcomb\t1\nBen_Stein\t1\tDavid_Canary\t1\nBen_Stein\t1\tLionel_Richie\t2\nBernadette_Peters\t1\tEd_Smart\t1\nBertie_Ahern\t4\tJim_Leach\t1\nBill_OReilly\t1\tJim_Wessling\t1\nBilly_Boyd\t1\tSid_Caesar\t1\nBilly_Donovan\t1\tBrandon_Spann\t1\nBilly_Donovan\t1\tCabas\t1\nBilly_Donovan\t1\tWilliam_Nessen\t1\nBinyamin_Ben-Eliezer\t1\tJenny_Romero\t1\nBo_Ryan\t2\tHeidi_Fleiss\t3\nBob_Beauprez\t2\tHedayat_Amin_Arsala\t1\nBob_Beauprez\t2\tJohn_Norquist\t1\nBob_Hayes\t1\tZhu_Rongji\t8\nBrady_Rodgers\t1\tJenna_Elfman\t1\nBrandon_Larson\t1\tChita_Rivera\t1\nBrendan_Hansen\t2\tDorothy_Wilson\t1\nCaio_Blat\t1\tSanja_Papic\t1\nCarlos_Quintanilla_Schmidt\t1\tNova_Esther_Guthrie\t1\nCarlos_Quintanilla_Schmidt\t2\tChris_Thomas\t1\nCarroll_Weimer\t1\tChris_Pronger\t1\nCarroll_Weimer\t1\tDebbie_Reynolds\t2\nCecilia_Bolocco\t1\tJohn_Perrota\t1\nCecilia_Bolocco\t1\tKurt_Schottenheimer\t1\nCelia_Cruz\t1\tRob_Ramsay\t1\nCharlie_Zaa\t2\tTheo_Epstein\t2\nChris_Pronger\t1\tEdgar_Savisaar\t1\nChristian_Longo\t2\tDavid_Carradine\t1\nChristian_Wulff\t2\tKjell_Magne_Bondevik\t3\nCindy_Klassen\t1\tVal_Ackerman\t1\nCindy_Taylor\t1\tFabian_Vargas\t1\nClaudette_Robinson\t1\tEric_Fehr\t1\nClifford_Robinson\t1\tMagdalena_Maleeva\t2\nClifford_Robinson\t1\tShirley_Jones\t1\nClifford_Robinson\t1\tTim_Howard\t1\nColin_Jackson\t1\tMarcelo_Ebrard\t3\nColin_Jackson\t2\tHunter_Bates\t1\nColumba_Bush\t1\tLarry_Anderson\t1\nColumba_Bush\t1\tNeil_Goldman\t1\nCraig_Fitzgibbon\t1\tJoe_Dumars\t1\nCristian_Barros\t1\tSteve_Largent\t1\nCurtis_Strange\t1\tKurt_Schottenheimer\t1\nCurtis_Strange\t1\tRaul_Chacon\t1\nDan_Kellner\t1\tFreda_Black\t1\nDan_LaCoutre\t1\tGustavo_Kuerten\t2\nDan_Monson\t1\tJim_Flaherty\t1\nDan_Monson\t1\tRafael_Vinoly\t1\nDarrell_Porter\t2\tRobert_Towne\t1\nDave_Campo\t2\tJenny_Romero\t1\nDavid_Ballantyne\t1\tDiana_Taurasi\t2\nDavid_Carradine\t1\tKobe_Bryant\t1\nDavid_Dodge\t1\tFrancois_Botha\t1\nDavid_Dodge\t1\tLarry_Anderson\t1\nDavid_Dodge\t2\tThomas_Wyman\t2\nDavid_Heyman\t1\tRod_Paige\t1\nDavid_Oh\t1\tDesiree_McKenzie\t1\nDavid_Oh\t1\tJoe_Garner\t1\nDavid_Spade\t2\tDenise_Locke\t1\nDavid_Suazo\t1\tJane_Krakowski\t1\nDavid_Wells\t1\tMary_Hill\t1\nDavid_Wells\t1\tYannos_Papantoniou\t1\nDawna_LoPiccolo\t1\tJean-Claude_Juncker\t2\nDebbie_Reynolds\t1\tNick_Nolte\t1\nDeniz_Baykal\t1\tKathy_Bates\t1\nDeniz_Baykal\t1\tRobin_Wagner\t1\nDesiree_McKenzie\t1\tJohn_Danforth\t1\nDick_Devine\t1\tMichael_Jackson\t9\nDinora_Rosales\t1\tRobbie_Fowler\t1\nDirk_Kempthorne\t1\tJanusz_Kaminski\t1\nDonald_Evans\t2\tFred_Funk\t2\nDorothy_Wilson\t1\tJim_Thome\t1\nDrew_Gooden\t1\tKimi_Raikkonen\t3\nDwain_Kyles\t1\tGregory_Peck\t1\nEd_Smart\t3\tJason_Gardner\t1\nEdgar_Savisaar\t1\tKirk_Doerger\t1\nEdward_Burns\t1\tPaul_ONeill\t1\nElmar_Brok\t1\tJose_Jose\t1\nEmily_Mortimer\t1\tMaria_Simon\t1\nEnos_Slaughter\t1\tQais_al-Kazali\t1\nEric_Fehr\t1\tLee_Jun\t2\nEric_Fehr\t1\tTamara_Mowry\t1\nFaisal_Saleh_Hayat\t1\tMarwan_Barghouthi\t1\nFederico_Castelan_Sayre\t1\tJimmy_Jimenez\t1\nFiona_Milne\t1\tHartmut_Mehdorn\t1\nFiona_Milne\t1\tJosh_Kronfeld\t1\nFloyd_Keith\t1\tHalle_Berry\t1\nFranklin_Brown\t1\tMichael_Jackson\t10\nFranklin_Brown\t1\tTamara_Mowry\t1\nFranklin_Brown\t1\tYolanda_King\t1\nFreda_Black\t1\tRod_Paige\t1\nFruit_Chan\t1\tKjell_Magne_Bondevik\t3\nGary_Winnick\t1\tMichael_Patrick_King\t2\nGeorge_Robertson\t5\tRobbie_Mc_Ewen\t1\nGloria_Trevi\t4\tWilliam_Ragland\t1\nGrace_Dodd\t1\tHenrique_Meirelles\t1\nGraeme_Lloyd\t1\tHumberto_Coelho\t1\nGraeme_Lloyd\t1\tLaura_Pausini\t1\nGreg_Rusedski\t2\tHorace_Newcomb\t1\nGreg_Rusedski\t3\tJavier_Bardem\t1\nGreg_Rusedski\t3\tMarcos_Milinkovic\t1\nGregory_Peck\t1\tJacqueline_Obradors\t1\nGuillermo_Ruiz_Polanco\t1\tJon_Constance\t1\nGustavo_Kuerten\t1\tRani_Mukherjee\t1\nHalle_Berry\t12\tJanet_Chandler\t1\nHartmut_Mehdorn\t1\tNatanaela_Barnova\t1\nHartmut_Mehdorn\t1\tSanja_Papic\t1\nHartmut_Mehdorn\t1\tSvetlana_Belousova\t1\nHaydar_Aliyev\t1\tNuon_Chea\t1\nHeather_Willson\t1\tLynn_Redgrave\t3\nHector_Mitelman\t1\tJon_Gruden\t2\nHelo_Pinheiro\t1\tRobert_Durst\t1\nHerman_Edwards\t1\tPatrick_Eaves\t1\nHermogenes_Ebdane_Jr\t1\tSanja_Papic\t1\nHorace_Newcomb\t1\tStephan_Eberharter\t1\nHugo_Colace\t1\tKim_Yun-kyu\t1\nHumberto_Coelho\t1\tSue_Wicks\t2\nHunter_Bates\t1\tPedro_Alvarez\t1\nHunter_Bates\t1\tWilliam_Rosenberg\t1\nIgor_Trunov\t1\tPeter_Sejna\t1\nIvan_Stambolic\t1\tMichael_Bloomberg\t18\nJack_LaLanne\t1\tYves_Brodeur\t1\nJacqueline_Obradors\t1\tJulie_Taymor\t1\nJada_Pinkett_Smith\t2\tJenny_Romero\t1\nJames_Cunningham\t3\tStephen_Daldry\t1\nJames_Gibson\t1\tRoger_Corbett\t1\nJames_Parker\t1\tSaeed_Mortazavi\t1\nJane_Krakowski\t1\tShingo_Suetsugu\t1\nJanice_Goldfinger\t1\tPyar_Jung_Thapa\t1\nJanusz_Kaminski\t1\tLisa_Stone\t1\nJason_Lezak\t1\tJohn_Bolton\t4\nJason_Lezak\t1\tSimon_Cowell\t1\nJavier_Vazquez\t1\tKarin_Stoiber\t2\nJay_Rasulo\t1\tNova_Esther_Guthrie\t1\nJean-Marc_Olive\t1\tJohn_Timoney\t1\nJean-Marc_Olive\t1\tTino_Martinez\t1\nJeri_Ryan\t1\tNova_Esther_Guthrie\t1\nJeri_Ryan\t1\tPeter_Goldmark\t1\nJeri_Ryan\t1\tScott_Sullivan\t2\nJeri_Ryan\t1\tSkip_Prosser\t1\nJesse_James_Leija\t2\tJoaquin_Phoenix\t1\nJesse_James_Leija\t2\tNick_Nolte\t4\nJesse_Ventura\t2\tLela_Rochon\t1\nJessica_Biel\t1\tJim_Fassel\t1\nJim_Flaherty\t1\tMark_Andrew\t1\nJim_Tressel\t3\tRalf_Schumacher\t3\nJimmy_Jimenez\t1\tMiles_Stewart\t1\nJimmy_Lee\t1\tNova_Esther_Guthrie\t1\nJoan_Laporta\t3\tRoy_Romanow\t1\nJoaquin_Phoenix\t1\tRainer_Geulen\t1\nJoe_Dumars\t2\tTimothy_McVeigh\t1\nJohn_Bolton\t14\tKim_Yun-kyu\t1\nJohn_Kerr\t1\tLi_Changchun\t1\nJohn_Swofford\t2\tSok_An\t1\nJuan_Fernandez\t1\tPaul_Krueger\t1\nJuan_Fernandez\t1\tSuzanne_Mubarak\t1\nJustin_Wilson\t1\tLarry_Hagman\t1\nJustin_Wilson\t1\tRay_Bradbury\t1\nKara_Lynn_Joyce\t1\tZach_Pillar\t1\nKim_Chinn\t1\tRobert_Flodquist\t1\nKim_Chinn\t1\tRuth_Harlow\t2\nKim_Yong-il\t2\tLinda_Ham\t1\nKwon_Yang-sook\t3\tTommy_Robredo\t1\nLane_Bryant\t1\tYannos_Papantoniou\t1\nLarry_Hagman\t1\tTeddy_Kollek\t1\nLarry_Hagman\t1\tVal_Ackerman\t1\nLaura_Gobai\t1\tRobin_Wagner\t1\nLaura_Pausini\t1\tThad_Matta\t1\nLaura_Romero\t1\tPaula_Zahn\t2\nLee_Jun\t1\tRuth_Pearce\t1\nLee_Jun\t2\tStephen_Friedman\t1\nLela_Rochon\t1\tMichael_Haneke\t1\nLela_Rochon\t1\tYannos_Papantoniou\t1\nLesley_Flood\t1\tPeter_Goldmark\t1\nLi_Changchun\t1\tPieter_Bouw\t1\nLina_Krasnoroutskaya\t1\tTroy_Polamalu\t1\nLinda_Lingle\t1\tVictor_Hanescu\t1\nLisa_Stone\t1\tRod_Paige\t1\nLisa_Stone\t1\tScott_Sullivan\t2\nLou_Lang\t1\tNova_Esther_Guthrie\t1\nLuc_Montagnier\t1\tPaul_Krueger\t1\nLuc_Montagnier\t1\tPedro_Alvarez\t1\nLuc_Montagnier\t1\tPierre_Pettigrew\t2\nLuis_Guzman\t1\tPatsy_Kensit\t1\nMarcelo_Ebrard\t2\tMike_Scioscia\t2\nMarcelo_Rios\t4\tMaria_Shriver\t3\nMarcelo_Rios\t4\tPierre_Pettigrew\t1\nMarcelo_Rios\t4\tSaeed_Mortazavi\t1\nMargaret_Thatcher\t1\tPedro_Alvarez\t1\nMargaret_Thatcher\t1\tSalman_Rushdie\t2\nMaria_Simon\t1\tMona_Rishmawi\t1\nMaria_Simon\t1\tRobert_Durst\t1\nMarlon_Devonish\t1\tPatrick_Clawsen\t1\nMax_von_Sydow\t1\tZhu_Rongji\t1\nMel_Karmazin\t1\tPierre_Pettigrew\t1\nMelana_Scantlin\t1\tWilliam_Ragland\t1\nMichael_Bloomberg\t15\tOzzy_Osbourne\t2\nMichael_J_Fox\t1\tRicky_Barnes\t1\nMichael_J_Fox\t1\tThomas_Daily\t1\nMicky_Ward\t1\tTakenori_Kanzaki\t1\nMike_Babcock\t1\tTony_Parker\t2\nMike_Martz\t5\tWilliam_Burns\t1\nMira_Sorvino\t1\tSimon_Cowell\t2\nMira_Sorvino\t1\tTom_Tunney\t1\nMiroljub\t2\tTheo_Epstein\t1\nMitzi_Gaynor\t1\tRuth_Harlow\t1\nMohammed_Dahlan\t1\tRonald_White\t1\nNatanaela_Barnova\t1\tNuon_Chea\t1\nNoel_Forgeard\t1\tZach_Pillar\t1\nNormand_Legault\t1\tOmar_Vizquel\t1\nNormand_Legault\t1\tRupert_Grint\t3\nNova_Esther_Guthrie\t1\tStephen_Joseph\t1\nOntario_Lett\t1\tWallace_Capel\t1\nOrlando_Bloom\t1\tRay_Liotta\t1\nPatrick_Clawsen\t1\tSandra_Banning\t1\nPaul_Coppin\t2\tRick_Husband\t1\nPaul_Murphy\t1\tQazi_Hussain_Ahmed\t1\nPaul_Newman\t1\tRobert_Blake\t3\nPaula_Zahn\t1\tTamara_Mowry\t1\nPeter_Ahearn\t1\tRomain_Duris\t1\nPeter_Gabriel\t1\tPeter_OToole\t1\nPeter_Lundgren\t1\tWilliam_Rosenberg\t1\nPeter_OToole\t1\tQazi_Afzal\t1\nQais_al-Kazali\t1\tRingo_Starr\t1\nRandy_Brown\t1\tVal_Ackerman\t1\nRani_Mukherjee\t1\tTimothy_McVeigh\t1\nRingo_Starr\t1\tZach_Pillar\t1\nRoger_Corbett\t1\tTocker_Pudwill\t1\nRuth_Harlow\t1\tVirgina_Ruano_Pascal\t1\nSandra_Banning\t1\tWolfgang_Schneiderhan\t1\nScott_Wolf\t2\tTroy_Polamalu\t1\nSergei_Alexandrovitch_Ordzhonikidze\t1\tYolanda_King\t1\nShane_Loux\t1\tVal_Ackerman\t1\nShawn_Marion\t1\tShirley_Jones\t1\nSlobodan_Milosevic\t2\tSok_An\t1\n"
  },
  {
    "path": "requirements.txt",
    "content": "tensorflow==1.7\nscipy\nscikit-learn\nopencv-python\nh5py\nmatplotlib\nPillow\nrequests\npsutil\n"
  },
  {
    "path": "src/__init__.py",
    "content": "# flake8: noqa\n\n"
  },
  {
    "path": "src/align/__init__.py",
    "content": ""
  },
  {
    "path": "src/align/align_dataset_mtcnn.py",
    "content": "\"\"\"Performs face alignment and stores face thumbnails in the output directory.\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport sys\nimport os\nimport argparse\nimport tensorflow as tf\nimport numpy as np\nimport facenet\nimport align.detect_face\nimport random\nfrom time import sleep\n\ndef main(args):\n    sleep(random.random())\n    output_dir = os.path.expanduser(args.output_dir)\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n    # Store some git revision info in a text file in the log directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))\n    dataset = facenet.get_dataset(args.input_dir)\n    \n    print('Creating networks and loading parameters')\n    \n    with tf.Graph().as_default():\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        with sess.as_default():\n            pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)\n    \n    minsize = 20 # minimum size of face\n    threshold = [ 0.6, 0.7, 0.7 ]  # three steps's threshold\n    factor = 0.709 # scale factor\n\n    # Add a random key to the filename to allow alignment using multiple processes\n    random_key = np.random.randint(0, high=99999)\n    bounding_boxes_filename = os.path.join(output_dir, 'bounding_boxes_%05d.txt' % random_key)\n    \n    with open(bounding_boxes_filename, \"w\") as text_file:\n        nrof_images_total = 0\n        nrof_successfully_aligned = 0\n        if args.random_order:\n            random.shuffle(dataset)\n        for cls in dataset:\n            output_class_dir = os.path.join(output_dir, cls.name)\n            if not os.path.exists(output_class_dir):\n                os.makedirs(output_class_dir)\n                if args.random_order:\n                    random.shuffle(cls.image_paths)\n            for image_path in cls.image_paths:\n                nrof_images_total += 1\n                filename = os.path.splitext(os.path.split(image_path)[1])[0]\n                output_filename = os.path.join(output_class_dir, filename+'.png')\n                print(image_path)\n                if not os.path.exists(output_filename):\n                    try:\n                        img = misc.imread(image_path)\n                    except (IOError, ValueError, IndexError) as e:\n                        errorMessage = '{}: {}'.format(image_path, e)\n                        print(errorMessage)\n                    else:\n                        if img.ndim<2:\n                            print('Unable to align \"%s\"' % image_path)\n                            text_file.write('%s\\n' % (output_filename))\n                            continue\n                        if img.ndim == 2:\n                            img = facenet.to_rgb(img)\n                        img = img[:,:,0:3]\n    \n                        bounding_boxes, _ = align.detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)\n                        nrof_faces = bounding_boxes.shape[0]\n                        if nrof_faces>0:\n                            det = bounding_boxes[:,0:4]\n                            det_arr = []\n                            img_size = np.asarray(img.shape)[0:2]\n                            if nrof_faces>1:\n                                if args.detect_multiple_faces:\n                                    for i in range(nrof_faces):\n                                        det_arr.append(np.squeeze(det[i]))\n                                else:\n                                    bounding_box_size = (det[:,2]-det[:,0])*(det[:,3]-det[:,1])\n                                    img_center = img_size / 2\n                                    offsets = np.vstack([ (det[:,0]+det[:,2])/2-img_center[1], (det[:,1]+det[:,3])/2-img_center[0] ])\n                                    offset_dist_squared = np.sum(np.power(offsets,2.0),0)\n                                    index = np.argmax(bounding_box_size-offset_dist_squared*2.0) # some extra weight on the centering\n                                    det_arr.append(det[index,:])\n                            else:\n                                det_arr.append(np.squeeze(det))\n\n                            for i, det in enumerate(det_arr):\n                                det = np.squeeze(det)\n                                bb = np.zeros(4, dtype=np.int32)\n                                bb[0] = np.maximum(det[0]-args.margin/2, 0)\n                                bb[1] = np.maximum(det[1]-args.margin/2, 0)\n                                bb[2] = np.minimum(det[2]+args.margin/2, img_size[1])\n                                bb[3] = np.minimum(det[3]+args.margin/2, img_size[0])\n                                cropped = img[bb[1]:bb[3],bb[0]:bb[2],:]\n                                scaled = misc.imresize(cropped, (args.image_size, args.image_size), interp='bilinear')\n                                nrof_successfully_aligned += 1\n                                filename_base, file_extension = os.path.splitext(output_filename)\n                                if args.detect_multiple_faces:\n                                    output_filename_n = \"{}_{}{}\".format(filename_base, i, file_extension)\n                                else:\n                                    output_filename_n = \"{}{}\".format(filename_base, file_extension)\n                                misc.imsave(output_filename_n, scaled)\n                                text_file.write('%s %d %d %d %d\\n' % (output_filename_n, bb[0], bb[1], bb[2], bb[3]))\n                        else:\n                            print('Unable to align \"%s\"' % image_path)\n                            text_file.write('%s\\n' % (output_filename))\n                            \n    print('Total number of images: %d' % nrof_images_total)\n    print('Number of successfully aligned images: %d' % nrof_successfully_aligned)\n            \n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('input_dir', type=str, help='Directory with unaligned images.')\n    parser.add_argument('output_dir', type=str, help='Directory with aligned face thumbnails.')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=182)\n    parser.add_argument('--margin', type=int,\n        help='Margin for the crop around the bounding box (height, width) in pixels.', default=44)\n    parser.add_argument('--random_order', \n        help='Shuffles the order of images to enable alignment using multiple processes.', action='store_true')\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n    parser.add_argument('--detect_multiple_faces', type=bool,\n                        help='Detect and align multiple faces per image.', default=False)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/align/detect_face.py",
    "content": "\"\"\" Tensorflow implementation of the face detection / alignment algorithm found at\nhttps://github.com/kpzhang93/MTCNN_face_detection_alignment\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\nfrom six import string_types, iteritems\n\nimport numpy as np\nimport tensorflow as tf\n#from math import floor\nimport cv2\nimport os\n\ndef layer(op):\n    \"\"\"Decorator for composable network layers.\"\"\"\n\n    def layer_decorated(self, *args, **kwargs):\n        # Automatically set a name if not provided.\n        name = kwargs.setdefault('name', self.get_unique_name(op.__name__))\n        # Figure out the layer inputs.\n        if len(self.terminals) == 0:\n            raise RuntimeError('No input variables found for layer %s.' % name)\n        elif len(self.terminals) == 1:\n            layer_input = self.terminals[0]\n        else:\n            layer_input = list(self.terminals)\n        # Perform the operation and get the output.\n        layer_output = op(self, layer_input, *args, **kwargs)\n        # Add to layer LUT.\n        self.layers[name] = layer_output\n        # This output is now the input for the next layer.\n        self.feed(layer_output)\n        # Return self for chained calls.\n        return self\n\n    return layer_decorated\n\nclass Network(object):\n\n    def __init__(self, inputs, trainable=True):\n        # The input nodes for this network\n        self.inputs = inputs\n        # The current list of terminal nodes\n        self.terminals = []\n        # Mapping from layer names to layers\n        self.layers = dict(inputs)\n        # If true, the resulting variables are set as trainable\n        self.trainable = trainable\n\n        self.setup()\n\n    def setup(self):\n        \"\"\"Construct the network. \"\"\"\n        raise NotImplementedError('Must be implemented by the subclass.')\n\n    def load(self, data_path, session, ignore_missing=False):\n        \"\"\"Load network weights.\n        data_path: The path to the numpy-serialized network weights\n        session: The current TensorFlow session\n        ignore_missing: If true, serialized weights for missing layers are ignored.\n        \"\"\"\n        data_dict = np.load(data_path, encoding='latin1').item() #pylint: disable=no-member\n\n        for op_name in data_dict:\n            with tf.variable_scope(op_name, reuse=True):\n                for param_name, data in iteritems(data_dict[op_name]):\n                    try:\n                        var = tf.get_variable(param_name)\n                        session.run(var.assign(data))\n                    except ValueError:\n                        if not ignore_missing:\n                            raise\n\n    def feed(self, *args):\n        \"\"\"Set the input(s) for the next operation by replacing the terminal nodes.\n        The arguments can be either layer names or the actual layers.\n        \"\"\"\n        assert len(args) != 0\n        self.terminals = []\n        for fed_layer in args:\n            if isinstance(fed_layer, string_types):\n                try:\n                    fed_layer = self.layers[fed_layer]\n                except KeyError:\n                    raise KeyError('Unknown layer name fed: %s' % fed_layer)\n            self.terminals.append(fed_layer)\n        return self\n\n    def get_output(self):\n        \"\"\"Returns the current network output.\"\"\"\n        return self.terminals[-1]\n\n    def get_unique_name(self, prefix):\n        \"\"\"Returns an index-suffixed unique name for the given prefix.\n        This is used for auto-generating layer names based on the type-prefix.\n        \"\"\"\n        ident = sum(t.startswith(prefix) for t, _ in self.layers.items()) + 1\n        return '%s_%d' % (prefix, ident)\n\n    def make_var(self, name, shape):\n        \"\"\"Creates a new TensorFlow variable.\"\"\"\n        return tf.get_variable(name, shape, trainable=self.trainable)\n\n    def validate_padding(self, padding):\n        \"\"\"Verifies that the padding is one of the supported ones.\"\"\"\n        assert padding in ('SAME', 'VALID')\n\n    @layer\n    def conv(self,\n             inp,\n             k_h,\n             k_w,\n             c_o,\n             s_h,\n             s_w,\n             name,\n             relu=True,\n             padding='SAME',\n             group=1,\n             biased=True):\n        # Verify that the padding is acceptable\n        self.validate_padding(padding)\n        # Get the number of channels in the input\n        c_i = int(inp.get_shape()[-1])\n        # Verify that the grouping parameter is valid\n        assert c_i % group == 0\n        assert c_o % group == 0\n        # Convolution for a given input and kernel\n        convolve = lambda i, k: tf.nn.conv2d(i, k, [1, s_h, s_w, 1], padding=padding)\n        with tf.variable_scope(name) as scope:\n            kernel = self.make_var('weights', shape=[k_h, k_w, c_i // group, c_o])\n            # This is the common-case. Convolve the input without any further complications.\n            output = convolve(inp, kernel)\n            # Add the biases\n            if biased:\n                biases = self.make_var('biases', [c_o])\n                output = tf.nn.bias_add(output, biases)\n            if relu:\n                # ReLU non-linearity\n                output = tf.nn.relu(output, name=scope.name)\n            return output\n\n    @layer\n    def prelu(self, inp, name):\n        with tf.variable_scope(name):\n            i = int(inp.get_shape()[-1])\n            alpha = self.make_var('alpha', shape=(i,))\n            output = tf.nn.relu(inp) + tf.multiply(alpha, -tf.nn.relu(-inp))\n        return output\n\n    @layer\n    def max_pool(self, inp, k_h, k_w, s_h, s_w, name, padding='SAME'):\n        self.validate_padding(padding)\n        return tf.nn.max_pool(inp,\n                              ksize=[1, k_h, k_w, 1],\n                              strides=[1, s_h, s_w, 1],\n                              padding=padding,\n                              name=name)\n\n    @layer\n    def fc(self, inp, num_out, name, relu=True):\n        with tf.variable_scope(name):\n            input_shape = inp.get_shape()\n            if input_shape.ndims == 4:\n                # The input is spatial. Vectorize it first.\n                dim = 1\n                for d in input_shape[1:].as_list():\n                    dim *= int(d)\n                feed_in = tf.reshape(inp, [-1, dim])\n            else:\n                feed_in, dim = (inp, input_shape[-1].value)\n            weights = self.make_var('weights', shape=[dim, num_out])\n            biases = self.make_var('biases', [num_out])\n            op = tf.nn.relu_layer if relu else tf.nn.xw_plus_b\n            fc = op(feed_in, weights, biases, name=name)\n            return fc\n\n\n    \"\"\"\n    Multi dimensional softmax,\n    refer to https://github.com/tensorflow/tensorflow/issues/210\n    compute softmax along the dimension of target\n    the native softmax only supports batch_size x dimension\n    \"\"\"\n    @layer\n    def softmax(self, target, axis, name=None):\n        max_axis = tf.reduce_max(target, axis, keepdims=True)\n        target_exp = tf.exp(target-max_axis)\n        normalize = tf.reduce_sum(target_exp, axis, keepdims=True)\n        softmax = tf.div(target_exp, normalize, name)\n        return softmax\n    \nclass PNet(Network):\n    def setup(self):\n        (self.feed('data') #pylint: disable=no-value-for-parameter, no-member\n             .conv(3, 3, 10, 1, 1, padding='VALID', relu=False, name='conv1')\n             .prelu(name='PReLU1')\n             .max_pool(2, 2, 2, 2, name='pool1')\n             .conv(3, 3, 16, 1, 1, padding='VALID', relu=False, name='conv2')\n             .prelu(name='PReLU2')\n             .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv3')\n             .prelu(name='PReLU3')\n             .conv(1, 1, 2, 1, 1, relu=False, name='conv4-1')\n             .softmax(3,name='prob1'))\n\n        (self.feed('PReLU3') #pylint: disable=no-value-for-parameter\n             .conv(1, 1, 4, 1, 1, relu=False, name='conv4-2'))\n        \nclass RNet(Network):\n    def setup(self):\n        (self.feed('data') #pylint: disable=no-value-for-parameter, no-member\n             .conv(3, 3, 28, 1, 1, padding='VALID', relu=False, name='conv1')\n             .prelu(name='prelu1')\n             .max_pool(3, 3, 2, 2, name='pool1')\n             .conv(3, 3, 48, 1, 1, padding='VALID', relu=False, name='conv2')\n             .prelu(name='prelu2')\n             .max_pool(3, 3, 2, 2, padding='VALID', name='pool2')\n             .conv(2, 2, 64, 1, 1, padding='VALID', relu=False, name='conv3')\n             .prelu(name='prelu3')\n             .fc(128, relu=False, name='conv4')\n             .prelu(name='prelu4')\n             .fc(2, relu=False, name='conv5-1')\n             .softmax(1,name='prob1'))\n\n        (self.feed('prelu4') #pylint: disable=no-value-for-parameter\n             .fc(4, relu=False, name='conv5-2'))\n\nclass ONet(Network):\n    def setup(self):\n        (self.feed('data') #pylint: disable=no-value-for-parameter, no-member\n             .conv(3, 3, 32, 1, 1, padding='VALID', relu=False, name='conv1')\n             .prelu(name='prelu1')\n             .max_pool(3, 3, 2, 2, name='pool1')\n             .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv2')\n             .prelu(name='prelu2')\n             .max_pool(3, 3, 2, 2, padding='VALID', name='pool2')\n             .conv(3, 3, 64, 1, 1, padding='VALID', relu=False, name='conv3')\n             .prelu(name='prelu3')\n             .max_pool(2, 2, 2, 2, name='pool3')\n             .conv(2, 2, 128, 1, 1, padding='VALID', relu=False, name='conv4')\n             .prelu(name='prelu4')\n             .fc(256, relu=False, name='conv5')\n             .prelu(name='prelu5')\n             .fc(2, relu=False, name='conv6-1')\n             .softmax(1, name='prob1'))\n\n        (self.feed('prelu5') #pylint: disable=no-value-for-parameter\n             .fc(4, relu=False, name='conv6-2'))\n\n        (self.feed('prelu5') #pylint: disable=no-value-for-parameter\n             .fc(10, relu=False, name='conv6-3'))\n\ndef create_mtcnn(sess, model_path):\n    if not model_path:\n        model_path,_ = os.path.split(os.path.realpath(__file__))\n\n    with tf.variable_scope('pnet'):\n        data = tf.placeholder(tf.float32, (None,None,None,3), 'input')\n        pnet = PNet({'data':data})\n        pnet.load(os.path.join(model_path, 'det1.npy'), sess)\n    with tf.variable_scope('rnet'):\n        data = tf.placeholder(tf.float32, (None,24,24,3), 'input')\n        rnet = RNet({'data':data})\n        rnet.load(os.path.join(model_path, 'det2.npy'), sess)\n    with tf.variable_scope('onet'):\n        data = tf.placeholder(tf.float32, (None,48,48,3), 'input')\n        onet = ONet({'data':data})\n        onet.load(os.path.join(model_path, 'det3.npy'), sess)\n        \n    pnet_fun = lambda img : sess.run(('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0':img})\n    rnet_fun = lambda img : sess.run(('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0':img})\n    onet_fun = lambda img : sess.run(('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0'), feed_dict={'onet/input:0':img})\n    return pnet_fun, rnet_fun, onet_fun\n\ndef detect_face(img, minsize, pnet, rnet, onet, threshold, factor):\n    \"\"\"Detects faces in an image, and returns bounding boxes and points for them.\n    img: input image\n    minsize: minimum faces' size\n    pnet, rnet, onet: caffemodel\n    threshold: threshold=[th1, th2, th3], th1-3 are three steps's threshold\n    factor: the factor used to create a scaling pyramid of face sizes to detect in the image.\n    \"\"\"\n    factor_count=0\n    total_boxes=np.empty((0,9))\n    points=np.empty(0)\n    h=img.shape[0]\n    w=img.shape[1]\n    minl=np.amin([h, w])\n    m=12.0/minsize\n    minl=minl*m\n    # create scale pyramid\n    scales=[]\n    while minl>=12:\n        scales += [m*np.power(factor, factor_count)]\n        minl = minl*factor\n        factor_count += 1\n\n    # first stage\n    for scale in scales:\n        hs=int(np.ceil(h*scale))\n        ws=int(np.ceil(w*scale))\n        im_data = imresample(img, (hs, ws))\n        im_data = (im_data-127.5)*0.0078125\n        img_x = np.expand_dims(im_data, 0)\n        img_y = np.transpose(img_x, (0,2,1,3))\n        out = pnet(img_y)\n        out0 = np.transpose(out[0], (0,2,1,3))\n        out1 = np.transpose(out[1], (0,2,1,3))\n        \n        boxes, _ = generateBoundingBox(out1[0,:,:,1].copy(), out0[0,:,:,:].copy(), scale, threshold[0])\n        \n        # inter-scale nms\n        pick = nms(boxes.copy(), 0.5, 'Union')\n        if boxes.size>0 and pick.size>0:\n            boxes = boxes[pick,:]\n            total_boxes = np.append(total_boxes, boxes, axis=0)\n\n    numbox = total_boxes.shape[0]\n    if numbox>0:\n        pick = nms(total_boxes.copy(), 0.7, 'Union')\n        total_boxes = total_boxes[pick,:]\n        regw = total_boxes[:,2]-total_boxes[:,0]\n        regh = total_boxes[:,3]-total_boxes[:,1]\n        qq1 = total_boxes[:,0]+total_boxes[:,5]*regw\n        qq2 = total_boxes[:,1]+total_boxes[:,6]*regh\n        qq3 = total_boxes[:,2]+total_boxes[:,7]*regw\n        qq4 = total_boxes[:,3]+total_boxes[:,8]*regh\n        total_boxes = np.transpose(np.vstack([qq1, qq2, qq3, qq4, total_boxes[:,4]]))\n        total_boxes = rerec(total_boxes.copy())\n        total_boxes[:,0:4] = np.fix(total_boxes[:,0:4]).astype(np.int32)\n        dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h)\n\n    numbox = total_boxes.shape[0]\n    if numbox>0:\n        # second stage\n        tempimg = np.zeros((24,24,3,numbox))\n        for k in range(0,numbox):\n            tmp = np.zeros((int(tmph[k]),int(tmpw[k]),3))\n            tmp[dy[k]-1:edy[k],dx[k]-1:edx[k],:] = img[y[k]-1:ey[k],x[k]-1:ex[k],:]\n            if tmp.shape[0]>0 and tmp.shape[1]>0 or tmp.shape[0]==0 and tmp.shape[1]==0:\n                tempimg[:,:,:,k] = imresample(tmp, (24, 24))\n            else:\n                return np.empty()\n        tempimg = (tempimg-127.5)*0.0078125\n        tempimg1 = np.transpose(tempimg, (3,1,0,2))\n        out = rnet(tempimg1)\n        out0 = np.transpose(out[0])\n        out1 = np.transpose(out[1])\n        score = out1[1,:]\n        ipass = np.where(score>threshold[1])\n        total_boxes = np.hstack([total_boxes[ipass[0],0:4].copy(), np.expand_dims(score[ipass].copy(),1)])\n        mv = out0[:,ipass[0]]\n        if total_boxes.shape[0]>0:\n            pick = nms(total_boxes, 0.7, 'Union')\n            total_boxes = total_boxes[pick,:]\n            total_boxes = bbreg(total_boxes.copy(), np.transpose(mv[:,pick]))\n            total_boxes = rerec(total_boxes.copy())\n\n    numbox = total_boxes.shape[0]\n    if numbox>0:\n        # third stage\n        total_boxes = np.fix(total_boxes).astype(np.int32)\n        dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(total_boxes.copy(), w, h)\n        tempimg = np.zeros((48,48,3,numbox))\n        for k in range(0,numbox):\n            tmp = np.zeros((int(tmph[k]),int(tmpw[k]),3))\n            tmp[dy[k]-1:edy[k],dx[k]-1:edx[k],:] = img[y[k]-1:ey[k],x[k]-1:ex[k],:]\n            if tmp.shape[0]>0 and tmp.shape[1]>0 or tmp.shape[0]==0 and tmp.shape[1]==0:\n                tempimg[:,:,:,k] = imresample(tmp, (48, 48))\n            else:\n                return np.empty()\n        tempimg = (tempimg-127.5)*0.0078125\n        tempimg1 = np.transpose(tempimg, (3,1,0,2))\n        out = onet(tempimg1)\n        out0 = np.transpose(out[0])\n        out1 = np.transpose(out[1])\n        out2 = np.transpose(out[2])\n        score = out2[1,:]\n        points = out1\n        ipass = np.where(score>threshold[2])\n        points = points[:,ipass[0]]\n        total_boxes = np.hstack([total_boxes[ipass[0],0:4].copy(), np.expand_dims(score[ipass].copy(),1)])\n        mv = out0[:,ipass[0]]\n\n        w = total_boxes[:,2]-total_boxes[:,0]+1\n        h = total_boxes[:,3]-total_boxes[:,1]+1\n        points[0:5,:] = np.tile(w,(5, 1))*points[0:5,:] + np.tile(total_boxes[:,0],(5, 1))-1\n        points[5:10,:] = np.tile(h,(5, 1))*points[5:10,:] + np.tile(total_boxes[:,1],(5, 1))-1\n        if total_boxes.shape[0]>0:\n            total_boxes = bbreg(total_boxes.copy(), np.transpose(mv))\n            pick = nms(total_boxes.copy(), 0.7, 'Min')\n            total_boxes = total_boxes[pick,:]\n            points = points[:,pick]\n                \n    return total_boxes, points\n\n\ndef bulk_detect_face(images, detection_window_size_ratio, pnet, rnet, onet, threshold, factor):\n    \"\"\"Detects faces in a list of images\n    images: list containing input images\n    detection_window_size_ratio: ratio of minimum face size to smallest image dimension\n    pnet, rnet, onet: caffemodel\n    threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold [0-1]\n    factor: the factor used to create a scaling pyramid of face sizes to detect in the image.\n    \"\"\"\n    all_scales = [None] * len(images)\n    images_with_boxes = [None] * len(images)\n\n    for i in range(len(images)):\n        images_with_boxes[i] = {'total_boxes': np.empty((0, 9))}\n\n    # create scale pyramid\n    for index, img in enumerate(images):\n        all_scales[index] = []\n        h = img.shape[0]\n        w = img.shape[1]\n        minsize = int(detection_window_size_ratio * np.minimum(w, h))\n        factor_count = 0\n        minl = np.amin([h, w])\n        if minsize <= 12:\n            minsize = 12\n\n        m = 12.0 / minsize\n        minl = minl * m\n        while minl >= 12:\n            all_scales[index].append(m * np.power(factor, factor_count))\n            minl = minl * factor\n            factor_count += 1\n\n    # # # # # # # # # # # # #\n    # first stage - fast proposal network (pnet) to obtain face candidates\n    # # # # # # # # # # # # #\n\n    images_obj_per_resolution = {}\n\n    # TODO: use some type of rounding to number module 8 to increase probability that pyramid images will have the same resolution across input images\n\n    for index, scales in enumerate(all_scales):\n        h = images[index].shape[0]\n        w = images[index].shape[1]\n\n        for scale in scales:\n            hs = int(np.ceil(h * scale))\n            ws = int(np.ceil(w * scale))\n\n            if (ws, hs) not in images_obj_per_resolution:\n                images_obj_per_resolution[(ws, hs)] = []\n\n            im_data = imresample(images[index], (hs, ws))\n            im_data = (im_data - 127.5) * 0.0078125\n            img_y = np.transpose(im_data, (1, 0, 2))  # caffe uses different dimensions ordering\n            images_obj_per_resolution[(ws, hs)].append({'scale': scale, 'image': img_y, 'index': index})\n\n    for resolution in images_obj_per_resolution:\n        images_per_resolution = [i['image'] for i in images_obj_per_resolution[resolution]]\n        outs = pnet(images_per_resolution)\n\n        for index in range(len(outs[0])):\n            scale = images_obj_per_resolution[resolution][index]['scale']\n            image_index = images_obj_per_resolution[resolution][index]['index']\n            out0 = np.transpose(outs[0][index], (1, 0, 2))\n            out1 = np.transpose(outs[1][index], (1, 0, 2))\n\n            boxes, _ = generateBoundingBox(out1[:, :, 1].copy(), out0[:, :, :].copy(), scale, threshold[0])\n\n            # inter-scale nms\n            pick = nms(boxes.copy(), 0.5, 'Union')\n            if boxes.size > 0 and pick.size > 0:\n                boxes = boxes[pick, :]\n                images_with_boxes[image_index]['total_boxes'] = np.append(images_with_boxes[image_index]['total_boxes'],\n                                                                          boxes,\n                                                                          axis=0)\n\n    for index, image_obj in enumerate(images_with_boxes):\n        numbox = image_obj['total_boxes'].shape[0]\n        if numbox > 0:\n            h = images[index].shape[0]\n            w = images[index].shape[1]\n            pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Union')\n            image_obj['total_boxes'] = image_obj['total_boxes'][pick, :]\n            regw = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0]\n            regh = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1]\n            qq1 = image_obj['total_boxes'][:, 0] + image_obj['total_boxes'][:, 5] * regw\n            qq2 = image_obj['total_boxes'][:, 1] + image_obj['total_boxes'][:, 6] * regh\n            qq3 = image_obj['total_boxes'][:, 2] + image_obj['total_boxes'][:, 7] * regw\n            qq4 = image_obj['total_boxes'][:, 3] + image_obj['total_boxes'][:, 8] * regh\n            image_obj['total_boxes'] = np.transpose(np.vstack([qq1, qq2, qq3, qq4, image_obj['total_boxes'][:, 4]]))\n            image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy())\n            image_obj['total_boxes'][:, 0:4] = np.fix(image_obj['total_boxes'][:, 0:4]).astype(np.int32)\n            dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h)\n\n            numbox = image_obj['total_boxes'].shape[0]\n            tempimg = np.zeros((24, 24, 3, numbox))\n\n            if numbox > 0:\n                for k in range(0, numbox):\n                    tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3))\n                    tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :]\n                    if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0:\n                        tempimg[:, :, :, k] = imresample(tmp, (24, 24))\n                    else:\n                        return np.empty()\n\n                tempimg = (tempimg - 127.5) * 0.0078125\n                image_obj['rnet_input'] = np.transpose(tempimg, (3, 1, 0, 2))\n\n    # # # # # # # # # # # # #\n    # second stage - refinement of face candidates with rnet\n    # # # # # # # # # # # # #\n\n    bulk_rnet_input = np.empty((0, 24, 24, 3))\n    for index, image_obj in enumerate(images_with_boxes):\n        if 'rnet_input' in image_obj:\n            bulk_rnet_input = np.append(bulk_rnet_input, image_obj['rnet_input'], axis=0)\n\n    out = rnet(bulk_rnet_input)\n    out0 = np.transpose(out[0])\n    out1 = np.transpose(out[1])\n    score = out1[1, :]\n\n    i = 0\n    for index, image_obj in enumerate(images_with_boxes):\n        if 'rnet_input' not in image_obj:\n            continue\n\n        rnet_input_count = image_obj['rnet_input'].shape[0]\n        score_per_image = score[i:i + rnet_input_count]\n        out0_per_image = out0[:, i:i + rnet_input_count]\n\n        ipass = np.where(score_per_image > threshold[1])\n        image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(),\n                                              np.expand_dims(score_per_image[ipass].copy(), 1)])\n\n        mv = out0_per_image[:, ipass[0]]\n\n        if image_obj['total_boxes'].shape[0] > 0:\n            h = images[index].shape[0]\n            w = images[index].shape[1]\n            pick = nms(image_obj['total_boxes'], 0.7, 'Union')\n            image_obj['total_boxes'] = image_obj['total_boxes'][pick, :]\n            image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv[:, pick]))\n            image_obj['total_boxes'] = rerec(image_obj['total_boxes'].copy())\n\n            numbox = image_obj['total_boxes'].shape[0]\n\n            if numbox > 0:\n                tempimg = np.zeros((48, 48, 3, numbox))\n                image_obj['total_boxes'] = np.fix(image_obj['total_boxes']).astype(np.int32)\n                dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph = pad(image_obj['total_boxes'].copy(), w, h)\n\n                for k in range(0, numbox):\n                    tmp = np.zeros((int(tmph[k]), int(tmpw[k]), 3))\n                    tmp[dy[k] - 1:edy[k], dx[k] - 1:edx[k], :] = images[index][y[k] - 1:ey[k], x[k] - 1:ex[k], :]\n                    if tmp.shape[0] > 0 and tmp.shape[1] > 0 or tmp.shape[0] == 0 and tmp.shape[1] == 0:\n                        tempimg[:, :, :, k] = imresample(tmp, (48, 48))\n                    else:\n                        return np.empty()\n                tempimg = (tempimg - 127.5) * 0.0078125\n                image_obj['onet_input'] = np.transpose(tempimg, (3, 1, 0, 2))\n\n        i += rnet_input_count\n\n    # # # # # # # # # # # # #\n    # third stage - further refinement and facial landmarks positions with onet\n    # # # # # # # # # # # # #\n\n    bulk_onet_input = np.empty((0, 48, 48, 3))\n    for index, image_obj in enumerate(images_with_boxes):\n        if 'onet_input' in image_obj:\n            bulk_onet_input = np.append(bulk_onet_input, image_obj['onet_input'], axis=0)\n\n    out = onet(bulk_onet_input)\n\n    out0 = np.transpose(out[0])\n    out1 = np.transpose(out[1])\n    out2 = np.transpose(out[2])\n    score = out2[1, :]\n    points = out1\n\n    i = 0\n    ret = []\n    for index, image_obj in enumerate(images_with_boxes):\n        if 'onet_input' not in image_obj:\n            ret.append(None)\n            continue\n\n        onet_input_count = image_obj['onet_input'].shape[0]\n\n        out0_per_image = out0[:, i:i + onet_input_count]\n        score_per_image = score[i:i + onet_input_count]\n        points_per_image = points[:, i:i + onet_input_count]\n\n        ipass = np.where(score_per_image > threshold[2])\n        points_per_image = points_per_image[:, ipass[0]]\n\n        image_obj['total_boxes'] = np.hstack([image_obj['total_boxes'][ipass[0], 0:4].copy(),\n                                              np.expand_dims(score_per_image[ipass].copy(), 1)])\n        mv = out0_per_image[:, ipass[0]]\n\n        w = image_obj['total_boxes'][:, 2] - image_obj['total_boxes'][:, 0] + 1\n        h = image_obj['total_boxes'][:, 3] - image_obj['total_boxes'][:, 1] + 1\n        points_per_image[0:5, :] = np.tile(w, (5, 1)) * points_per_image[0:5, :] + np.tile(\n            image_obj['total_boxes'][:, 0], (5, 1)) - 1\n        points_per_image[5:10, :] = np.tile(h, (5, 1)) * points_per_image[5:10, :] + np.tile(\n            image_obj['total_boxes'][:, 1], (5, 1)) - 1\n\n        if image_obj['total_boxes'].shape[0] > 0:\n            image_obj['total_boxes'] = bbreg(image_obj['total_boxes'].copy(), np.transpose(mv))\n            pick = nms(image_obj['total_boxes'].copy(), 0.7, 'Min')\n            image_obj['total_boxes'] = image_obj['total_boxes'][pick, :]\n            points_per_image = points_per_image[:, pick]\n\n            ret.append((image_obj['total_boxes'], points_per_image))\n        else:\n            ret.append(None)\n\n        i += onet_input_count\n\n    return ret\n\n\n# function [boundingbox] = bbreg(boundingbox,reg)\ndef bbreg(boundingbox,reg):\n    \"\"\"Calibrate bounding boxes\"\"\"\n    if reg.shape[1]==1:\n        reg = np.reshape(reg, (reg.shape[2], reg.shape[3]))\n\n    w = boundingbox[:,2]-boundingbox[:,0]+1\n    h = boundingbox[:,3]-boundingbox[:,1]+1\n    b1 = boundingbox[:,0]+reg[:,0]*w\n    b2 = boundingbox[:,1]+reg[:,1]*h\n    b3 = boundingbox[:,2]+reg[:,2]*w\n    b4 = boundingbox[:,3]+reg[:,3]*h\n    boundingbox[:,0:4] = np.transpose(np.vstack([b1, b2, b3, b4 ]))\n    return boundingbox\n \ndef generateBoundingBox(imap, reg, scale, t):\n    \"\"\"Use heatmap to generate bounding boxes\"\"\"\n    stride=2\n    cellsize=12\n\n    imap = np.transpose(imap)\n    dx1 = np.transpose(reg[:,:,0])\n    dy1 = np.transpose(reg[:,:,1])\n    dx2 = np.transpose(reg[:,:,2])\n    dy2 = np.transpose(reg[:,:,3])\n    y, x = np.where(imap >= t)\n    if y.shape[0]==1:\n        dx1 = np.flipud(dx1)\n        dy1 = np.flipud(dy1)\n        dx2 = np.flipud(dx2)\n        dy2 = np.flipud(dy2)\n    score = imap[(y,x)]\n    reg = np.transpose(np.vstack([ dx1[(y,x)], dy1[(y,x)], dx2[(y,x)], dy2[(y,x)] ]))\n    if reg.size==0:\n        reg = np.empty((0,3))\n    bb = np.transpose(np.vstack([y,x]))\n    q1 = np.fix((stride*bb+1)/scale)\n    q2 = np.fix((stride*bb+cellsize-1+1)/scale)\n    boundingbox = np.hstack([q1, q2, np.expand_dims(score,1), reg])\n    return boundingbox, reg\n \n# function pick = nms(boxes,threshold,type)\ndef nms(boxes, threshold, method):\n    if boxes.size==0:\n        return np.empty((0,3))\n    x1 = boxes[:,0]\n    y1 = boxes[:,1]\n    x2 = boxes[:,2]\n    y2 = boxes[:,3]\n    s = boxes[:,4]\n    area = (x2-x1+1) * (y2-y1+1)\n    I = np.argsort(s)\n    pick = np.zeros_like(s, dtype=np.int16)\n    counter = 0\n    while I.size>0:\n        i = I[-1]\n        pick[counter] = i\n        counter += 1\n        idx = I[0:-1]\n        xx1 = np.maximum(x1[i], x1[idx])\n        yy1 = np.maximum(y1[i], y1[idx])\n        xx2 = np.minimum(x2[i], x2[idx])\n        yy2 = np.minimum(y2[i], y2[idx])\n        w = np.maximum(0.0, xx2-xx1+1)\n        h = np.maximum(0.0, yy2-yy1+1)\n        inter = w * h\n        if method is 'Min':\n            o = inter / np.minimum(area[i], area[idx])\n        else:\n            o = inter / (area[i] + area[idx] - inter)\n        I = I[np.where(o<=threshold)]\n    pick = pick[0:counter]\n    return pick\n\n# function [dy edy dx edx y ey x ex tmpw tmph] = pad(total_boxes,w,h)\ndef pad(total_boxes, w, h):\n    \"\"\"Compute the padding coordinates (pad the bounding boxes to square)\"\"\"\n    tmpw = (total_boxes[:,2]-total_boxes[:,0]+1).astype(np.int32)\n    tmph = (total_boxes[:,3]-total_boxes[:,1]+1).astype(np.int32)\n    numbox = total_boxes.shape[0]\n\n    dx = np.ones((numbox), dtype=np.int32)\n    dy = np.ones((numbox), dtype=np.int32)\n    edx = tmpw.copy().astype(np.int32)\n    edy = tmph.copy().astype(np.int32)\n\n    x = total_boxes[:,0].copy().astype(np.int32)\n    y = total_boxes[:,1].copy().astype(np.int32)\n    ex = total_boxes[:,2].copy().astype(np.int32)\n    ey = total_boxes[:,3].copy().astype(np.int32)\n\n    tmp = np.where(ex>w)\n    edx.flat[tmp] = np.expand_dims(-ex[tmp]+w+tmpw[tmp],1)\n    ex[tmp] = w\n    \n    tmp = np.where(ey>h)\n    edy.flat[tmp] = np.expand_dims(-ey[tmp]+h+tmph[tmp],1)\n    ey[tmp] = h\n\n    tmp = np.where(x<1)\n    dx.flat[tmp] = np.expand_dims(2-x[tmp],1)\n    x[tmp] = 1\n\n    tmp = np.where(y<1)\n    dy.flat[tmp] = np.expand_dims(2-y[tmp],1)\n    y[tmp] = 1\n    \n    return dy, edy, dx, edx, y, ey, x, ex, tmpw, tmph\n\n# function [bboxA] = rerec(bboxA)\ndef rerec(bboxA):\n    \"\"\"Convert bboxA to square.\"\"\"\n    h = bboxA[:,3]-bboxA[:,1]\n    w = bboxA[:,2]-bboxA[:,0]\n    l = np.maximum(w, h)\n    bboxA[:,0] = bboxA[:,0]+w*0.5-l*0.5\n    bboxA[:,1] = bboxA[:,1]+h*0.5-l*0.5\n    bboxA[:,2:4] = bboxA[:,0:2] + np.transpose(np.tile(l,(2,1)))\n    return bboxA\n\ndef imresample(img, sz):\n    im_data = cv2.resize(img, (sz[1], sz[0]), interpolation=cv2.INTER_AREA) #@UndefinedVariable\n    return im_data\n\n    # This method is kept for debugging purpose\n#     h=img.shape[0]\n#     w=img.shape[1]\n#     hs, ws = sz\n#     dx = float(w) / ws\n#     dy = float(h) / hs\n#     im_data = np.zeros((hs,ws,3))\n#     for a1 in range(0,hs):\n#         for a2 in range(0,ws):\n#             for a3 in range(0,3):\n#                 im_data[a1,a2,a3] = img[int(floor(a1*dy)),int(floor(a2*dx)),a3]\n#     return im_data\n\n"
  },
  {
    "path": "src/calculate_filtering_metrics.py",
    "content": "\"\"\"Calculate filtering metrics for a dataset and store in a .hdf file.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport argparse\nimport facenet\nimport os\nimport sys\nimport time\nimport h5py\nimport math\nfrom tensorflow.python.platform import gfile\nfrom six import iteritems\n\ndef main(args):\n    dataset = facenet.get_dataset(args.dataset_dir)\n  \n    with tf.Graph().as_default():\n      \n        # Get a list of image paths and their labels\n        image_list, label_list = facenet.get_image_paths_and_labels(dataset)\n        nrof_images = len(image_list)\n        image_indices = range(nrof_images)\n\n        image_batch, label_batch = facenet.read_and_augment_data(image_list,\n            image_indices, args.image_size, args.batch_size, None, \n            False, False, False, nrof_preprocess_threads=4, shuffle=False)\n        \n        model_exp = os.path.expanduser(args.model_file)\n        with gfile.FastGFile(model_exp,'rb') as f:\n            graph_def = tf.GraphDef()\n            graph_def.ParseFromString(f.read())\n            input_map={'input':image_batch, 'phase_train':False}\n            tf.import_graph_def(graph_def, input_map=input_map, name='net')\n        \n        embeddings = tf.get_default_graph().get_tensor_by_name(\"net/embeddings:0\")\n\n        with tf.Session() as sess:\n            tf.train.start_queue_runners(sess=sess)\n                \n            embedding_size = int(embeddings.get_shape()[1])\n            nrof_batches = int(math.ceil(nrof_images / args.batch_size))\n            nrof_classes = len(dataset)\n            label_array = np.array(label_list)\n            class_names = [cls.name for cls in dataset]\n            nrof_examples_per_class = [ len(cls.image_paths) for cls in dataset ]\n            class_variance = np.zeros((nrof_classes,))\n            class_center = np.zeros((nrof_classes,embedding_size))\n            distance_to_center = np.ones((len(label_list),))*np.NaN\n            emb_array = np.zeros((0,embedding_size))\n            idx_array = np.zeros((0,), dtype=np.int32)\n            lab_array = np.zeros((0,), dtype=np.int32)\n            index_arr = np.append(0, np.cumsum(nrof_examples_per_class))\n            for i in range(nrof_batches):\n                t = time.time()\n                emb, idx = sess.run([embeddings, label_batch])\n                emb_array = np.append(emb_array, emb, axis=0)\n                idx_array = np.append(idx_array, idx, axis=0)\n                lab_array = np.append(lab_array, label_array[idx], axis=0)\n                for cls in set(lab_array):\n                    cls_idx = np.where(lab_array==cls)[0]\n                    if cls_idx.shape[0]==nrof_examples_per_class[cls]:\n                        # We have calculated all the embeddings for this class\n                        i2 = np.argsort(idx_array[cls_idx])\n                        emb_class = emb_array[cls_idx,:]\n                        emb_sort = emb_class[i2,:]\n                        center = np.mean(emb_sort, axis=0)\n                        diffs = emb_sort - center\n                        dists_sqr = np.sum(np.square(diffs), axis=1)\n                        class_variance[cls] = np.mean(dists_sqr)\n                        class_center[cls,:] = center\n                        distance_to_center[index_arr[cls]:index_arr[cls+1]] = np.sqrt(dists_sqr)\n                        emb_array = np.delete(emb_array, cls_idx, axis=0)\n                        idx_array = np.delete(idx_array, cls_idx, axis=0)\n                        lab_array = np.delete(lab_array, cls_idx, axis=0)\n\n                        \n                print('Batch %d in %.3f seconds' % (i, time.time()-t))\n                \n            print('Writing filtering data to %s' % args.data_file_name)\n            mdict = {'class_names':class_names, 'image_list':image_list, 'label_list':label_list, 'distance_to_center':distance_to_center }\n            with h5py.File(args.data_file_name, 'w') as f:\n                for key, value in iteritems(mdict):\n                    f.create_dataset(key, data=value)\n                        \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('dataset_dir', type=str,\n        help='Path to the directory containing aligned dataset.')\n    parser.add_argument('model_file', type=str,\n        help='File containing the frozen model in protobuf (.pb) format to use for feature extraction.')\n    parser.add_argument('data_file_name', type=str,\n        help='The name of the file to store filtering data in.')\n    parser.add_argument('--image_size', type=int,\n        help='Image size.', default=160)\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=90)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/classifier.py",
    "content": "\"\"\"An example of how to use your own dataset to train a classifier that recognizes people.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport argparse\nimport facenet\nimport os\nimport sys\nimport math\nimport pickle\nfrom sklearn.svm import SVC\n\ndef main(args):\n  \n    with tf.Graph().as_default():\n      \n        with tf.Session() as sess:\n            \n            np.random.seed(seed=args.seed)\n            \n            if args.use_split_dataset:\n                dataset_tmp = facenet.get_dataset(args.data_dir)\n                train_set, test_set = split_dataset(dataset_tmp, args.min_nrof_images_per_class, args.nrof_train_images_per_class)\n                if (args.mode=='TRAIN'):\n                    dataset = train_set\n                elif (args.mode=='CLASSIFY'):\n                    dataset = test_set\n            else:\n                dataset = facenet.get_dataset(args.data_dir)\n\n            # Check that there are at least one training image per class\n            for cls in dataset:\n                assert(len(cls.image_paths)>0, 'There must be at least one image for each class in the dataset')            \n\n                 \n            paths, labels = facenet.get_image_paths_and_labels(dataset)\n            \n            print('Number of classes: %d' % len(dataset))\n            print('Number of images: %d' % len(paths))\n            \n            # Load the model\n            print('Loading feature extraction model')\n            facenet.load_model(args.model)\n            \n            # Get input and output tensors\n            images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n            embedding_size = embeddings.get_shape()[1]\n            \n            # Run forward pass to calculate embeddings\n            print('Calculating features for images')\n            nrof_images = len(paths)\n            nrof_batches_per_epoch = int(math.ceil(1.0*nrof_images / args.batch_size))\n            emb_array = np.zeros((nrof_images, embedding_size))\n            for i in range(nrof_batches_per_epoch):\n                start_index = i*args.batch_size\n                end_index = min((i+1)*args.batch_size, nrof_images)\n                paths_batch = paths[start_index:end_index]\n                images = facenet.load_data(paths_batch, False, False, args.image_size)\n                feed_dict = { images_placeholder:images, phase_train_placeholder:False }\n                emb_array[start_index:end_index,:] = sess.run(embeddings, feed_dict=feed_dict)\n            \n            classifier_filename_exp = os.path.expanduser(args.classifier_filename)\n\n            if (args.mode=='TRAIN'):\n                # Train classifier\n                print('Training classifier')\n                model = SVC(kernel='linear', probability=True)\n                model.fit(emb_array, labels)\n            \n                # Create a list of class names\n                class_names = [ cls.name.replace('_', ' ') for cls in dataset]\n\n                # Saving classifier model\n                with open(classifier_filename_exp, 'wb') as outfile:\n                    pickle.dump((model, class_names), outfile)\n                print('Saved classifier model to file \"%s\"' % classifier_filename_exp)\n                \n            elif (args.mode=='CLASSIFY'):\n                # Classify images\n                print('Testing classifier')\n                with open(classifier_filename_exp, 'rb') as infile:\n                    (model, class_names) = pickle.load(infile)\n\n                print('Loaded classifier model from file \"%s\"' % classifier_filename_exp)\n\n                predictions = model.predict_proba(emb_array)\n                best_class_indices = np.argmax(predictions, axis=1)\n                best_class_probabilities = predictions[np.arange(len(best_class_indices)), best_class_indices]\n                \n                for i in range(len(best_class_indices)):\n                    print('%4d  %s: %.3f' % (i, class_names[best_class_indices[i]], best_class_probabilities[i]))\n                    \n                accuracy = np.mean(np.equal(best_class_indices, labels))\n                print('Accuracy: %.3f' % accuracy)\n                \n            \ndef split_dataset(dataset, min_nrof_images_per_class, nrof_train_images_per_class):\n    train_set = []\n    test_set = []\n    for cls in dataset:\n        paths = cls.image_paths\n        # Remove classes with less than min_nrof_images_per_class\n        if len(paths)>=min_nrof_images_per_class:\n            np.random.shuffle(paths)\n            train_set.append(facenet.ImageClass(cls.name, paths[:nrof_train_images_per_class]))\n            test_set.append(facenet.ImageClass(cls.name, paths[nrof_train_images_per_class:]))\n    return train_set, test_set\n\n            \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('mode', type=str, choices=['TRAIN', 'CLASSIFY'],\n        help='Indicates if a new classifier should be trained or a classification ' + \n        'model should be used for classification', default='CLASSIFY')\n    parser.add_argument('data_dir', type=str,\n        help='Path to the data directory containing aligned LFW face patches.')\n    parser.add_argument('model', type=str, \n        help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')\n    parser.add_argument('classifier_filename', \n        help='Classifier model file name as a pickle (.pkl) file. ' + \n        'For training this is the output and for classification this is an input.')\n    parser.add_argument('--use_split_dataset', \n        help='Indicates that the dataset specified by data_dir should be split into a training and test set. ' +  \n        'Otherwise a separate test set can be specified using the test_data_dir option.', action='store_true')\n    parser.add_argument('--test_data_dir', type=str,\n        help='Path to the test data directory containing aligned images used for testing.')\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=90)\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    parser.add_argument('--min_nrof_images_per_class', type=int,\n        help='Only include classes with at least this number of images in the dataset', default=20)\n    parser.add_argument('--nrof_train_images_per_class', type=int,\n        help='Use this number of images from each class for training and the rest for testing', default=10)\n    \n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/compare.py",
    "content": "\"\"\"Performs face alignment and calculates L2 distance between the embeddings of images.\"\"\"\n\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport tensorflow as tf\nimport numpy as np\nimport sys\nimport os\nimport copy\nimport argparse\nimport facenet\nimport align.detect_face\n\ndef main(args):\n\n    images = load_and_align_data(args.image_files, args.image_size, args.margin, args.gpu_memory_fraction)\n    with tf.Graph().as_default():\n\n        with tf.Session() as sess:\n      \n            # Load the model\n            facenet.load_model(args.model)\n    \n            # Get input and output tensors\n            images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n\n            # Run forward pass to calculate embeddings\n            feed_dict = { images_placeholder: images, phase_train_placeholder:False }\n            emb = sess.run(embeddings, feed_dict=feed_dict)\n            \n            nrof_images = len(args.image_files)\n\n            print('Images:')\n            for i in range(nrof_images):\n                print('%1d: %s' % (i, args.image_files[i]))\n            print('')\n            \n            # Print distance matrix\n            print('Distance matrix')\n            print('    ', end='')\n            for i in range(nrof_images):\n                print('    %1d     ' % i, end='')\n            print('')\n            for i in range(nrof_images):\n                print('%1d  ' % i, end='')\n                for j in range(nrof_images):\n                    dist = np.sqrt(np.sum(np.square(np.subtract(emb[i,:], emb[j,:]))))\n                    print('  %1.4f  ' % dist, end='')\n                print('')\n            \n            \ndef load_and_align_data(image_paths, image_size, margin, gpu_memory_fraction):\n\n    minsize = 20 # minimum size of face\n    threshold = [ 0.6, 0.7, 0.7 ]  # three steps's threshold\n    factor = 0.709 # scale factor\n    \n    print('Creating networks and loading parameters')\n    with tf.Graph().as_default():\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        with sess.as_default():\n            pnet, rnet, onet = align.detect_face.create_mtcnn(sess, None)\n  \n    tmp_image_paths=copy.copy(image_paths)\n    img_list = []\n    for image in tmp_image_paths:\n        img = misc.imread(os.path.expanduser(image), mode='RGB')\n        img_size = np.asarray(img.shape)[0:2]\n        bounding_boxes, _ = align.detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)\n        if len(bounding_boxes) < 1:\n          image_paths.remove(image)\n          print(\"can't detect face, remove \", image)\n          continue\n        det = np.squeeze(bounding_boxes[0,0:4])\n        bb = np.zeros(4, dtype=np.int32)\n        bb[0] = np.maximum(det[0]-margin/2, 0)\n        bb[1] = np.maximum(det[1]-margin/2, 0)\n        bb[2] = np.minimum(det[2]+margin/2, img_size[1])\n        bb[3] = np.minimum(det[3]+margin/2, img_size[0])\n        cropped = img[bb[1]:bb[3],bb[0]:bb[2],:]\n        aligned = misc.imresize(cropped, (image_size, image_size), interp='bilinear')\n        prewhitened = facenet.prewhiten(aligned)\n        img_list.append(prewhitened)\n    images = np.stack(img_list)\n    return images\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('model', type=str, \n        help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')\n    parser.add_argument('image_files', type=str, nargs='+', help='Images to compare')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--margin', type=int,\n        help='Margin for the crop around the bounding box (height, width) in pixels.', default=44)\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/decode_msceleb_dataset.py",
    "content": "\"\"\"Decode the MsCelebV1 dataset in TSV (tab separated values) format downloaded from\nhttps://www.microsoft.com/en-us/research/project/ms-celeb-1m-challenge-recognizing-one-million-celebrities-real-world/\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport numpy as np\nimport base64\nimport sys\nimport os\nimport cv2\nimport argparse\nimport facenet\n\n\n# File format: text files, each line is an image record containing 6 columns, delimited by TAB.\n# Column1: Freebase MID\n# Column2: Query/Name\n# Column3: ImageSearchRank\n# Column4: ImageURL\n# Column5: PageURL\n# Column6: ImageData_Base64Encoded\n\ndef main(args):\n    output_dir = os.path.expanduser(args.output_dir)\n  \n    if not os.path.exists(output_dir):\n        os.mkdir(output_dir)\n  \n    # Store some git revision info in a text file in the output directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))\n    \n    i = 0\n    for f in args.tsv_files:\n        for line in f:\n            fields = line.split('\\t')\n            class_dir = fields[0]\n            img_name = fields[1] + '-' + fields[4] + '.' + args.output_format\n            img_string = fields[5]\n            img_dec_string = base64.b64decode(img_string)\n            img_data = np.fromstring(img_dec_string, dtype=np.uint8)\n            img = cv2.imdecode(img_data, cv2.IMREAD_COLOR) #pylint: disable=maybe-no-member\n            if args.size:\n                img = misc.imresize(img, (args.size, args.size), interp='bilinear')\n            full_class_dir = os.path.join(output_dir, class_dir)\n            if not os.path.exists(full_class_dir):\n                os.mkdir(full_class_dir)\n            full_path = os.path.join(full_class_dir, img_name.replace('/','_'))\n            cv2.imwrite(full_path, img) #pylint: disable=maybe-no-member\n            print('%8d: %s' % (i, full_path))\n            i += 1\n  \nif __name__ == '__main__':\n    parser = argparse.ArgumentParser()\n\n    parser.add_argument('output_dir', type=str, help='Output base directory for the image dataset')\n    parser.add_argument('tsv_files', type=argparse.FileType('r'), nargs='+', help='Input TSV file name(s)')\n    parser.add_argument('--size', type=int, help='Images are resized to the given size')\n    parser.add_argument('--output_format', type=str, help='Format of the output images', default='png', choices=['png', 'jpg'])\n\n    main(parser.parse_args())\n\n"
  },
  {
    "path": "src/download_and_extract.py",
    "content": "import requests\nimport zipfile\nimport os\n\nmodel_dict = {\n    'lfw-subset':      '1B5BQUZuJO-paxdN8UclxeHAR1WnR_Tzi', \n    '20170131-234652': '0B5MzpY9kBtDVSGM0RmVET2EwVEk',\n    '20170216-091149': '0B5MzpY9kBtDVTGZjcWkzT3pldDA',\n    '20170512-110547': '0B5MzpY9kBtDVZ2RpVDYwWmxoSUk',\n    '20180402-114759': '1EXPBSXwTaqrSC0OhUdXNmKSh9qJUQ55-'\n    }\n\ndef download_and_extract_file(model_name, data_dir):\n    file_id = model_dict[model_name]\n    destination = os.path.join(data_dir, model_name + '.zip')\n    if not os.path.exists(destination):\n        print('Downloading file to %s' % destination)\n        download_file_from_google_drive(file_id, destination)\n        with zipfile.ZipFile(destination, 'r') as zip_ref:\n            print('Extracting file to %s' % data_dir)\n            zip_ref.extractall(data_dir)\n\ndef download_file_from_google_drive(file_id, destination):\n    \n        URL = \"https://drive.google.com/uc?export=download\"\n    \n        session = requests.Session()\n    \n        response = session.get(URL, params = { 'id' : file_id }, stream = True)\n        token = get_confirm_token(response)\n    \n        if token:\n            params = { 'id' : file_id, 'confirm' : token }\n            response = session.get(URL, params = params, stream = True)\n    \n        save_response_content(response, destination)    \n\ndef get_confirm_token(response):\n    for key, value in response.cookies.items():\n        if key.startswith('download_warning'):\n            return value\n\n    return None\n\ndef save_response_content(response, destination):\n    CHUNK_SIZE = 32768\n\n    with open(destination, \"wb\") as f:\n        for chunk in response.iter_content(CHUNK_SIZE):\n            if chunk: # filter out keep-alive new chunks\n                f.write(chunk)\n"
  },
  {
    "path": "src/facenet.py",
    "content": "\"\"\"Functions for building the face recognition network.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport os\nfrom subprocess import Popen, PIPE\nimport tensorflow as tf\nimport numpy as np\nfrom scipy import misc\nfrom sklearn.model_selection import KFold\nfrom scipy import interpolate\nfrom tensorflow.python.training import training\nimport random\nimport re\nfrom tensorflow.python.platform import gfile\nimport math\nfrom six import iteritems\n\ndef triplet_loss(anchor, positive, negative, alpha):\n    \"\"\"Calculate the triplet loss according to the FaceNet paper\n    \n    Args:\n      anchor: the embeddings for the anchor images.\n      positive: the embeddings for the positive images.\n      negative: the embeddings for the negative images.\n  \n    Returns:\n      the triplet loss according to the FaceNet paper as a float tensor.\n    \"\"\"\n    with tf.variable_scope('triplet_loss'):\n        pos_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, positive)), 1)\n        neg_dist = tf.reduce_sum(tf.square(tf.subtract(anchor, negative)), 1)\n        \n        basic_loss = tf.add(tf.subtract(pos_dist,neg_dist), alpha)\n        loss = tf.reduce_mean(tf.maximum(basic_loss, 0.0), 0)\n      \n    return loss\n  \ndef center_loss(features, label, alfa, nrof_classes):\n    \"\"\"Center loss based on the paper \"A Discriminative Feature Learning Approach for Deep Face Recognition\"\n       (http://ydwen.github.io/papers/WenECCV16.pdf)\n    \"\"\"\n    nrof_features = features.get_shape()[1]\n    centers = tf.get_variable('centers', [nrof_classes, nrof_features], dtype=tf.float32,\n        initializer=tf.constant_initializer(0), trainable=False)\n    label = tf.reshape(label, [-1])\n    centers_batch = tf.gather(centers, label)\n    diff = (1 - alfa) * (centers_batch - features)\n    centers = tf.scatter_sub(centers, label, diff)\n    with tf.control_dependencies([centers]):\n        loss = tf.reduce_mean(tf.square(features - centers_batch))\n    return loss, centers\n\ndef get_image_paths_and_labels(dataset):\n    image_paths_flat = []\n    labels_flat = []\n    for i in range(len(dataset)):\n        image_paths_flat += dataset[i].image_paths\n        labels_flat += [i] * len(dataset[i].image_paths)\n    return image_paths_flat, labels_flat\n\ndef shuffle_examples(image_paths, labels):\n    shuffle_list = list(zip(image_paths, labels))\n    random.shuffle(shuffle_list)\n    image_paths_shuff, labels_shuff = zip(*shuffle_list)\n    return image_paths_shuff, labels_shuff\n\ndef random_rotate_image(image):\n    angle = np.random.uniform(low=-10.0, high=10.0)\n    return misc.imrotate(image, angle, 'bicubic')\n  \n# 1: Random rotate 2: Random crop  4: Random flip  8:  Fixed image standardization  16: Flip\nRANDOM_ROTATE = 1\nRANDOM_CROP = 2\nRANDOM_FLIP = 4\nFIXED_STANDARDIZATION = 8\nFLIP = 16\ndef create_input_pipeline(input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder):\n    images_and_labels_list = []\n    for _ in range(nrof_preprocess_threads):\n        filenames, label, control = input_queue.dequeue()\n        images = []\n        for filename in tf.unstack(filenames):\n            file_contents = tf.read_file(filename)\n            image = tf.image.decode_image(file_contents, 3)\n            image = tf.cond(get_control_flag(control[0], RANDOM_ROTATE),\n                            lambda:tf.py_func(random_rotate_image, [image], tf.uint8), \n                            lambda:tf.identity(image))\n            image = tf.cond(get_control_flag(control[0], RANDOM_CROP), \n                            lambda:tf.random_crop(image, image_size + (3,)), \n                            lambda:tf.image.resize_image_with_crop_or_pad(image, image_size[0], image_size[1]))\n            image = tf.cond(get_control_flag(control[0], RANDOM_FLIP),\n                            lambda:tf.image.random_flip_left_right(image),\n                            lambda:tf.identity(image))\n            image = tf.cond(get_control_flag(control[0], FIXED_STANDARDIZATION),\n                            lambda:(tf.cast(image, tf.float32) - 127.5)/128.0,\n                            lambda:tf.image.per_image_standardization(image))\n            image = tf.cond(get_control_flag(control[0], FLIP),\n                            lambda:tf.image.flip_left_right(image),\n                            lambda:tf.identity(image))\n            #pylint: disable=no-member\n            image.set_shape(image_size + (3,))\n            images.append(image)\n        images_and_labels_list.append([images, label])\n\n    image_batch, label_batch = tf.train.batch_join(\n        images_and_labels_list, batch_size=batch_size_placeholder, \n        shapes=[image_size + (3,), ()], enqueue_many=True,\n        capacity=4 * nrof_preprocess_threads * 100,\n        allow_smaller_final_batch=True)\n    \n    return image_batch, label_batch\n\ndef get_control_flag(control, field):\n    return tf.equal(tf.mod(tf.floor_div(control, field), 2), 1)\n  \ndef _add_loss_summaries(total_loss):\n    \"\"\"Add summaries for losses.\n  \n    Generates moving average for all losses and associated summaries for\n    visualizing the performance of the network.\n  \n    Args:\n      total_loss: Total loss from loss().\n    Returns:\n      loss_averages_op: op for generating moving averages of losses.\n    \"\"\"\n    # Compute the moving average of all individual losses and the total loss.\n    loss_averages = tf.train.ExponentialMovingAverage(0.9, name='avg')\n    losses = tf.get_collection('losses')\n    loss_averages_op = loss_averages.apply(losses + [total_loss])\n  \n    # Attach a scalar summmary to all individual losses and the total loss; do the\n    # same for the averaged version of the losses.\n    for l in losses + [total_loss]:\n        # Name each loss as '(raw)' and name the moving average version of the loss\n        # as the original loss name.\n        tf.summary.scalar(l.op.name +' (raw)', l)\n        tf.summary.scalar(l.op.name, loss_averages.average(l))\n  \n    return loss_averages_op\n\ndef train(total_loss, global_step, optimizer, learning_rate, moving_average_decay, update_gradient_vars, log_histograms=True):\n    # Generate moving averages of all losses and associated summaries.\n    loss_averages_op = _add_loss_summaries(total_loss)\n\n    # Compute gradients.\n    with tf.control_dependencies([loss_averages_op]):\n        if optimizer=='ADAGRAD':\n            opt = tf.train.AdagradOptimizer(learning_rate)\n        elif optimizer=='ADADELTA':\n            opt = tf.train.AdadeltaOptimizer(learning_rate, rho=0.9, epsilon=1e-6)\n        elif optimizer=='ADAM':\n            opt = tf.train.AdamOptimizer(learning_rate, beta1=0.9, beta2=0.999, epsilon=0.1)\n        elif optimizer=='RMSPROP':\n            opt = tf.train.RMSPropOptimizer(learning_rate, decay=0.9, momentum=0.9, epsilon=1.0)\n        elif optimizer=='MOM':\n            opt = tf.train.MomentumOptimizer(learning_rate, 0.9, use_nesterov=True)\n        else:\n            raise ValueError('Invalid optimization algorithm')\n    \n        grads = opt.compute_gradients(total_loss, update_gradient_vars)\n        \n    # Apply gradients.\n    apply_gradient_op = opt.apply_gradients(grads, global_step=global_step)\n  \n    # Add histograms for trainable variables.\n    if log_histograms:\n        for var in tf.trainable_variables():\n            tf.summary.histogram(var.op.name, var)\n   \n    # Add histograms for gradients.\n    if log_histograms:\n        for grad, var in grads:\n            if grad is not None:\n                tf.summary.histogram(var.op.name + '/gradients', grad)\n  \n    # Track the moving averages of all trainable variables.\n    variable_averages = tf.train.ExponentialMovingAverage(\n        moving_average_decay, global_step)\n    variables_averages_op = variable_averages.apply(tf.trainable_variables())\n  \n    with tf.control_dependencies([apply_gradient_op, variables_averages_op]):\n        train_op = tf.no_op(name='train')\n  \n    return train_op\n\ndef prewhiten(x):\n    mean = np.mean(x)\n    std = np.std(x)\n    std_adj = np.maximum(std, 1.0/np.sqrt(x.size))\n    y = np.multiply(np.subtract(x, mean), 1/std_adj)\n    return y  \n\ndef crop(image, random_crop, image_size):\n    if image.shape[1]>image_size:\n        sz1 = int(image.shape[1]//2)\n        sz2 = int(image_size//2)\n        if random_crop:\n            diff = sz1-sz2\n            (h, v) = (np.random.randint(-diff, diff+1), np.random.randint(-diff, diff+1))\n        else:\n            (h, v) = (0,0)\n        image = image[(sz1-sz2+v):(sz1+sz2+v),(sz1-sz2+h):(sz1+sz2+h),:]\n    return image\n  \ndef flip(image, random_flip):\n    if random_flip and np.random.choice([True, False]):\n        image = np.fliplr(image)\n    return image\n\ndef to_rgb(img):\n    w, h = img.shape\n    ret = np.empty((w, h, 3), dtype=np.uint8)\n    ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img\n    return ret\n  \ndef load_data(image_paths, do_random_crop, do_random_flip, image_size, do_prewhiten=True):\n    nrof_samples = len(image_paths)\n    images = np.zeros((nrof_samples, image_size, image_size, 3))\n    for i in range(nrof_samples):\n        img = misc.imread(image_paths[i])\n        if img.ndim == 2:\n            img = to_rgb(img)\n        if do_prewhiten:\n            img = prewhiten(img)\n        img = crop(img, do_random_crop, image_size)\n        img = flip(img, do_random_flip)\n        images[i,:,:,:] = img\n    return images\n\ndef get_label_batch(label_data, batch_size, batch_index):\n    nrof_examples = np.size(label_data, 0)\n    j = batch_index*batch_size % nrof_examples\n    if j+batch_size<=nrof_examples:\n        batch = label_data[j:j+batch_size]\n    else:\n        x1 = label_data[j:nrof_examples]\n        x2 = label_data[0:nrof_examples-j]\n        batch = np.vstack([x1,x2])\n    batch_int = batch.astype(np.int64)\n    return batch_int\n\ndef get_batch(image_data, batch_size, batch_index):\n    nrof_examples = np.size(image_data, 0)\n    j = batch_index*batch_size % nrof_examples\n    if j+batch_size<=nrof_examples:\n        batch = image_data[j:j+batch_size,:,:,:]\n    else:\n        x1 = image_data[j:nrof_examples,:,:,:]\n        x2 = image_data[0:nrof_examples-j,:,:,:]\n        batch = np.vstack([x1,x2])\n    batch_float = batch.astype(np.float32)\n    return batch_float\n\ndef get_triplet_batch(triplets, batch_index, batch_size):\n    ax, px, nx = triplets\n    a = get_batch(ax, int(batch_size/3), batch_index)\n    p = get_batch(px, int(batch_size/3), batch_index)\n    n = get_batch(nx, int(batch_size/3), batch_index)\n    batch = np.vstack([a, p, n])\n    return batch\n\ndef get_learning_rate_from_file(filename, epoch):\n    with open(filename, 'r') as f:\n        for line in f.readlines():\n            line = line.split('#', 1)[0]\n            if line:\n                par = line.strip().split(':')\n                e = int(par[0])\n                if par[1]=='-':\n                    lr = -1\n                else:\n                    lr = float(par[1])\n                if e <= epoch:\n                    learning_rate = lr\n                else:\n                    return learning_rate\n\nclass ImageClass():\n    \"Stores the paths to images for a given class\"\n    def __init__(self, name, image_paths):\n        self.name = name\n        self.image_paths = image_paths\n  \n    def __str__(self):\n        return self.name + ', ' + str(len(self.image_paths)) + ' images'\n  \n    def __len__(self):\n        return len(self.image_paths)\n  \ndef get_dataset(path, has_class_directories=True):\n    dataset = []\n    path_exp = os.path.expanduser(path)\n    classes = [path for path in os.listdir(path_exp) \\\n                    if os.path.isdir(os.path.join(path_exp, path))]\n    classes.sort()\n    nrof_classes = len(classes)\n    for i in range(nrof_classes):\n        class_name = classes[i]\n        facedir = os.path.join(path_exp, class_name)\n        image_paths = get_image_paths(facedir)\n        dataset.append(ImageClass(class_name, image_paths))\n  \n    return dataset\n\ndef get_image_paths(facedir):\n    image_paths = []\n    if os.path.isdir(facedir):\n        images = os.listdir(facedir)\n        image_paths = [os.path.join(facedir,img) for img in images]\n    return image_paths\n  \ndef split_dataset(dataset, split_ratio, min_nrof_images_per_class, mode):\n    if mode=='SPLIT_CLASSES':\n        nrof_classes = len(dataset)\n        class_indices = np.arange(nrof_classes)\n        np.random.shuffle(class_indices)\n        split = int(round(nrof_classes*(1-split_ratio)))\n        train_set = [dataset[i] for i in class_indices[0:split]]\n        test_set = [dataset[i] for i in class_indices[split:-1]]\n    elif mode=='SPLIT_IMAGES':\n        train_set = []\n        test_set = []\n        for cls in dataset:\n            paths = cls.image_paths\n            np.random.shuffle(paths)\n            nrof_images_in_class = len(paths)\n            split = int(math.floor(nrof_images_in_class*(1-split_ratio)))\n            if split==nrof_images_in_class:\n                split = nrof_images_in_class-1\n            if split>=min_nrof_images_per_class and nrof_images_in_class-split>=1:\n                train_set.append(ImageClass(cls.name, paths[:split]))\n                test_set.append(ImageClass(cls.name, paths[split:]))\n    else:\n        raise ValueError('Invalid train/test split mode \"%s\"' % mode)\n    return train_set, test_set\n\ndef load_model(model, input_map=None):\n    # Check if the model is a model directory (containing a metagraph and a checkpoint file)\n    #  or if it is a protobuf file with a frozen graph\n    model_exp = os.path.expanduser(model)\n    if (os.path.isfile(model_exp)):\n        print('Model filename: %s' % model_exp)\n        with gfile.FastGFile(model_exp,'rb') as f:\n            graph_def = tf.GraphDef()\n            graph_def.ParseFromString(f.read())\n            tf.import_graph_def(graph_def, input_map=input_map, name='')\n    else:\n        print('Model directory: %s' % model_exp)\n        meta_file, ckpt_file = get_model_filenames(model_exp)\n        \n        print('Metagraph file: %s' % meta_file)\n        print('Checkpoint file: %s' % ckpt_file)\n      \n        saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)\n        saver.restore(tf.get_default_session(), os.path.join(model_exp, ckpt_file))\n    \ndef get_model_filenames(model_dir):\n    files = os.listdir(model_dir)\n    meta_files = [s for s in files if s.endswith('.meta')]\n    if len(meta_files)==0:\n        raise ValueError('No meta file found in the model directory (%s)' % model_dir)\n    elif len(meta_files)>1:\n        raise ValueError('There should not be more than one meta file in the model directory (%s)' % model_dir)\n    meta_file = meta_files[0]\n    ckpt = tf.train.get_checkpoint_state(model_dir)\n    if ckpt and ckpt.model_checkpoint_path:\n        ckpt_file = os.path.basename(ckpt.model_checkpoint_path)\n        return meta_file, ckpt_file\n\n    meta_files = [s for s in files if '.ckpt' in s]\n    max_step = -1\n    for f in files:\n        step_str = re.match(r'(^model-[\\w\\- ]+.ckpt-(\\d+))', f)\n        if step_str is not None and len(step_str.groups())>=2:\n            step = int(step_str.groups()[1])\n            if step > max_step:\n                max_step = step\n                ckpt_file = step_str.groups()[0]\n    return meta_file, ckpt_file\n  \ndef distance(embeddings1, embeddings2, distance_metric=0):\n    if distance_metric==0:\n        # Euclidian distance\n        diff = np.subtract(embeddings1, embeddings2)\n        dist = np.sum(np.square(diff),1)\n    elif distance_metric==1:\n        # Distance based on cosine similarity\n        dot = np.sum(np.multiply(embeddings1, embeddings2), axis=1)\n        norm = np.linalg.norm(embeddings1, axis=1) * np.linalg.norm(embeddings2, axis=1)\n        similarity = dot / norm\n        dist = np.arccos(similarity) / math.pi\n    else:\n        raise 'Undefined distance metric %d' % distance_metric \n        \n    return dist\n\ndef calculate_roc(thresholds, embeddings1, embeddings2, actual_issame, nrof_folds=10, distance_metric=0, subtract_mean=False):\n    assert(embeddings1.shape[0] == embeddings2.shape[0])\n    assert(embeddings1.shape[1] == embeddings2.shape[1])\n    nrof_pairs = min(len(actual_issame), embeddings1.shape[0])\n    nrof_thresholds = len(thresholds)\n    k_fold = KFold(n_splits=nrof_folds, shuffle=False)\n    \n    tprs = np.zeros((nrof_folds,nrof_thresholds))\n    fprs = np.zeros((nrof_folds,nrof_thresholds))\n    accuracy = np.zeros((nrof_folds))\n    \n    indices = np.arange(nrof_pairs)\n    \n    for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)):\n        if subtract_mean:\n            mean = np.mean(np.concatenate([embeddings1[train_set], embeddings2[train_set]]), axis=0)\n        else:\n          mean = 0.0\n        dist = distance(embeddings1-mean, embeddings2-mean, distance_metric)\n        \n        # Find the best threshold for the fold\n        acc_train = np.zeros((nrof_thresholds))\n        for threshold_idx, threshold in enumerate(thresholds):\n            _, _, acc_train[threshold_idx] = calculate_accuracy(threshold, dist[train_set], actual_issame[train_set])\n        best_threshold_index = np.argmax(acc_train)\n        for threshold_idx, threshold in enumerate(thresholds):\n            tprs[fold_idx,threshold_idx], fprs[fold_idx,threshold_idx], _ = calculate_accuracy(threshold, dist[test_set], actual_issame[test_set])\n        _, _, accuracy[fold_idx] = calculate_accuracy(thresholds[best_threshold_index], dist[test_set], actual_issame[test_set])\n          \n        tpr = np.mean(tprs,0)\n        fpr = np.mean(fprs,0)\n    return tpr, fpr, accuracy\n\ndef calculate_accuracy(threshold, dist, actual_issame):\n    predict_issame = np.less(dist, threshold)\n    tp = np.sum(np.logical_and(predict_issame, actual_issame))\n    fp = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))\n    tn = np.sum(np.logical_and(np.logical_not(predict_issame), np.logical_not(actual_issame)))\n    fn = np.sum(np.logical_and(np.logical_not(predict_issame), actual_issame))\n  \n    tpr = 0 if (tp+fn==0) else float(tp) / float(tp+fn)\n    fpr = 0 if (fp+tn==0) else float(fp) / float(fp+tn)\n    acc = float(tp+tn)/dist.size\n    return tpr, fpr, acc\n\n\n  \ndef calculate_val(thresholds, embeddings1, embeddings2, actual_issame, far_target, nrof_folds=10, distance_metric=0, subtract_mean=False):\n    assert(embeddings1.shape[0] == embeddings2.shape[0])\n    assert(embeddings1.shape[1] == embeddings2.shape[1])\n    nrof_pairs = min(len(actual_issame), embeddings1.shape[0])\n    nrof_thresholds = len(thresholds)\n    k_fold = KFold(n_splits=nrof_folds, shuffle=False)\n    \n    val = np.zeros(nrof_folds)\n    far = np.zeros(nrof_folds)\n    \n    indices = np.arange(nrof_pairs)\n    \n    for fold_idx, (train_set, test_set) in enumerate(k_fold.split(indices)):\n        if subtract_mean:\n            mean = np.mean(np.concatenate([embeddings1[train_set], embeddings2[train_set]]), axis=0)\n        else:\n          mean = 0.0\n        dist = distance(embeddings1-mean, embeddings2-mean, distance_metric)\n      \n        # Find the threshold that gives FAR = far_target\n        far_train = np.zeros(nrof_thresholds)\n        for threshold_idx, threshold in enumerate(thresholds):\n            _, far_train[threshold_idx] = calculate_val_far(threshold, dist[train_set], actual_issame[train_set])\n        if np.max(far_train)>=far_target:\n            f = interpolate.interp1d(far_train, thresholds, kind='slinear')\n            threshold = f(far_target)\n        else:\n            threshold = 0.0\n    \n        val[fold_idx], far[fold_idx] = calculate_val_far(threshold, dist[test_set], actual_issame[test_set])\n  \n    val_mean = np.mean(val)\n    far_mean = np.mean(far)\n    val_std = np.std(val)\n    return val_mean, val_std, far_mean\n\n\ndef calculate_val_far(threshold, dist, actual_issame):\n    predict_issame = np.less(dist, threshold)\n    true_accept = np.sum(np.logical_and(predict_issame, actual_issame))\n    false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))\n    n_same = np.sum(actual_issame)\n    n_diff = np.sum(np.logical_not(actual_issame))\n    val = float(true_accept) / float(n_same)\n    far = float(false_accept) / float(n_diff)\n    return val, far\n\ndef store_revision_info(src_path, output_dir, arg_string):\n    try:\n        # Get git hash\n        cmd = ['git', 'rev-parse', 'HEAD']\n        gitproc = Popen(cmd, stdout = PIPE, cwd=src_path)\n        (stdout, _) = gitproc.communicate()\n        git_hash = stdout.strip()\n    except OSError as e:\n        git_hash = ' '.join(cmd) + ': ' +  e.strerror\n  \n    try:\n        # Get local changes\n        cmd = ['git', 'diff', 'HEAD']\n        gitproc = Popen(cmd, stdout = PIPE, cwd=src_path)\n        (stdout, _) = gitproc.communicate()\n        git_diff = stdout.strip()\n    except OSError as e:\n        git_diff = ' '.join(cmd) + ': ' +  e.strerror\n    \n    # Store a text file in the log directory\n    rev_info_filename = os.path.join(output_dir, 'revision_info.txt')\n    with open(rev_info_filename, \"w\") as text_file:\n        text_file.write('arguments: %s\\n--------------------\\n' % arg_string)\n        text_file.write('tensorflow version: %s\\n--------------------\\n' % tf.__version__)  # @UndefinedVariable\n        text_file.write('git hash: %s\\n--------------------\\n' % git_hash)\n        text_file.write('%s' % git_diff)\n\ndef list_variables(filename):\n    reader = training.NewCheckpointReader(filename)\n    variable_map = reader.get_variable_to_shape_map()\n    names = sorted(variable_map.keys())\n    return names\n\ndef put_images_on_grid(images, shape=(16,8)):\n    nrof_images = images.shape[0]\n    img_size = images.shape[1]\n    bw = 3\n    img = np.zeros((shape[1]*(img_size+bw)+bw, shape[0]*(img_size+bw)+bw, 3), np.float32)\n    for i in range(shape[1]):\n        x_start = i*(img_size+bw)+bw\n        for j in range(shape[0]):\n            img_index = i*shape[0]+j\n            if img_index>=nrof_images:\n                break\n            y_start = j*(img_size+bw)+bw\n            img[x_start:x_start+img_size, y_start:y_start+img_size, :] = images[img_index, :, :, :]\n        if img_index>=nrof_images:\n            break\n    return img\n\ndef write_arguments_to_file(args, filename):\n    with open(filename, 'w') as f:\n        for key, value in iteritems(vars(args)):\n            f.write('%s: %s\\n' % (key, str(value)))\n"
  },
  {
    "path": "src/freeze_graph.py",
    "content": "\"\"\"Imports a model metagraph and checkpoint file, converts the variables to constants\nand exports the model as a graphdef protobuf\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom tensorflow.python.framework import graph_util\nimport tensorflow as tf\nimport argparse\nimport os\nimport sys\nimport facenet\nfrom six.moves import xrange  # @UnresolvedImport\n\ndef main(args):\n    with tf.Graph().as_default():\n        with tf.Session() as sess:\n            # Load the model metagraph and checkpoint\n            print('Model directory: %s' % args.model_dir)\n            meta_file, ckpt_file = facenet.get_model_filenames(os.path.expanduser(args.model_dir))\n            \n            print('Metagraph file: %s' % meta_file)\n            print('Checkpoint file: %s' % ckpt_file)\n\n            model_dir_exp = os.path.expanduser(args.model_dir)\n            saver = tf.train.import_meta_graph(os.path.join(model_dir_exp, meta_file), clear_devices=True)\n            tf.get_default_session().run(tf.global_variables_initializer())\n            tf.get_default_session().run(tf.local_variables_initializer())\n            saver.restore(tf.get_default_session(), os.path.join(model_dir_exp, ckpt_file))\n            \n            # Retrieve the protobuf graph definition and fix the batch norm nodes\n            input_graph_def = sess.graph.as_graph_def()\n            \n            # Freeze the graph def\n            output_graph_def = freeze_graph_def(sess, input_graph_def, 'embeddings,label_batch')\n\n        # Serialize and dump the output graph to the filesystem\n        with tf.gfile.GFile(args.output_file, 'wb') as f:\n            f.write(output_graph_def.SerializeToString())\n        print(\"%d ops in the final graph: %s\" % (len(output_graph_def.node), args.output_file))\n        \ndef freeze_graph_def(sess, input_graph_def, output_node_names):\n    for node in input_graph_def.node:\n        if node.op == 'RefSwitch':\n            node.op = 'Switch'\n            for index in xrange(len(node.input)):\n                if 'moving_' in node.input[index]:\n                    node.input[index] = node.input[index] + '/read'\n        elif node.op == 'AssignSub':\n            node.op = 'Sub'\n            if 'use_locking' in node.attr: del node.attr['use_locking']\n        elif node.op == 'AssignAdd':\n            node.op = 'Add'\n            if 'use_locking' in node.attr: del node.attr['use_locking']\n    \n    # Get the list of important nodes\n    whitelist_names = []\n    for node in input_graph_def.node:\n        if (node.name.startswith('InceptionResnet') or node.name.startswith('embeddings') or \n                node.name.startswith('image_batch') or node.name.startswith('label_batch') or\n                node.name.startswith('phase_train') or node.name.startswith('Logits')):\n            whitelist_names.append(node.name)\n\n    # Replace all the variables in the graph with constants of the same values\n    output_graph_def = graph_util.convert_variables_to_constants(\n        sess, input_graph_def, output_node_names.split(\",\"),\n        variable_names_whitelist=whitelist_names)\n    return output_graph_def\n  \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('model_dir', type=str, \n        help='Directory containing the metagraph (.meta) file and the checkpoint (ckpt) file containing model parameters')\n    parser.add_argument('output_file', type=str, \n        help='Filename for the exported graphdef protobuf (.pb)')\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/generative/__init__.py",
    "content": ""
  },
  {
    "path": "src/generative/calculate_attribute_vectors.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Calculate average latent variables (here called attribute vectors) \nfor the different attributes in CelebA\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport sys\nimport argparse\nimport importlib\nimport facenet\nimport os\nimport numpy as np\nimport math\nimport time\nimport h5py\nfrom six import iteritems\n\ndef main(args):\n  \n    img_mean = np.array([134.10714722, 102.52040863, 87.15436554])\n    img_stddev = np.sqrt(np.array([3941.30175781, 2856.94287109, 2519.35791016]))\n    \n    vae_checkpoint = os.path.expanduser(args.vae_checkpoint)\n    \n    fields, attribs_dict = read_annotations(args.annotations_filename)\n    \n    vae_def = importlib.import_module(args.vae_def)\n    vae = vae_def.Vae(args.latent_var_size)\n    gen_image_size = vae.get_image_size()\n\n    with tf.Graph().as_default():\n        tf.set_random_seed(args.seed)\n        \n        image_list = facenet.get_image_paths(os.path.expanduser(args.data_dir))\n        \n        # Get attributes for images\n        nrof_attributes = len(fields)\n        attribs_list = []\n        for img in image_list:\n            key = os.path.split(img)[1].split('.')[0]\n            attr = attribs_dict[key]\n            assert len(attr)==nrof_attributes\n            attribs_list.append(attr)\n            \n        # Create the input queue\n        index_list = range(len(image_list))\n        input_queue = tf.train.slice_input_producer([image_list, attribs_list, index_list], num_epochs=1, shuffle=False)        \n        \n        nrof_preprocess_threads = 4\n        image_per_thread = []\n        for _ in range(nrof_preprocess_threads):\n            filename = input_queue[0]\n            file_contents = tf.read_file(filename)\n            image = tf.image.decode_image(file_contents, channels=3)\n            image = tf.image.resize_image_with_crop_or_pad(image, 160, 160)\n            #image = tf.image.resize_images(image, (64,64))\n            image.set_shape((args.image_size, args.image_size, 3))\n            attrib = input_queue[1]\n            attrib.set_shape((nrof_attributes,))\n            image = tf.cast(image, tf.float32)\n            image_per_thread.append([image, attrib, input_queue[2]])\n    \n        images, attribs, indices = tf.train.batch_join(\n            image_per_thread, batch_size=args.batch_size, \n            shapes=[(args.image_size, args.image_size, 3), (nrof_attributes,), ()], enqueue_many=False,\n            capacity=4 * nrof_preprocess_threads * args.batch_size,\n            allow_smaller_final_batch=True)\n        \n        # Normalize\n        images_norm = (images-img_mean) / img_stddev\n\n        # Resize to appropriate size for the encoder \n        images_norm_resize = tf.image.resize_images(images_norm, (gen_image_size,gen_image_size))\n        \n        # Create encoder network\n        mean, log_variance = vae.encoder(images_norm_resize, True)\n        \n        epsilon = tf.random_normal((tf.shape(mean)[0], args.latent_var_size))\n        std = tf.exp(log_variance/2)\n        latent_var = mean + epsilon * std\n        \n        # Create a saver\n        saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3)\n        \n        # Start running operations on the Graph\n        gpu_memory_fraction = 1.0\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        sess.run(tf.global_variables_initializer())\n        sess.run(tf.local_variables_initializer())\n        coord = tf.train.Coordinator()\n        tf.train.start_queue_runners(coord=coord, sess=sess)\n        \n\n        with sess.as_default():\n          \n            if vae_checkpoint:\n                print('Restoring VAE checkpoint: %s' % vae_checkpoint)\n                saver.restore(sess, vae_checkpoint)\n           \n            nrof_images = len(image_list)\n            nrof_batches = int(math.ceil(len(image_list) / args.batch_size))\n            latent_vars = np.zeros((nrof_images, args.latent_var_size))\n            attributes = np.zeros((nrof_images, nrof_attributes))\n            for i in range(nrof_batches):\n                start_time = time.time()\n                latent_var_, attribs_, indices_ = sess.run([latent_var, attribs, indices])\n                latent_vars[indices_,:] = latent_var_\n                attributes[indices_,:] = attribs_\n                duration = time.time() - start_time\n                print('Batch %d/%d: %.3f seconds' % (i+1, nrof_batches, duration))\n            # NOTE: This will print the 'Out of range' warning if the last batch is not full,\n            #  as described by https://github.com/tensorflow/tensorflow/issues/8330\n             \n            # Calculate average change in the latent variable when each attribute changes\n            attribute_vectors = np.zeros((nrof_attributes, args.latent_var_size), np.float32)\n            for i in range(nrof_attributes):\n                pos_idx = np.argwhere(attributes[:,i]==1)[:,0]\n                neg_idx = np.argwhere(attributes[:,i]==-1)[:,0]\n                pos_avg = np.mean(latent_vars[pos_idx,:], 0)\n                neg_avg = np.mean(latent_vars[neg_idx,:], 0)\n                attribute_vectors[i,:] = pos_avg - neg_avg\n            \n            filename = os.path.expanduser(args.output_filename)\n            print('Writing attribute vectors, latent variables and attributes to %s' % filename)\n            mdict = {'latent_vars':latent_vars, 'attributes':attributes, \n                     'fields':fields, 'attribute_vectors':attribute_vectors }\n            with h5py.File(filename, 'w') as f:\n                for key, value in iteritems(mdict):\n                    f.create_dataset(key, data=value)\n                    \n                    \ndef read_annotations(filename):\n    attribs = {}    \n    with open(filename, 'r') as f:\n        for i, line in enumerate(f.readlines()):\n            if i==0:\n                continue  # First line is the number of entries in the file\n            elif i==1:\n                fields = line.strip().split() # Second line is the field names\n            else:\n                line = line.split()\n                img_name = line[0].split('.')[0]\n                img_attribs = map(int, line[1:])\n                attribs[img_name] = img_attribs\n    return fields, attribs\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('vae_def', type=str,\n        help='Model definition for the variational autoencoder. Points to a module containing the definition.', \n        default='src.generative.models.dfc_vae')\n    parser.add_argument('vae_checkpoint', type=str,\n        help='Checkpoint file of a pre-trained variational autoencoder.')\n    parser.add_argument('data_dir', type=str,\n        help='Path to the directory containing aligned face patches for the CelebA dataset.')\n    parser.add_argument('annotations_filename', type=str,\n        help='Path to the annotations file',\n        default='/media/deep/datasets/CelebA/Anno/list_attr_celeba.txt')\n    parser.add_argument('output_filename', type=str,\n        help='Filename to use for the file containing the attribute vectors.')\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=128)\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=64)\n    parser.add_argument('--latent_var_size', type=int,\n        help='Dimensionality of the latent variable.', default=100)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n\n    return parser.parse_args(argv)\n  \n    \nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/generative/models/__init__.py",
    "content": ""
  },
  {
    "path": "src/generative/models/dfc_vae.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Variational autoencoder based on the paper \n'Deep Feature Consistent Variational Autoencoder'\n(https://arxiv.org/pdf/1610.00291.pdf)\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\nimport generative.models.vae_base  # @UnresolvedImport\n\n\nclass Vae(generative.models.vae_base.Vae):\n  \n    def __init__(self, latent_variable_dim):\n        super(Vae, self).__init__(latent_variable_dim, 64)\n  \n    def encoder(self, images, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0\n        with tf.variable_scope('encoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = slim.conv2d(images, 32, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_1')\n                    net = slim.conv2d(net, 64, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_2')\n                    net = slim.conv2d(net, 128, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_3')\n                    net = slim.conv2d(net, 256, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_4')\n                    net = slim.flatten(net)\n                    fc1 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    fc2 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_2')\n        return fc1, fc2\n      \n    def decoder(self, latent_var, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0 \n        with tf.variable_scope('decoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = slim.fully_connected(latent_var, 4096, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    net = tf.reshape(net, [-1,4,4,256], name='Reshape')\n                    \n                    net = tf.image.resize_nearest_neighbor(net, size=(8,8), name='Upsample_1')\n                    net = slim.conv2d(net, 128, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_1')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(16,16), name='Upsample_2')\n                    net = slim.conv2d(net, 64, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_2')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(32,32), name='Upsample_3')\n                    net = slim.conv2d(net, 32, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_3')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(64,64), name='Upsample_4')\n                    net = slim.conv2d(net, 3, [3, 3], 1, activation_fn=None, scope='Conv2d_4')\n                \n        return net\n      \ndef leaky_relu(x):\n    return tf.maximum(0.1*x,x)\n  "
  },
  {
    "path": "src/generative/models/dfc_vae_large.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Variational autoencoder based on the paper \n'Deep Feature Consistent Variational Autoencoder'\n(https://arxiv.org/pdf/1610.00291.pdf) but with a larger image size (128x128 pixels)\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\nimport generative.models.vae_base  # @UnresolvedImport\n\n\nclass Vae(generative.models.vae_base.Vae):\n  \n    def __init__(self, latent_variable_dim):\n        super(Vae, self).__init__(latent_variable_dim, 128)\n        \n      \n    def encoder(self, images, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0\n        with tf.variable_scope('encoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = slim.conv2d(images, 32, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_1')\n                    net = slim.conv2d(net, 64, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_2')\n                    net = slim.conv2d(net, 128, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_3')\n                    net = slim.conv2d(net, 256, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_4')\n                    net = slim.conv2d(net, 512, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_5')\n                    net = slim.flatten(net)\n                    fc1 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    fc2 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_2')\n        return fc1, fc2\n      \n    def decoder(self, latent_var, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0 \n        with tf.variable_scope('decoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = slim.fully_connected(latent_var, 4096, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    net = tf.reshape(net, [-1,4,4,256], name='Reshape')\n                    \n                    net = tf.image.resize_nearest_neighbor(net, size=(8,8), name='Upsample_1')\n                    net = slim.conv2d(net, 128, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_1')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(16,16), name='Upsample_2')\n                    net = slim.conv2d(net, 64, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_2')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(32,32), name='Upsample_3')\n                    net = slim.conv2d(net, 32, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_3')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(64,64), name='Upsample_4')\n                    net = slim.conv2d(net, 3, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_4')\n                \n                    net = tf.image.resize_nearest_neighbor(net, size=(128,128), name='Upsample_5')\n                    net = slim.conv2d(net, 3, [3, 3], 1, activation_fn=None, scope='Conv2d_5')\n        return net\n\ndef leaky_relu(x):\n    return tf.maximum(0.1*x,x)  \n"
  },
  {
    "path": "src/generative/models/dfc_vae_resnet.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Variational autoencoder based on the paper \n'Deep Feature Consistent Variational Autoencoder'\n(https://arxiv.org/pdf/1610.00291.pdf)\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\nimport generative.models.vae_base  # @UnresolvedImport\n\n\nclass Vae(generative.models.vae_base.Vae):\n  \n    def __init__(self, latent_variable_dim):\n        super(Vae, self).__init__(latent_variable_dim, 64)\n  \n    def encoder(self, images, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0\n        with tf.variable_scope('encoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = images\n                    \n                    net = slim.conv2d(net, 32, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_1a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 32, [4, 4], 1, activation_fn=activation_fn, scope='Conv2d_1b')\n                    \n                    net = slim.conv2d(net, 64, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_2a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 64, [4, 4], 1, activation_fn=activation_fn, scope='Conv2d_2b')\n\n                    net = slim.conv2d(net, 128, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_3a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 128, [4, 4], 1, activation_fn=activation_fn, scope='Conv2d_3b')\n\n                    net = slim.conv2d(net, 256, [4, 4], 2, activation_fn=activation_fn, scope='Conv2d_4a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 256, [4, 4], 1, activation_fn=activation_fn, scope='Conv2d_4b')\n                    \n                    net = slim.flatten(net)\n                    fc1 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    fc2 = slim.fully_connected(net, self.latent_variable_dim, activation_fn=None, normalizer_fn=None, scope='Fc_2')\n        return fc1, fc2\n      \n    def decoder(self, latent_var, is_training):\n        activation_fn = leaky_relu  # tf.nn.relu\n        weight_decay = 0.0 \n        with tf.variable_scope('decoder'):\n            with slim.arg_scope([slim.batch_norm],\n                                is_training=is_training):\n                with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                                    weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                                    weights_regularizer=slim.l2_regularizer(weight_decay),\n                                    normalizer_fn=slim.batch_norm,\n                                    normalizer_params=self.batch_norm_params):\n                    net = slim.fully_connected(latent_var, 4096, activation_fn=None, normalizer_fn=None, scope='Fc_1')\n                    net = tf.reshape(net, [-1,4,4,256], name='Reshape')\n                    \n                    net = tf.image.resize_nearest_neighbor(net, size=(8,8), name='Upsample_1')\n                    net = slim.conv2d(net, 128, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_1a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 128, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_1b')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(16,16), name='Upsample_2')\n                    net = slim.conv2d(net, 64, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_2a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 64, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_2b')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(32,32), name='Upsample_3')\n                    net = slim.conv2d(net, 32, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_3a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 32, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_3b')\n            \n                    net = tf.image.resize_nearest_neighbor(net, size=(64,64), name='Upsample_4')\n                    net = slim.conv2d(net, 3, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_4a')\n                    net = slim.repeat(net, 3, conv2d_block, 0.1, 3, [3, 3], 1, activation_fn=activation_fn, scope='Conv2d_4b')\n                    net = slim.conv2d(net, 3, [3, 3], 1, activation_fn=None, scope='Conv2d_4c')\n                \n        return net\n      \ndef conv2d_block(inp, scale, *args, **kwargs):\n    return inp + slim.conv2d(inp, *args, **kwargs) * scale\n\ndef leaky_relu(x):\n    return tf.maximum(0.1*x,x)\n  "
  },
  {
    "path": "src/generative/models/vae_base.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Base class for variational autoencoders containing an encoder and a decoder\n\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\n\nclass Vae(object):\n  \n    def __init__(self, latent_variable_dim, image_size):\n        self.latent_variable_dim = latent_variable_dim\n        self.image_size = image_size\n        self.batch_norm_params = {\n        # Decay for the moving averages.\n        'decay': 0.995,\n        # epsilon to prevent 0s in variance.\n        'epsilon': 0.001,\n        # force in-place updates of mean and variance estimates\n        'updates_collections': None,\n        # Moving averages ends up in the trainable variables collection\n        'variables_collections': [ tf.GraphKeys.TRAINABLE_VARIABLES ],\n    }\n  \n    def encoder(self, images, is_training):\n        # Must be overridden in implementation classes\n        raise NotImplementedError\n      \n    def decoder(self, latent_var, is_training):\n        # Must be overridden in implementation classes\n        raise NotImplementedError\n\n    def get_image_size(self):\n        return self.image_size\n        "
  },
  {
    "path": "src/generative/modify_attribute.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Modify attributes of images using attribute vectors calculated using\n'calculate_attribute_vectors.py'. Images are generated from latent variables of\nthe CelebA dataset.\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport sys\nimport argparse\nimport importlib\nimport facenet\nimport os\nimport numpy as np\nimport h5py\nimport math\nfrom scipy import misc\n\ndef main(args):\n  \n    img_mean = np.array([134.10714722, 102.52040863, 87.15436554])\n    img_stddev = np.sqrt(np.array([3941.30175781, 2856.94287109, 2519.35791016]))\n    \n    vae_def = importlib.import_module(args.vae_def)\n    vae = vae_def.Vae(args.latent_var_size)\n    gen_image_size = vae.get_image_size()\n\n    with tf.Graph().as_default():\n        tf.set_random_seed(args.seed)\n        \n        images = tf.placeholder(tf.float32, shape=(None,gen_image_size,gen_image_size,3), name='input')\n        \n        # Normalize\n        images_norm = (images-img_mean) / img_stddev\n\n        # Resize to appropriate size for the encoder \n        images_norm_resize = tf.image.resize_images(images_norm, (gen_image_size,gen_image_size))\n        \n        # Create encoder network\n        mean, log_variance = vae.encoder(images_norm_resize, True)\n        \n        epsilon = tf.random_normal((tf.shape(mean)[0], args.latent_var_size))\n        std = tf.exp(log_variance/2)\n        latent_var = mean + epsilon * std\n        \n        # Create decoder\n        reconstructed_norm = vae.decoder(latent_var, False)\n        \n        # Un-normalize\n        reconstructed = (reconstructed_norm*img_stddev) + img_mean\n\n        # Create a saver\n        saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3)\n        \n        # Start running operations on the Graph\n        gpu_memory_fraction = 1.0\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        sess.run(tf.global_variables_initializer())\n        sess.run(tf.local_variables_initializer())\n        coord = tf.train.Coordinator()\n        tf.train.start_queue_runners(coord=coord, sess=sess)\n        \n\n        with sess.as_default():\n          \n            vae_checkpoint = os.path.expanduser(args.vae_checkpoint)\n            print('Restoring VAE checkpoint: %s' % vae_checkpoint)\n            saver.restore(sess, vae_checkpoint)\n           \n            filename = os.path.expanduser(args.attributes_filename)\n            with h5py.File(filename,'r') as f:\n                latent_vars = np.array(f.get('latent_vars'))\n                attributes = np.array(f.get('attributes'))\n                #fields = np.array(f.get('fields'))\n                attribute_vectors = np.array(f.get('attribute_vectors'))\n\n            # Reconstruct faces while adding varying amount of the selected attribute vector\n            attribute_index = 31 # 31: 'Smiling'\n            image_indices = [8,11,13,18,19,26,31,39,47,54,56,57,58,59,60,73]\n            nrof_images = len(image_indices)\n            nrof_interp_steps = 10\n            sweep_latent_var = np.zeros((nrof_interp_steps*nrof_images, args.latent_var_size), np.float32)\n            for j in range(nrof_images):\n                image_index = image_indices[j]\n                idx = np.argwhere(attributes[:,attribute_index]==-1)[image_index,0]\n                for i in range(nrof_interp_steps):\n                    sweep_latent_var[i+nrof_interp_steps*j,:] = latent_vars[idx,:] + 5.0*i/nrof_interp_steps*attribute_vectors[attribute_index,:]\n                \n            recon = sess.run(reconstructed, feed_dict={latent_var:sweep_latent_var})\n            \n            img = facenet.put_images_on_grid(recon, shape=(nrof_interp_steps*2,int(math.ceil(nrof_images/2))))\n            \n            image_filename = os.path.expanduser(args.output_image_filename)\n            print('Writing generated image to %s' % image_filename)\n            misc.imsave(image_filename, img)\n\n                    \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('vae_def', type=str,\n        help='Model definition for the variational autoencoder. Points to a module containing the definition.')\n    parser.add_argument('vae_checkpoint', type=str,\n        help='Checkpoint file of a pre-trained variational autoencoder.')\n    parser.add_argument('attributes_filename', type=str,\n        help='The file containing the attribute vectors, as generated by calculate_attribute_vectors.py.')\n    parser.add_argument('output_image_filename', type=str,\n        help='File to write the generated image to.')\n    parser.add_argument('--latent_var_size', type=int,\n        help='Dimensionality of the latent variable.', default=100)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n\n    return parser.parse_args(argv)\n  \n    \nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/generative/train_vae.py",
    "content": "# MIT License\n# \n# Copyright (c) 2017 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n\"\"\"Train a Variational Autoencoder\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\nimport sys\nimport time\nimport importlib\nimport argparse\nimport facenet\nimport numpy as np\nimport h5py\nimport os\nfrom datetime import datetime\nfrom scipy import misc\nfrom six import iteritems\n\ndef main(args):\n  \n    img_mean = np.array([134.10714722, 102.52040863, 87.15436554])\n    img_stddev = np.sqrt(np.array([3941.30175781, 2856.94287109, 2519.35791016]))\n  \n    vae_def = importlib.import_module(args.vae_def)\n    vae = vae_def.Vae(args.latent_var_size)\n    gen_image_size = vae.get_image_size()\n\n    subdir = datetime.strftime(datetime.now(), '%Y%m%d-%H%M%S')\n    model_dir = os.path.join(os.path.expanduser(args.models_base_dir), subdir)\n    if not os.path.isdir(model_dir):  # Create the model directory if it doesn't exist\n        os.makedirs(model_dir)\n    log_file_name = os.path.join(model_dir, 'logs.h5')\n    \n    # Write arguments to a text file\n    facenet.write_arguments_to_file(args, os.path.join(model_dir, 'arguments.txt'))\n        \n    # Store some git revision info in a text file in the log directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, model_dir, ' '.join(sys.argv))\n    \n    with tf.Graph().as_default():\n        tf.set_random_seed(args.seed)\n        global_step = tf.Variable(0, trainable=False)\n        \n        train_set = facenet.get_dataset(args.data_dir)\n        image_list, _ = facenet.get_image_paths_and_labels(train_set)\n        \n        # Create the input queue\n        input_queue = tf.train.string_input_producer(image_list, shuffle=True)\n    \n        nrof_preprocess_threads = 4\n        image_per_thread = []\n        for _ in range(nrof_preprocess_threads):\n            file_contents = tf.read_file(input_queue.dequeue())\n            image = tf.image.decode_image(file_contents, channels=3)\n            image = tf.image.resize_image_with_crop_or_pad(image, args.input_image_size, args.input_image_size)\n            image.set_shape((args.input_image_size, args.input_image_size, 3))\n            image = tf.cast(image, tf.float32)\n            #pylint: disable=no-member\n            image_per_thread.append([image])\n    \n        images = tf.train.batch_join(\n            image_per_thread, batch_size=args.batch_size,\n            capacity=4 * nrof_preprocess_threads * args.batch_size,\n            allow_smaller_final_batch=False)\n        \n        # Normalize\n        images_norm = (images-img_mean) / img_stddev\n\n        # Resize to appropriate size for the encoder \n        images_norm_resize = tf.image.resize_images(images_norm, (gen_image_size,gen_image_size))\n        \n        # Create encoder network\n        mean, log_variance = vae.encoder(images_norm_resize, True)\n        \n        epsilon = tf.random_normal((tf.shape(mean)[0], args.latent_var_size))\n        std = tf.exp(log_variance/2)\n        latent_var = mean + epsilon * std\n        \n        # Create decoder network\n        reconstructed_norm = vae.decoder(latent_var, True)\n        \n        # Un-normalize\n        reconstructed = (reconstructed_norm*img_stddev) + img_mean\n        \n        # Create reconstruction loss\n        if args.reconstruction_loss_type=='PLAIN':\n            images_resize = tf.image.resize_images(images, (gen_image_size,gen_image_size))\n            reconstruction_loss = tf.reduce_mean(tf.reduce_sum(tf.pow(images_resize - reconstructed,2)))\n        elif args.reconstruction_loss_type=='PERCEPTUAL':\n            network = importlib.import_module(args.model_def)\n\n            reconstructed_norm_resize = tf.image.resize_images(reconstructed_norm, (args.input_image_size,args.input_image_size))\n\n            # Stack images from both the input batch and the reconstructed batch in a new tensor \n            shp = [-1] + images_norm.get_shape().as_list()[1:]\n            input_images = tf.reshape(tf.stack([images_norm, reconstructed_norm_resize], axis=0), shp)\n            _, end_points = network.inference(input_images, 1.0, \n                phase_train=False, bottleneck_layer_size=128, weight_decay=0.0)\n\n            # Get a list of feature names to use for loss terms\n            feature_names = args.loss_features.replace(' ', '').split(',')\n\n            # Calculate L2 loss between original and reconstructed images in feature space\n            reconstruction_loss_list = []\n            for feature_name in feature_names:\n                feature_flat = slim.flatten(end_points[feature_name])\n                image_feature, reconstructed_feature = tf.unstack(tf.reshape(feature_flat, [2,args.batch_size,-1]), num=2, axis=0)\n                reconstruction_loss = tf.reduce_mean(tf.reduce_sum(tf.pow(image_feature-reconstructed_feature, 2)), name=feature_name+'_loss')\n                reconstruction_loss_list.append(reconstruction_loss)\n            # Sum up the losses in for the different features\n            reconstruction_loss = tf.add_n(reconstruction_loss_list, 'reconstruction_loss')\n        else:\n            pass\n        \n        # Create KL divergence loss\n        kl_loss = kl_divergence_loss(mean, log_variance)\n        kl_loss_mean = tf.reduce_mean(kl_loss)\n        \n        total_loss = args.alfa*kl_loss_mean + args.beta*reconstruction_loss\n        \n        learning_rate = tf.train.exponential_decay(args.initial_learning_rate, global_step,\n            args.learning_rate_decay_steps, args.learning_rate_decay_factor, staircase=True)\n        \n        # Calculate gradients and make sure not to include parameters for the perceptual loss model\n        opt = tf.train.AdamOptimizer(learning_rate)\n        grads = opt.compute_gradients(total_loss, var_list=get_variables_to_train())\n        \n        # Apply gradients\n        apply_gradient_op = opt.apply_gradients(grads, global_step=global_step)\n        with tf.control_dependencies([apply_gradient_op]):\n            train_op = tf.no_op(name='train')\n\n        # Create a saver\n        saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3)\n        \n        facenet_saver = tf.train.Saver(get_facenet_variables_to_restore())\n\n        # Start running operations on the Graph\n        gpu_memory_fraction = 1.0\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        sess.run(tf.global_variables_initializer())\n        sess.run(tf.local_variables_initializer())\n        coord = tf.train.Coordinator()\n        tf.train.start_queue_runners(coord=coord, sess=sess)\n\n        with sess.as_default():\n            \n            if args.reconstruction_loss_type=='PERCEPTUAL':\n                if not args.pretrained_model:\n                    raise ValueError('A pretrained model must be specified when using perceptual loss')\n                pretrained_model_exp = os.path.expanduser(args.pretrained_model)\n                print('Restoring pretrained model: %s' % pretrained_model_exp)\n                facenet_saver.restore(sess, pretrained_model_exp)\n          \n            log = {\n                'total_loss': np.zeros((0,), np.float),\n                'reconstruction_loss': np.zeros((0,), np.float),\n                'kl_loss': np.zeros((0,), np.float),\n                'learning_rate': np.zeros((0,), np.float),\n                }\n            \n            step = 0\n            print('Running training')\n            while step < args.max_nrof_steps:\n                start_time = time.time()\n                step += 1\n                save_state = step>0 and (step % args.save_every_n_steps==0 or step==args.max_nrof_steps)\n                if save_state:\n                    _, reconstruction_loss_, kl_loss_mean_, total_loss_, learning_rate_, rec_ = sess.run(\n                          [train_op, reconstruction_loss, kl_loss_mean, total_loss, learning_rate, reconstructed])\n                    img = facenet.put_images_on_grid(rec_, shape=(16,8))\n                    misc.imsave(os.path.join(model_dir, 'reconstructed_%06d.png' % step), img)\n                else:\n                    _, reconstruction_loss_, kl_loss_mean_, total_loss_, learning_rate_ = sess.run(\n                          [train_op, reconstruction_loss, kl_loss_mean, total_loss, learning_rate])\n                log['total_loss'] = np.append(log['total_loss'], total_loss_)\n                log['reconstruction_loss'] = np.append(log['reconstruction_loss'], reconstruction_loss_)\n                log['kl_loss'] = np.append(log['kl_loss'], kl_loss_mean_)\n                log['learning_rate'] = np.append(log['learning_rate'], learning_rate_)\n\n                duration = time.time() - start_time\n                print('Step: %d \\tTime: %.3f \\trec_loss: %.3f \\tkl_loss: %.3f \\ttotal_loss: %.3f' % (step, duration, reconstruction_loss_, kl_loss_mean_, total_loss_))\n\n                if save_state:\n                    print('Saving checkpoint file')\n                    checkpoint_path = os.path.join(model_dir, 'model.ckpt')\n                    saver.save(sess, checkpoint_path, global_step=step, write_meta_graph=False)\n                    print('Saving log')\n                    with h5py.File(log_file_name, 'w') as f:\n                        for key, value in iteritems(log):\n                            f.create_dataset(key, data=value)\n\ndef get_variables_to_train():\n    train_variables = []\n    for var in tf.trainable_variables():\n        if 'Inception' not in var.name:\n            train_variables.append(var)\n    return train_variables\n\ndef get_facenet_variables_to_restore():\n    facenet_variables = []\n    for var in tf.global_variables():\n        if var.name.startswith('Inception'):\n            if 'Adam' not in var.name:\n                facenet_variables.append(var)\n    return facenet_variables\n\ndef kl_divergence_loss(mean, log_variance):\n    kl = 0.5 * tf.reduce_sum( tf.exp(log_variance) + tf.square(mean) - 1.0 - log_variance, reduction_indices = 1)\n    return kl\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('vae_def', type=str,\n        help='Model definition for the variational autoencoder. Points to a module containing the definition.')\n    parser.add_argument('data_dir', type=str,\n        help='Path to the data directory containing aligned face patches.')\n    parser.add_argument('model_def', type=str,\n        help='Model definition. Points to a module containing the definition of the inference graph.')\n    parser.add_argument('pretrained_model', type=str,\n        help='Pretrained model to use to calculate features for perceptual loss.')\n    parser.add_argument('--models_base_dir', type=str,\n        help='Directory where to write trained models and checkpoints.', default='~/vae')\n    parser.add_argument('--loss_features', type=str,\n        help='Comma separated list of features to use for perceptual loss. Features should be defined ' +\n          'in the end_points dictionary.', default='Conv2d_1a_3x3,Conv2d_2a_3x3, Conv2d_2b_3x3')\n    parser.add_argument('--reconstruction_loss_type', type=str, choices=['PLAIN', 'PERCEPTUAL'],\n        help='The type of reconstruction loss to use', default='PERCEPTUAL')\n    parser.add_argument('--max_nrof_steps', type=int,\n        help='Number of steps to run.', default=50000)\n    parser.add_argument('--save_every_n_steps', type=int,\n        help='Number of steps between storing of model checkpoint and log files', default=500)\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=128)\n    parser.add_argument('--input_image_size', type=int,\n        help='Image size of input images (height, width) in pixels. If perceptual loss is used this ' \n        + 'should be the input image size for the perceptual loss model', default=160)\n    parser.add_argument('--latent_var_size', type=int,\n        help='Dimensionality of the latent variable.', default=100)\n    parser.add_argument('--initial_learning_rate', type=float,\n        help='Initial learning rate.', default=0.0005)\n    parser.add_argument('--learning_rate_decay_steps', type=int,\n        help='Number of steps between learning rate decay.', default=1)\n    parser.add_argument('--learning_rate_decay_factor', type=float,\n        help='Learning rate decay factor.', default=1.0)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    parser.add_argument('--alfa', type=float,\n        help='Kullback-Leibler divergence loss factor.', default=1.0)\n    parser.add_argument('--beta', type=float,\n        help='Reconstruction loss factor.', default=0.5)\n    \n    return parser.parse_args(argv)\n  \n    \nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/lfw.py",
    "content": "\"\"\"Helper for evaluation on the Labeled Faces in the Wild dataset \n\"\"\"\n\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport os\nimport numpy as np\nimport facenet\n\ndef evaluate(embeddings, actual_issame, nrof_folds=10, distance_metric=0, subtract_mean=False):\n    # Calculate evaluation metrics\n    thresholds = np.arange(0, 4, 0.01)\n    embeddings1 = embeddings[0::2]\n    embeddings2 = embeddings[1::2]\n    tpr, fpr, accuracy = facenet.calculate_roc(thresholds, embeddings1, embeddings2,\n        np.asarray(actual_issame), nrof_folds=nrof_folds, distance_metric=distance_metric, subtract_mean=subtract_mean)\n    thresholds = np.arange(0, 4, 0.001)\n    val, val_std, far = facenet.calculate_val(thresholds, embeddings1, embeddings2,\n        np.asarray(actual_issame), 1e-3, nrof_folds=nrof_folds, distance_metric=distance_metric, subtract_mean=subtract_mean)\n    return tpr, fpr, accuracy, val, val_std, far\n\ndef get_paths(lfw_dir, pairs):\n    nrof_skipped_pairs = 0\n    path_list = []\n    issame_list = []\n    for pair in pairs:\n        if len(pair) == 3:\n            path0 = add_extension(os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1])))\n            path1 = add_extension(os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[2])))\n            issame = True\n        elif len(pair) == 4:\n            path0 = add_extension(os.path.join(lfw_dir, pair[0], pair[0] + '_' + '%04d' % int(pair[1])))\n            path1 = add_extension(os.path.join(lfw_dir, pair[2], pair[2] + '_' + '%04d' % int(pair[3])))\n            issame = False\n        if os.path.exists(path0) and os.path.exists(path1):    # Only add the pair if both paths exist\n            path_list += (path0,path1)\n            issame_list.append(issame)\n        else:\n            nrof_skipped_pairs += 1\n    if nrof_skipped_pairs>0:\n        print('Skipped %d image pairs' % nrof_skipped_pairs)\n    \n    return path_list, issame_list\n  \ndef add_extension(path):\n    if os.path.exists(path+'.jpg'):\n        return path+'.jpg'\n    elif os.path.exists(path+'.png'):\n        return path+'.png'\n    else:\n        raise RuntimeError('No file \"%s\" with extension png or jpg.' % path)\n\ndef read_pairs(pairs_filename):\n    pairs = []\n    with open(pairs_filename, 'r') as f:\n        for line in f.readlines()[1:]:\n            pair = line.strip().split()\n            pairs.append(pair)\n    return np.array(pairs)\n\n\n\n"
  },
  {
    "path": "src/models/__init__.py",
    "content": "# flake8: noqa\n\n"
  },
  {
    "path": "src/models/dummy.py",
    "content": "\"\"\"Dummy model used only for testing\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\nimport numpy as np\n  \ndef inference(images, keep_probability, phase_train=True,  # @UnusedVariable\n              bottleneck_layer_size=128, bottleneck_layer_activation=None, weight_decay=0.0, reuse=None):  # @UnusedVariable\n    batch_norm_params = {\n        # Decay for the moving averages.\n        'decay': 0.995,\n        # epsilon to prevent 0s in variance.\n        'epsilon': 0.001,\n        # force in-place updates of mean and variance estimates\n        'updates_collections': None,\n        # Moving averages ends up in the trainable variables collection\n        'variables_collections': [ tf.GraphKeys.TRAINABLE_VARIABLES ],\n    }\n    \n    with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                        weights_initializer=tf.truncated_normal_initializer(stddev=0.1),\n                        weights_regularizer=slim.l2_regularizer(weight_decay),\n                        normalizer_fn=slim.batch_norm,\n                        normalizer_params=batch_norm_params):\n        size = np.prod(images.get_shape()[1:].as_list())\n        net = slim.fully_connected(tf.reshape(images, (-1,size)), bottleneck_layer_size, activation_fn=None, \n                scope='Bottleneck', reuse=False)\n        return net, None\n"
  },
  {
    "path": "src/models/inception_resnet_v1.py",
    "content": "# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\n\"\"\"Contains the definition of the Inception Resnet V1 architecture.\nAs described in http://arxiv.org/abs/1602.07261.\n  Inception-v4, Inception-ResNet and the Impact of Residual Connections\n    on Learning\n  Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\n\n# Inception-Resnet-A\ndef block35(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 35x35 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block35', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 32, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 32, 3, scope='Conv2d_0b_3x3')\n        with tf.variable_scope('Branch_2'):\n            tower_conv2_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')\n            tower_conv2_1 = slim.conv2d(tower_conv2_0, 32, 3, scope='Conv2d_0b_3x3')\n            tower_conv2_2 = slim.conv2d(tower_conv2_1, 32, 3, scope='Conv2d_0c_3x3')\n        mixed = tf.concat([tower_conv, tower_conv1_1, tower_conv2_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n\n# Inception-Resnet-B\ndef block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 17x17 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block17', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 128, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 128, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 128, [1, 7],\n                                        scope='Conv2d_0b_1x7')\n            tower_conv1_2 = slim.conv2d(tower_conv1_1, 128, [7, 1],\n                                        scope='Conv2d_0c_7x1')\n        mixed = tf.concat([tower_conv, tower_conv1_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n\n\n# Inception-Resnet-C\ndef block8(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 8x8 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block8', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 192, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 192, [1, 3],\n                                        scope='Conv2d_0b_1x3')\n            tower_conv1_2 = slim.conv2d(tower_conv1_1, 192, [3, 1],\n                                        scope='Conv2d_0c_3x1')\n        mixed = tf.concat([tower_conv, tower_conv1_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n  \ndef reduction_a(net, k, l, m, n):\n    with tf.variable_scope('Branch_0'):\n        tower_conv = slim.conv2d(net, n, 3, stride=2, padding='VALID',\n                                 scope='Conv2d_1a_3x3')\n    with tf.variable_scope('Branch_1'):\n        tower_conv1_0 = slim.conv2d(net, k, 1, scope='Conv2d_0a_1x1')\n        tower_conv1_1 = slim.conv2d(tower_conv1_0, l, 3,\n                                    scope='Conv2d_0b_3x3')\n        tower_conv1_2 = slim.conv2d(tower_conv1_1, m, 3,\n                                    stride=2, padding='VALID',\n                                    scope='Conv2d_1a_3x3')\n    with tf.variable_scope('Branch_2'):\n        tower_pool = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                     scope='MaxPool_1a_3x3')\n    net = tf.concat([tower_conv, tower_conv1_2, tower_pool], 3)\n    return net\n\ndef reduction_b(net):\n    with tf.variable_scope('Branch_0'):\n        tower_conv = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n        tower_conv_1 = slim.conv2d(tower_conv, 384, 3, stride=2,\n                                   padding='VALID', scope='Conv2d_1a_3x3')\n    with tf.variable_scope('Branch_1'):\n        tower_conv1 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n        tower_conv1_1 = slim.conv2d(tower_conv1, 256, 3, stride=2,\n                                    padding='VALID', scope='Conv2d_1a_3x3')\n    with tf.variable_scope('Branch_2'):\n        tower_conv2 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n        tower_conv2_1 = slim.conv2d(tower_conv2, 256, 3,\n                                    scope='Conv2d_0b_3x3')\n        tower_conv2_2 = slim.conv2d(tower_conv2_1, 256, 3, stride=2,\n                                    padding='VALID', scope='Conv2d_1a_3x3')\n    with tf.variable_scope('Branch_3'):\n        tower_pool = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                     scope='MaxPool_1a_3x3')\n    net = tf.concat([tower_conv_1, tower_conv1_1,\n                        tower_conv2_2, tower_pool], 3)\n    return net\n  \ndef inference(images, keep_probability, phase_train=True, \n              bottleneck_layer_size=128, weight_decay=0.0, reuse=None):\n    batch_norm_params = {\n        # Decay for the moving averages.\n        'decay': 0.995,\n        # epsilon to prevent 0s in variance.\n        'epsilon': 0.001,\n        # force in-place updates of mean and variance estimates\n        'updates_collections': None,\n        # Moving averages ends up in the trainable variables collection\n        'variables_collections': [ tf.GraphKeys.TRAINABLE_VARIABLES ],\n    }\n    \n    with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                        weights_initializer=slim.initializers.xavier_initializer(), \n                        weights_regularizer=slim.l2_regularizer(weight_decay),\n                        normalizer_fn=slim.batch_norm,\n                        normalizer_params=batch_norm_params):\n        return inception_resnet_v1(images, is_training=phase_train,\n              dropout_keep_prob=keep_probability, bottleneck_layer_size=bottleneck_layer_size, reuse=reuse)\n\n\ndef inception_resnet_v1(inputs, is_training=True,\n                        dropout_keep_prob=0.8,\n                        bottleneck_layer_size=128,\n                        reuse=None, \n                        scope='InceptionResnetV1'):\n    \"\"\"Creates the Inception Resnet V1 model.\n    Args:\n      inputs: a 4-D tensor of size [batch_size, height, width, 3].\n      num_classes: number of predicted classes.\n      is_training: whether is training or not.\n      dropout_keep_prob: float, the fraction to keep before final layer.\n      reuse: whether or not the network and its variables should be reused. To be\n        able to reuse 'scope' must be given.\n      scope: Optional variable_scope.\n    Returns:\n      logits: the logits outputs of the model.\n      end_points: the set of end_points from the inception model.\n    \"\"\"\n    end_points = {}\n  \n    with tf.variable_scope(scope, 'InceptionResnetV1', [inputs], reuse=reuse):\n        with slim.arg_scope([slim.batch_norm, slim.dropout],\n                            is_training=is_training):\n            with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d],\n                                stride=1, padding='SAME'):\n      \n                # 149 x 149 x 32\n                net = slim.conv2d(inputs, 32, 3, stride=2, padding='VALID',\n                                  scope='Conv2d_1a_3x3')\n                end_points['Conv2d_1a_3x3'] = net\n                # 147 x 147 x 32\n                net = slim.conv2d(net, 32, 3, padding='VALID',\n                                  scope='Conv2d_2a_3x3')\n                end_points['Conv2d_2a_3x3'] = net\n                # 147 x 147 x 64\n                net = slim.conv2d(net, 64, 3, scope='Conv2d_2b_3x3')\n                end_points['Conv2d_2b_3x3'] = net\n                # 73 x 73 x 64\n                net = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                      scope='MaxPool_3a_3x3')\n                end_points['MaxPool_3a_3x3'] = net\n                # 73 x 73 x 80\n                net = slim.conv2d(net, 80, 1, padding='VALID',\n                                  scope='Conv2d_3b_1x1')\n                end_points['Conv2d_3b_1x1'] = net\n                # 71 x 71 x 192\n                net = slim.conv2d(net, 192, 3, padding='VALID',\n                                  scope='Conv2d_4a_3x3')\n                end_points['Conv2d_4a_3x3'] = net\n                # 35 x 35 x 256\n                net = slim.conv2d(net, 256, 3, stride=2, padding='VALID',\n                                  scope='Conv2d_4b_3x3')\n                end_points['Conv2d_4b_3x3'] = net\n                \n                # 5 x Inception-resnet-A\n                net = slim.repeat(net, 5, block35, scale=0.17)\n                end_points['Mixed_5a'] = net\n        \n                # Reduction-A\n                with tf.variable_scope('Mixed_6a'):\n                    net = reduction_a(net, 192, 192, 256, 384)\n                end_points['Mixed_6a'] = net\n                \n                # 10 x Inception-Resnet-B\n                net = slim.repeat(net, 10, block17, scale=0.10)\n                end_points['Mixed_6b'] = net\n                \n                # Reduction-B\n                with tf.variable_scope('Mixed_7a'):\n                    net = reduction_b(net)\n                end_points['Mixed_7a'] = net\n                \n                # 5 x Inception-Resnet-C\n                net = slim.repeat(net, 5, block8, scale=0.20)\n                end_points['Mixed_8a'] = net\n                \n                net = block8(net, activation_fn=None)\n                end_points['Mixed_8b'] = net\n                \n                with tf.variable_scope('Logits'):\n                    end_points['PrePool'] = net\n                    #pylint: disable=no-member\n                    net = slim.avg_pool2d(net, net.get_shape()[1:3], padding='VALID',\n                                          scope='AvgPool_1a_8x8')\n                    net = slim.flatten(net)\n          \n                    net = slim.dropout(net, dropout_keep_prob, is_training=is_training,\n                                       scope='Dropout')\n          \n                    end_points['PreLogitsFlatten'] = net\n                \n                net = slim.fully_connected(net, bottleneck_layer_size, activation_fn=None, \n                        scope='Bottleneck', reuse=False)\n  \n    return net, end_points\n"
  },
  {
    "path": "src/models/inception_resnet_v2.py",
    "content": "# Copyright 2016 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\n\"\"\"Contains the definition of the Inception Resnet V2 architecture.\nAs described in http://arxiv.org/abs/1602.07261.\n  Inception-v4, Inception-ResNet and the Impact of Residual Connections\n    on Learning\n  Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\n\n# Inception-Resnet-A\ndef block35(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 35x35 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block35', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 32, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 32, 3, scope='Conv2d_0b_3x3')\n        with tf.variable_scope('Branch_2'):\n            tower_conv2_0 = slim.conv2d(net, 32, 1, scope='Conv2d_0a_1x1')\n            tower_conv2_1 = slim.conv2d(tower_conv2_0, 48, 3, scope='Conv2d_0b_3x3')\n            tower_conv2_2 = slim.conv2d(tower_conv2_1, 64, 3, scope='Conv2d_0c_3x3')\n        mixed = tf.concat([tower_conv, tower_conv1_1, tower_conv2_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n\n# Inception-Resnet-B\ndef block17(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 17x17 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block17', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 128, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 160, [1, 7],\n                                        scope='Conv2d_0b_1x7')\n            tower_conv1_2 = slim.conv2d(tower_conv1_1, 192, [7, 1],\n                                        scope='Conv2d_0c_7x1')\n        mixed = tf.concat([tower_conv, tower_conv1_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n\n\n# Inception-Resnet-C\ndef block8(net, scale=1.0, activation_fn=tf.nn.relu, scope=None, reuse=None):\n    \"\"\"Builds the 8x8 resnet block.\"\"\"\n    with tf.variable_scope(scope, 'Block8', [net], reuse=reuse):\n        with tf.variable_scope('Branch_0'):\n            tower_conv = slim.conv2d(net, 192, 1, scope='Conv2d_1x1')\n        with tf.variable_scope('Branch_1'):\n            tower_conv1_0 = slim.conv2d(net, 192, 1, scope='Conv2d_0a_1x1')\n            tower_conv1_1 = slim.conv2d(tower_conv1_0, 224, [1, 3],\n                                        scope='Conv2d_0b_1x3')\n            tower_conv1_2 = slim.conv2d(tower_conv1_1, 256, [3, 1],\n                                        scope='Conv2d_0c_3x1')\n        mixed = tf.concat([tower_conv, tower_conv1_2], 3)\n        up = slim.conv2d(mixed, net.get_shape()[3], 1, normalizer_fn=None,\n                         activation_fn=None, scope='Conv2d_1x1')\n        net += scale * up\n        if activation_fn:\n            net = activation_fn(net)\n    return net\n  \ndef inference(images, keep_probability, phase_train=True, \n              bottleneck_layer_size=128, weight_decay=0.0, reuse=None):\n    batch_norm_params = {\n        # Decay for the moving averages.\n        'decay': 0.995,\n        # epsilon to prevent 0s in variance.\n        'epsilon': 0.001,\n        # force in-place updates of mean and variance estimates\n        'updates_collections': None,\n        # Moving averages ends up in the trainable variables collection\n        'variables_collections': [ tf.GraphKeys.TRAINABLE_VARIABLES ],\n}\n    with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                        weights_initializer=slim.initializers.xavier_initializer(), \n                        weights_regularizer=slim.l2_regularizer(weight_decay),\n                        normalizer_fn=slim.batch_norm,\n                        normalizer_params=batch_norm_params):\n        return inception_resnet_v2(images, is_training=phase_train,\n              dropout_keep_prob=keep_probability, bottleneck_layer_size=bottleneck_layer_size, reuse=reuse)\n\n\ndef inception_resnet_v2(inputs, is_training=True,\n                        dropout_keep_prob=0.8,\n                        bottleneck_layer_size=128,\n                        reuse=None,\n                        scope='InceptionResnetV2'):\n    \"\"\"Creates the Inception Resnet V2 model.\n    Args:\n      inputs: a 4-D tensor of size [batch_size, height, width, 3].\n      num_classes: number of predicted classes.\n      is_training: whether is training or not.\n      dropout_keep_prob: float, the fraction to keep before final layer.\n      reuse: whether or not the network and its variables should be reused. To be\n        able to reuse 'scope' must be given.\n      scope: Optional variable_scope.\n    Returns:\n      logits: the logits outputs of the model.\n      end_points: the set of end_points from the inception model.\n    \"\"\"\n    end_points = {}\n  \n    with tf.variable_scope(scope, 'InceptionResnetV2', [inputs], reuse=reuse):\n        with slim.arg_scope([slim.batch_norm, slim.dropout],\n                            is_training=is_training):\n            with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d],\n                                stride=1, padding='SAME'):\n      \n                # 149 x 149 x 32\n                net = slim.conv2d(inputs, 32, 3, stride=2, padding='VALID',\n                                  scope='Conv2d_1a_3x3')\n                end_points['Conv2d_1a_3x3'] = net\n                # 147 x 147 x 32\n                net = slim.conv2d(net, 32, 3, padding='VALID',\n                                  scope='Conv2d_2a_3x3')\n                end_points['Conv2d_2a_3x3'] = net\n                # 147 x 147 x 64\n                net = slim.conv2d(net, 64, 3, scope='Conv2d_2b_3x3')\n                end_points['Conv2d_2b_3x3'] = net\n                # 73 x 73 x 64\n                net = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                      scope='MaxPool_3a_3x3')\n                end_points['MaxPool_3a_3x3'] = net\n                # 73 x 73 x 80\n                net = slim.conv2d(net, 80, 1, padding='VALID',\n                                  scope='Conv2d_3b_1x1')\n                end_points['Conv2d_3b_1x1'] = net\n                # 71 x 71 x 192\n                net = slim.conv2d(net, 192, 3, padding='VALID',\n                                  scope='Conv2d_4a_3x3')\n                end_points['Conv2d_4a_3x3'] = net\n                # 35 x 35 x 192\n                net = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                      scope='MaxPool_5a_3x3')\n                end_points['MaxPool_5a_3x3'] = net\n        \n                # 35 x 35 x 320\n                with tf.variable_scope('Mixed_5b'):\n                    with tf.variable_scope('Branch_0'):\n                        tower_conv = slim.conv2d(net, 96, 1, scope='Conv2d_1x1')\n                    with tf.variable_scope('Branch_1'):\n                        tower_conv1_0 = slim.conv2d(net, 48, 1, scope='Conv2d_0a_1x1')\n                        tower_conv1_1 = slim.conv2d(tower_conv1_0, 64, 5,\n                                                    scope='Conv2d_0b_5x5')\n                    with tf.variable_scope('Branch_2'):\n                        tower_conv2_0 = slim.conv2d(net, 64, 1, scope='Conv2d_0a_1x1')\n                        tower_conv2_1 = slim.conv2d(tower_conv2_0, 96, 3,\n                                                    scope='Conv2d_0b_3x3')\n                        tower_conv2_2 = slim.conv2d(tower_conv2_1, 96, 3,\n                                                    scope='Conv2d_0c_3x3')\n                    with tf.variable_scope('Branch_3'):\n                        tower_pool = slim.avg_pool2d(net, 3, stride=1, padding='SAME',\n                                                     scope='AvgPool_0a_3x3')\n                        tower_pool_1 = slim.conv2d(tower_pool, 64, 1,\n                                                   scope='Conv2d_0b_1x1')\n                    net = tf.concat([tower_conv, tower_conv1_1,\n                                        tower_conv2_2, tower_pool_1], 3)\n        \n                end_points['Mixed_5b'] = net\n                net = slim.repeat(net, 10, block35, scale=0.17)\n        \n                # 17 x 17 x 1024\n                with tf.variable_scope('Mixed_6a'):\n                    with tf.variable_scope('Branch_0'):\n                        tower_conv = slim.conv2d(net, 384, 3, stride=2, padding='VALID',\n                                                 scope='Conv2d_1a_3x3')\n                    with tf.variable_scope('Branch_1'):\n                        tower_conv1_0 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n                        tower_conv1_1 = slim.conv2d(tower_conv1_0, 256, 3,\n                                                    scope='Conv2d_0b_3x3')\n                        tower_conv1_2 = slim.conv2d(tower_conv1_1, 384, 3,\n                                                    stride=2, padding='VALID',\n                                                    scope='Conv2d_1a_3x3')\n                    with tf.variable_scope('Branch_2'):\n                        tower_pool = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                                     scope='MaxPool_1a_3x3')\n                    net = tf.concat([tower_conv, tower_conv1_2, tower_pool], 3)\n        \n                end_points['Mixed_6a'] = net\n                net = slim.repeat(net, 20, block17, scale=0.10)\n        \n                with tf.variable_scope('Mixed_7a'):\n                    with tf.variable_scope('Branch_0'):\n                        tower_conv = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n                        tower_conv_1 = slim.conv2d(tower_conv, 384, 3, stride=2,\n                                                   padding='VALID', scope='Conv2d_1a_3x3')\n                    with tf.variable_scope('Branch_1'):\n                        tower_conv1 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n                        tower_conv1_1 = slim.conv2d(tower_conv1, 288, 3, stride=2,\n                                                    padding='VALID', scope='Conv2d_1a_3x3')\n                    with tf.variable_scope('Branch_2'):\n                        tower_conv2 = slim.conv2d(net, 256, 1, scope='Conv2d_0a_1x1')\n                        tower_conv2_1 = slim.conv2d(tower_conv2, 288, 3,\n                                                    scope='Conv2d_0b_3x3')\n                        tower_conv2_2 = slim.conv2d(tower_conv2_1, 320, 3, stride=2,\n                                                    padding='VALID', scope='Conv2d_1a_3x3')\n                    with tf.variable_scope('Branch_3'):\n                        tower_pool = slim.max_pool2d(net, 3, stride=2, padding='VALID',\n                                                     scope='MaxPool_1a_3x3')\n                    net = tf.concat([tower_conv_1, tower_conv1_1,\n                                        tower_conv2_2, tower_pool], 3)\n        \n                end_points['Mixed_7a'] = net\n        \n                net = slim.repeat(net, 9, block8, scale=0.20)\n                net = block8(net, activation_fn=None)\n        \n                net = slim.conv2d(net, 1536, 1, scope='Conv2d_7b_1x1')\n                end_points['Conv2d_7b_1x1'] = net\n        \n                with tf.variable_scope('Logits'):\n                    end_points['PrePool'] = net\n                    #pylint: disable=no-member\n                    net = slim.avg_pool2d(net, net.get_shape()[1:3], padding='VALID',\n                                          scope='AvgPool_1a_8x8')\n                    net = slim.flatten(net)\n          \n                    net = slim.dropout(net, dropout_keep_prob, is_training=is_training,\n                                       scope='Dropout')\n          \n                    end_points['PreLogitsFlatten'] = net\n                \n                net = slim.fully_connected(net, bottleneck_layer_size, activation_fn=None, \n                        scope='Bottleneck', reuse=False)\n  \n    return net, end_points\n"
  },
  {
    "path": "src/models/squeezenet.py",
    "content": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport tensorflow.contrib.slim as slim\n\ndef fire_module(inputs,\n                squeeze_depth,\n                expand_depth,\n                reuse=None,\n                scope=None,\n                outputs_collections=None):\n    with tf.variable_scope(scope, 'fire', [inputs], reuse=reuse):\n        with slim.arg_scope([slim.conv2d, slim.max_pool2d],\n                            outputs_collections=None):\n            net = squeeze(inputs, squeeze_depth)\n            outputs = expand(net, expand_depth)\n            return outputs\n\ndef squeeze(inputs, num_outputs):\n    return slim.conv2d(inputs, num_outputs, [1, 1], stride=1, scope='squeeze')\n\ndef expand(inputs, num_outputs):\n    with tf.variable_scope('expand'):\n        e1x1 = slim.conv2d(inputs, num_outputs, [1, 1], stride=1, scope='1x1')\n        e3x3 = slim.conv2d(inputs, num_outputs, [3, 3], scope='3x3')\n    return tf.concat([e1x1, e3x3], 3)\n\ndef inference(images, keep_probability, phase_train=True, bottleneck_layer_size=128, weight_decay=0.0, reuse=None):\n    batch_norm_params = {\n        # Decay for the moving averages.\n        'decay': 0.995,\n        # epsilon to prevent 0s in variance.\n        'epsilon': 0.001,\n        # force in-place updates of mean and variance estimates\n        'updates_collections': None,\n        # Moving averages ends up in the trainable variables collection\n        'variables_collections': [ tf.GraphKeys.TRAINABLE_VARIABLES ],\n    }\n    with slim.arg_scope([slim.conv2d, slim.fully_connected],\n                        weights_initializer=slim.xavier_initializer_conv2d(uniform=True),\n                        weights_regularizer=slim.l2_regularizer(weight_decay),\n                        normalizer_fn=slim.batch_norm,\n                        normalizer_params=batch_norm_params):\n        with tf.variable_scope('squeezenet', [images], reuse=reuse):\n            with slim.arg_scope([slim.batch_norm, slim.dropout],\n                                is_training=phase_train):\n                net = slim.conv2d(images, 96, [7, 7], stride=2, scope='conv1')\n                net = slim.max_pool2d(net, [3, 3], stride=2, scope='maxpool1')\n                net = fire_module(net, 16, 64, scope='fire2')\n                net = fire_module(net, 16, 64, scope='fire3')\n                net = fire_module(net, 32, 128, scope='fire4')\n                net = slim.max_pool2d(net, [2, 2], stride=2, scope='maxpool4')\n                net = fire_module(net, 32, 128, scope='fire5')\n                net = fire_module(net, 48, 192, scope='fire6')\n                net = fire_module(net, 48, 192, scope='fire7')\n                net = fire_module(net, 64, 256, scope='fire8')\n                net = slim.max_pool2d(net, [3, 3], stride=2, scope='maxpool8')\n                net = fire_module(net, 64, 256, scope='fire9')\n                net = slim.dropout(net, keep_probability)\n                net = slim.conv2d(net, 1000, [1, 1], activation_fn=None, normalizer_fn=None, scope='conv10')\n                net = slim.avg_pool2d(net, net.get_shape()[1:3], scope='avgpool10')\n                net = tf.squeeze(net, [1, 2], name='logits')\n                net = slim.fully_connected(net, bottleneck_layer_size, activation_fn=None, \n                        scope='Bottleneck', reuse=False)\n    return net, None\n"
  },
  {
    "path": "src/train_softmax.py",
    "content": "\"\"\"Training a face recognizer with TensorFlow using softmax cross entropy loss\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom datetime import datetime\nimport os.path\nimport time\nimport sys\nimport random\nimport tensorflow as tf\nimport numpy as np\nimport importlib\nimport argparse\nimport facenet\nimport lfw\nimport h5py\nimport math\nimport tensorflow.contrib.slim as slim\nfrom tensorflow.python.ops import data_flow_ops\nfrom tensorflow.python.framework import ops\nfrom tensorflow.python.ops import array_ops\n\ndef main(args):\n  \n    network = importlib.import_module(args.model_def)\n    image_size = (args.image_size, args.image_size)\n\n    subdir = datetime.strftime(datetime.now(), '%Y%m%d-%H%M%S')\n    log_dir = os.path.join(os.path.expanduser(args.logs_base_dir), subdir)\n    if not os.path.isdir(log_dir):  # Create the log directory if it doesn't exist\n        os.makedirs(log_dir)\n    model_dir = os.path.join(os.path.expanduser(args.models_base_dir), subdir)\n    if not os.path.isdir(model_dir):  # Create the model directory if it doesn't exist\n        os.makedirs(model_dir)\n\n    stat_file_name = os.path.join(log_dir, 'stat.h5')\n\n    # Write arguments to a text file\n    facenet.write_arguments_to_file(args, os.path.join(log_dir, 'arguments.txt'))\n        \n    # Store some git revision info in a text file in the log directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, log_dir, ' '.join(sys.argv))\n\n    np.random.seed(seed=args.seed)\n    random.seed(args.seed)\n    dataset = facenet.get_dataset(args.data_dir)\n    if args.filter_filename:\n        dataset = filter_dataset(dataset, os.path.expanduser(args.filter_filename), \n            args.filter_percentile, args.filter_min_nrof_images_per_class)\n        \n    if args.validation_set_split_ratio>0.0:\n        train_set, val_set = facenet.split_dataset(dataset, args.validation_set_split_ratio, args.min_nrof_val_images_per_class, 'SPLIT_IMAGES')\n    else:\n        train_set, val_set = dataset, []\n        \n    nrof_classes = len(train_set)\n    \n    print('Model directory: %s' % model_dir)\n    print('Log directory: %s' % log_dir)\n    pretrained_model = None\n    if args.pretrained_model:\n        pretrained_model = os.path.expanduser(args.pretrained_model)\n        print('Pre-trained model: %s' % pretrained_model)\n    \n    if args.lfw_dir:\n        print('LFW directory: %s' % args.lfw_dir)\n        # Read the file containing the pairs used for testing\n        pairs = lfw.read_pairs(os.path.expanduser(args.lfw_pairs))\n        # Get the paths for the corresponding images\n        lfw_paths, actual_issame = lfw.get_paths(os.path.expanduser(args.lfw_dir), pairs)\n    \n    with tf.Graph().as_default():\n        tf.set_random_seed(args.seed)\n        global_step = tf.Variable(0, trainable=False)\n        \n        # Get a list of image paths and their labels\n        image_list, label_list = facenet.get_image_paths_and_labels(train_set)\n        assert len(image_list)>0, 'The training set should not be empty'\n        \n        val_image_list, val_label_list = facenet.get_image_paths_and_labels(val_set)\n\n        # Create a queue that produces indices into the image_list and label_list \n        labels = ops.convert_to_tensor(label_list, dtype=tf.int32)\n        range_size = array_ops.shape(labels)[0]\n        index_queue = tf.train.range_input_producer(range_size, num_epochs=None,\n                             shuffle=True, seed=None, capacity=32)\n        \n        index_dequeue_op = index_queue.dequeue_many(args.batch_size*args.epoch_size, 'index_dequeue')\n        \n        learning_rate_placeholder = tf.placeholder(tf.float32, name='learning_rate')\n        batch_size_placeholder = tf.placeholder(tf.int32, name='batch_size')\n        phase_train_placeholder = tf.placeholder(tf.bool, name='phase_train')\n        image_paths_placeholder = tf.placeholder(tf.string, shape=(None,1), name='image_paths')\n        labels_placeholder = tf.placeholder(tf.int32, shape=(None,1), name='labels')\n        control_placeholder = tf.placeholder(tf.int32, shape=(None,1), name='control')\n        \n        nrof_preprocess_threads = 4\n        input_queue = data_flow_ops.FIFOQueue(capacity=2000000,\n                                    dtypes=[tf.string, tf.int32, tf.int32],\n                                    shapes=[(1,), (1,), (1,)],\n                                    shared_name=None, name=None)\n        enqueue_op = input_queue.enqueue_many([image_paths_placeholder, labels_placeholder, control_placeholder], name='enqueue_op')\n        image_batch, label_batch = facenet.create_input_pipeline(input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder)\n\n        image_batch = tf.identity(image_batch, 'image_batch')\n        image_batch = tf.identity(image_batch, 'input')\n        label_batch = tf.identity(label_batch, 'label_batch')\n        \n        print('Number of classes in training set: %d' % nrof_classes)\n        print('Number of examples in training set: %d' % len(image_list))\n\n        print('Number of classes in validation set: %d' % len(val_set))\n        print('Number of examples in validation set: %d' % len(val_image_list))\n        \n        print('Building training graph')\n        \n        # Build the inference graph\n        prelogits, _ = network.inference(image_batch, args.keep_probability, \n            phase_train=phase_train_placeholder, bottleneck_layer_size=args.embedding_size, \n            weight_decay=args.weight_decay)\n        logits = slim.fully_connected(prelogits, len(train_set), activation_fn=None, \n                weights_initializer=slim.initializers.xavier_initializer(), \n                weights_regularizer=slim.l2_regularizer(args.weight_decay),\n                scope='Logits', reuse=False)\n\n        embeddings = tf.nn.l2_normalize(prelogits, 1, 1e-10, name='embeddings')\n\n        # Norm for the prelogits\n        eps = 1e-4\n        prelogits_norm = tf.reduce_mean(tf.norm(tf.abs(prelogits)+eps, ord=args.prelogits_norm_p, axis=1))\n        tf.add_to_collection(tf.GraphKeys.REGULARIZATION_LOSSES, prelogits_norm * args.prelogits_norm_loss_factor)\n\n        # Add center loss\n        prelogits_center_loss, _ = facenet.center_loss(prelogits, label_batch, args.center_loss_alfa, nrof_classes)\n        tf.add_to_collection(tf.GraphKeys.REGULARIZATION_LOSSES, prelogits_center_loss * args.center_loss_factor)\n\n        learning_rate = tf.train.exponential_decay(learning_rate_placeholder, global_step,\n            args.learning_rate_decay_epochs*args.epoch_size, args.learning_rate_decay_factor, staircase=True)\n        tf.summary.scalar('learning_rate', learning_rate)\n\n        # Calculate the average cross entropy loss across the batch\n        cross_entropy = tf.nn.sparse_softmax_cross_entropy_with_logits(\n            labels=label_batch, logits=logits, name='cross_entropy_per_example')\n        cross_entropy_mean = tf.reduce_mean(cross_entropy, name='cross_entropy')\n        tf.add_to_collection('losses', cross_entropy_mean)\n        \n        correct_prediction = tf.cast(tf.equal(tf.argmax(logits, 1), tf.cast(label_batch, tf.int64)), tf.float32)\n        accuracy = tf.reduce_mean(correct_prediction)\n        \n        # Calculate the total losses\n        regularization_losses = tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)\n        total_loss = tf.add_n([cross_entropy_mean] + regularization_losses, name='total_loss')\n\n        # Build a Graph that trains the model with one batch of examples and updates the model parameters\n        train_op = facenet.train(total_loss, global_step, args.optimizer, \n            learning_rate, args.moving_average_decay, tf.global_variables(), args.log_histograms)\n        \n        # Create a saver\n        saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3)\n\n        # Build the summary operation based on the TF collection of Summaries.\n        summary_op = tf.summary.merge_all()\n\n        # Start running operations on the Graph.\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options, log_device_placement=False))\n        sess.run(tf.global_variables_initializer())\n        sess.run(tf.local_variables_initializer())\n        summary_writer = tf.summary.FileWriter(log_dir, sess.graph)\n        coord = tf.train.Coordinator()\n        tf.train.start_queue_runners(coord=coord, sess=sess)\n\n        with sess.as_default():\n\n            if pretrained_model:\n                print('Restoring pretrained model: %s' % pretrained_model)\n                saver.restore(sess, pretrained_model)\n\n            # Training and validation loop\n            print('Running training')\n            nrof_steps = args.max_nrof_epochs*args.epoch_size\n            nrof_val_samples = int(math.ceil(args.max_nrof_epochs / args.validate_every_n_epochs))   # Validate every validate_every_n_epochs as well as in the last epoch\n            stat = {\n                'loss': np.zeros((nrof_steps,), np.float32),\n                'center_loss': np.zeros((nrof_steps,), np.float32),\n                'reg_loss': np.zeros((nrof_steps,), np.float32),\n                'xent_loss': np.zeros((nrof_steps,), np.float32),\n                'prelogits_norm': np.zeros((nrof_steps,), np.float32),\n                'accuracy': np.zeros((nrof_steps,), np.float32),\n                'val_loss': np.zeros((nrof_val_samples,), np.float32),\n                'val_xent_loss': np.zeros((nrof_val_samples,), np.float32),\n                'val_accuracy': np.zeros((nrof_val_samples,), np.float32),\n                'lfw_accuracy': np.zeros((args.max_nrof_epochs,), np.float32),\n                'lfw_valrate': np.zeros((args.max_nrof_epochs,), np.float32),\n                'learning_rate': np.zeros((args.max_nrof_epochs,), np.float32),\n                'time_train': np.zeros((args.max_nrof_epochs,), np.float32),\n                'time_validate': np.zeros((args.max_nrof_epochs,), np.float32),\n                'time_evaluate': np.zeros((args.max_nrof_epochs,), np.float32),\n                'prelogits_hist': np.zeros((args.max_nrof_epochs, 1000), np.float32),\n              }\n            for epoch in range(1,args.max_nrof_epochs+1):\n                step = sess.run(global_step, feed_dict=None)\n                # Train for one epoch\n                t = time.time()\n                cont = train(args, sess, epoch, image_list, label_list, index_dequeue_op, enqueue_op, image_paths_placeholder, labels_placeholder,\n                    learning_rate_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder, global_step, \n                    total_loss, train_op, summary_op, summary_writer, regularization_losses, args.learning_rate_schedule_file,\n                    stat, cross_entropy_mean, accuracy, learning_rate,\n                    prelogits, prelogits_center_loss, args.random_rotate, args.random_crop, args.random_flip, prelogits_norm, args.prelogits_hist_max, args.use_fixed_image_standardization)\n                stat['time_train'][epoch-1] = time.time() - t\n                \n                if not cont:\n                    break\n                  \n                t = time.time()\n                if len(val_image_list)>0 and ((epoch-1) % args.validate_every_n_epochs == args.validate_every_n_epochs-1 or epoch==args.max_nrof_epochs):\n                    validate(args, sess, epoch, val_image_list, val_label_list, enqueue_op, image_paths_placeholder, labels_placeholder, control_placeholder,\n                        phase_train_placeholder, batch_size_placeholder, \n                        stat, total_loss, regularization_losses, cross_entropy_mean, accuracy, args.validate_every_n_epochs, args.use_fixed_image_standardization)\n                stat['time_validate'][epoch-1] = time.time() - t\n\n                # Save variables and the metagraph if it doesn't exist already\n                save_variables_and_metagraph(sess, saver, summary_writer, model_dir, subdir, epoch)\n\n                # Evaluate on LFW\n                t = time.time()\n                if args.lfw_dir:\n                    evaluate(sess, enqueue_op, image_paths_placeholder, labels_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder, \n                        embeddings, label_batch, lfw_paths, actual_issame, args.lfw_batch_size, args.lfw_nrof_folds, log_dir, step, summary_writer, stat, epoch, \n                        args.lfw_distance_metric, args.lfw_subtract_mean, args.lfw_use_flipped_images, args.use_fixed_image_standardization)\n                stat['time_evaluate'][epoch-1] = time.time() - t\n\n                print('Saving statistics')\n                with h5py.File(stat_file_name, 'w') as f:\n                    for key, value in stat.iteritems():\n                        f.create_dataset(key, data=value)\n    \n    return model_dir\n  \ndef find_threshold(var, percentile):\n    hist, bin_edges = np.histogram(var, 100)\n    cdf = np.float32(np.cumsum(hist)) / np.sum(hist)\n    bin_centers = (bin_edges[:-1]+bin_edges[1:])/2\n    #plt.plot(bin_centers, cdf)\n    threshold = np.interp(percentile*0.01, cdf, bin_centers)\n    return threshold\n  \ndef filter_dataset(dataset, data_filename, percentile, min_nrof_images_per_class):\n    with h5py.File(data_filename,'r') as f:\n        distance_to_center = np.array(f.get('distance_to_center'))\n        label_list = np.array(f.get('label_list'))\n        image_list = np.array(f.get('image_list'))\n        distance_to_center_threshold = find_threshold(distance_to_center, percentile)\n        indices = np.where(distance_to_center>=distance_to_center_threshold)[0]\n        filtered_dataset = dataset\n        removelist = []\n        for i in indices:\n            label = label_list[i]\n            image = image_list[i]\n            if image in filtered_dataset[label].image_paths:\n                filtered_dataset[label].image_paths.remove(image)\n            if len(filtered_dataset[label].image_paths)<min_nrof_images_per_class:\n                removelist.append(label)\n\n        ix = sorted(list(set(removelist)), reverse=True)\n        for i in ix:\n            del(filtered_dataset[i])\n\n    return filtered_dataset\n  \ndef train(args, sess, epoch, image_list, label_list, index_dequeue_op, enqueue_op, image_paths_placeholder, labels_placeholder, \n      learning_rate_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder, step, \n      loss, train_op, summary_op, summary_writer, reg_losses, learning_rate_schedule_file, \n      stat, cross_entropy_mean, accuracy, \n      learning_rate, prelogits, prelogits_center_loss, random_rotate, random_crop, random_flip, prelogits_norm, prelogits_hist_max, use_fixed_image_standardization):\n    batch_number = 0\n    \n    if args.learning_rate>0.0:\n        lr = args.learning_rate\n    else:\n        lr = facenet.get_learning_rate_from_file(learning_rate_schedule_file, epoch)\n        \n    if lr<=0:\n        return False \n\n    index_epoch = sess.run(index_dequeue_op)\n    label_epoch = np.array(label_list)[index_epoch]\n    image_epoch = np.array(image_list)[index_epoch]\n    \n    # Enqueue one epoch of image paths and labels\n    labels_array = np.expand_dims(np.array(label_epoch),1)\n    image_paths_array = np.expand_dims(np.array(image_epoch),1)\n    control_value = facenet.RANDOM_ROTATE * random_rotate + facenet.RANDOM_CROP * random_crop + facenet.RANDOM_FLIP * random_flip + facenet.FIXED_STANDARDIZATION * use_fixed_image_standardization\n    control_array = np.ones_like(labels_array) * control_value\n    sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array, control_placeholder: control_array})\n\n    # Training loop\n    train_time = 0\n    while batch_number < args.epoch_size:\n        start_time = time.time()\n        feed_dict = {learning_rate_placeholder: lr, phase_train_placeholder:True, batch_size_placeholder:args.batch_size}\n        tensor_list = [loss, train_op, step, reg_losses, prelogits, cross_entropy_mean, learning_rate, prelogits_norm, accuracy, prelogits_center_loss]\n        if batch_number % 100 == 0:\n            loss_, _, step_, reg_losses_, prelogits_, cross_entropy_mean_, lr_, prelogits_norm_, accuracy_, center_loss_, summary_str = sess.run(tensor_list + [summary_op], feed_dict=feed_dict)\n            summary_writer.add_summary(summary_str, global_step=step_)\n        else:\n            loss_, _, step_, reg_losses_, prelogits_, cross_entropy_mean_, lr_, prelogits_norm_, accuracy_, center_loss_ = sess.run(tensor_list, feed_dict=feed_dict)\n         \n        duration = time.time() - start_time\n        stat['loss'][step_-1] = loss_\n        stat['center_loss'][step_-1] = center_loss_\n        stat['reg_loss'][step_-1] = np.sum(reg_losses_)\n        stat['xent_loss'][step_-1] = cross_entropy_mean_\n        stat['prelogits_norm'][step_-1] = prelogits_norm_\n        stat['learning_rate'][epoch-1] = lr_\n        stat['accuracy'][step_-1] = accuracy_\n        stat['prelogits_hist'][epoch-1,:] += np.histogram(np.minimum(np.abs(prelogits_), prelogits_hist_max), bins=1000, range=(0.0, prelogits_hist_max))[0]\n        \n        duration = time.time() - start_time\n        print('Epoch: [%d][%d/%d]\\tTime %.3f\\tLoss %2.3f\\tXent %2.3f\\tRegLoss %2.3f\\tAccuracy %2.3f\\tLr %2.5f\\tCl %2.3f' %\n              (epoch, batch_number+1, args.epoch_size, duration, loss_, cross_entropy_mean_, np.sum(reg_losses_), accuracy_, lr_, center_loss_))\n        batch_number += 1\n        train_time += duration\n    # Add validation loss and accuracy to summary\n    summary = tf.Summary()\n    #pylint: disable=maybe-no-member\n    summary.value.add(tag='time/total', simple_value=train_time)\n    summary_writer.add_summary(summary, global_step=step_)\n    return True\n\ndef validate(args, sess, epoch, image_list, label_list, enqueue_op, image_paths_placeholder, labels_placeholder, control_placeholder,\n             phase_train_placeholder, batch_size_placeholder, \n             stat, loss, regularization_losses, cross_entropy_mean, accuracy, validate_every_n_epochs, use_fixed_image_standardization):\n  \n    print('Running forward pass on validation set')\n\n    nrof_batches = len(label_list) // args.lfw_batch_size\n    nrof_images = nrof_batches * args.lfw_batch_size\n    \n    # Enqueue one epoch of image paths and labels\n    labels_array = np.expand_dims(np.array(label_list[:nrof_images]),1)\n    image_paths_array = np.expand_dims(np.array(image_list[:nrof_images]),1)\n    control_array = np.ones_like(labels_array, np.int32)*facenet.FIXED_STANDARDIZATION * use_fixed_image_standardization\n    sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array, control_placeholder: control_array})\n\n    loss_array = np.zeros((nrof_batches,), np.float32)\n    xent_array = np.zeros((nrof_batches,), np.float32)\n    accuracy_array = np.zeros((nrof_batches,), np.float32)\n\n    # Training loop\n    start_time = time.time()\n    for i in range(nrof_batches):\n        feed_dict = {phase_train_placeholder:False, batch_size_placeholder:args.lfw_batch_size}\n        loss_, cross_entropy_mean_, accuracy_ = sess.run([loss, cross_entropy_mean, accuracy], feed_dict=feed_dict)\n        loss_array[i], xent_array[i], accuracy_array[i] = (loss_, cross_entropy_mean_, accuracy_)\n        if i % 10 == 9:\n            print('.', end='')\n            sys.stdout.flush()\n    print('')\n\n    duration = time.time() - start_time\n\n    val_index = (epoch-1)//validate_every_n_epochs\n    stat['val_loss'][val_index] = np.mean(loss_array)\n    stat['val_xent_loss'][val_index] = np.mean(xent_array)\n    stat['val_accuracy'][val_index] = np.mean(accuracy_array)\n\n    print('Validation Epoch: %d\\tTime %.3f\\tLoss %2.3f\\tXent %2.3f\\tAccuracy %2.3f' %\n          (epoch, duration, np.mean(loss_array), np.mean(xent_array), np.mean(accuracy_array)))\n\n\ndef evaluate(sess, enqueue_op, image_paths_placeholder, labels_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder, \n        embeddings, labels, image_paths, actual_issame, batch_size, nrof_folds, log_dir, step, summary_writer, stat, epoch, distance_metric, subtract_mean, use_flipped_images, use_fixed_image_standardization):\n    start_time = time.time()\n    # Run forward pass to calculate embeddings\n    print('Runnning forward pass on LFW images')\n    \n    # Enqueue one epoch of image paths and labels\n    nrof_embeddings = len(actual_issame)*2  # nrof_pairs * nrof_images_per_pair\n    nrof_flips = 2 if use_flipped_images else 1\n    nrof_images = nrof_embeddings * nrof_flips\n    labels_array = np.expand_dims(np.arange(0,nrof_images),1)\n    image_paths_array = np.expand_dims(np.repeat(np.array(image_paths),nrof_flips),1)\n    control_array = np.zeros_like(labels_array, np.int32)\n    if use_fixed_image_standardization:\n        control_array += np.ones_like(labels_array)*facenet.FIXED_STANDARDIZATION\n    if use_flipped_images:\n        # Flip every second image\n        control_array += (labels_array % 2)*facenet.FLIP\n    sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array, control_placeholder: control_array})\n    \n    embedding_size = int(embeddings.get_shape()[1])\n    assert nrof_images % batch_size == 0, 'The number of LFW images must be an integer multiple of the LFW batch size'\n    nrof_batches = nrof_images // batch_size\n    emb_array = np.zeros((nrof_images, embedding_size))\n    lab_array = np.zeros((nrof_images,))\n    for i in range(nrof_batches):\n        feed_dict = {phase_train_placeholder:False, batch_size_placeholder:batch_size}\n        emb, lab = sess.run([embeddings, labels], feed_dict=feed_dict)\n        lab_array[lab] = lab\n        emb_array[lab, :] = emb\n        if i % 10 == 9:\n            print('.', end='')\n            sys.stdout.flush()\n    print('')\n    embeddings = np.zeros((nrof_embeddings, embedding_size*nrof_flips))\n    if use_flipped_images:\n        # Concatenate embeddings for flipped and non flipped version of the images\n        embeddings[:,:embedding_size] = emb_array[0::2,:]\n        embeddings[:,embedding_size:] = emb_array[1::2,:]\n    else:\n        embeddings = emb_array\n\n    assert np.array_equal(lab_array, np.arange(nrof_images))==True, 'Wrong labels used for evaluation, possibly caused by training examples left in the input pipeline'\n    _, _, accuracy, val, val_std, far = lfw.evaluate(embeddings, actual_issame, nrof_folds=nrof_folds, distance_metric=distance_metric, subtract_mean=subtract_mean)\n    \n    print('Accuracy: %2.5f+-%2.5f' % (np.mean(accuracy), np.std(accuracy)))\n    print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far))\n    lfw_time = time.time() - start_time\n    # Add validation loss and accuracy to summary\n    summary = tf.Summary()\n    #pylint: disable=maybe-no-member\n    summary.value.add(tag='lfw/accuracy', simple_value=np.mean(accuracy))\n    summary.value.add(tag='lfw/val_rate', simple_value=val)\n    summary.value.add(tag='time/lfw', simple_value=lfw_time)\n    summary_writer.add_summary(summary, step)\n    with open(os.path.join(log_dir,'lfw_result.txt'),'at') as f:\n        f.write('%d\\t%.5f\\t%.5f\\n' % (step, np.mean(accuracy), val))\n    stat['lfw_accuracy'][epoch-1] = np.mean(accuracy)\n    stat['lfw_valrate'][epoch-1] = val\n\ndef save_variables_and_metagraph(sess, saver, summary_writer, model_dir, model_name, step):\n    # Save the model checkpoint\n    print('Saving variables')\n    start_time = time.time()\n    checkpoint_path = os.path.join(model_dir, 'model-%s.ckpt' % model_name)\n    saver.save(sess, checkpoint_path, global_step=step, write_meta_graph=False)\n    save_time_variables = time.time() - start_time\n    print('Variables saved in %.2f seconds' % save_time_variables)\n    metagraph_filename = os.path.join(model_dir, 'model-%s.meta' % model_name)\n    save_time_metagraph = 0  \n    if not os.path.exists(metagraph_filename):\n        print('Saving metagraph')\n        start_time = time.time()\n        saver.export_meta_graph(metagraph_filename)\n        save_time_metagraph = time.time() - start_time\n        print('Metagraph saved in %.2f seconds' % save_time_metagraph)\n    summary = tf.Summary()\n    #pylint: disable=maybe-no-member\n    summary.value.add(tag='time/save_variables', simple_value=save_time_variables)\n    summary.value.add(tag='time/save_metagraph', simple_value=save_time_metagraph)\n    summary_writer.add_summary(summary, step)\n  \n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('--logs_base_dir', type=str, \n        help='Directory where to write event logs.', default='~/logs/facenet')\n    parser.add_argument('--models_base_dir', type=str,\n        help='Directory where to write trained models and checkpoints.', default='~/models/facenet')\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n    parser.add_argument('--pretrained_model', type=str,\n        help='Load a pretrained model before training starts.')\n    parser.add_argument('--data_dir', type=str,\n        help='Path to the data directory containing aligned face patches.',\n        default='~/datasets/casia/casia_maxpy_mtcnnalign_182_160')\n    parser.add_argument('--model_def', type=str,\n        help='Model definition. Points to a module containing the definition of the inference graph.', default='models.inception_resnet_v1')\n    parser.add_argument('--max_nrof_epochs', type=int,\n        help='Number of epochs to run.', default=500)\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=90)\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--epoch_size', type=int,\n        help='Number of batches per epoch.', default=1000)\n    parser.add_argument('--embedding_size', type=int,\n        help='Dimensionality of the embedding.', default=128)\n    parser.add_argument('--random_crop', \n        help='Performs random cropping of training images. If false, the center image_size pixels from the training images are used. ' +\n         'If the size of the images in the data directory is equal to image_size no cropping is performed', action='store_true')\n    parser.add_argument('--random_flip', \n        help='Performs random horizontal flipping of training images.', action='store_true')\n    parser.add_argument('--random_rotate', \n        help='Performs random rotations of training images.', action='store_true')\n    parser.add_argument('--use_fixed_image_standardization', \n        help='Performs fixed standardization of images.', action='store_true')\n    parser.add_argument('--keep_probability', type=float,\n        help='Keep probability of dropout for the fully connected layer(s).', default=1.0)\n    parser.add_argument('--weight_decay', type=float,\n        help='L2 weight regularization.', default=0.0)\n    parser.add_argument('--center_loss_factor', type=float,\n        help='Center loss factor.', default=0.0)\n    parser.add_argument('--center_loss_alfa', type=float,\n        help='Center update rate for center loss.', default=0.95)\n    parser.add_argument('--prelogits_norm_loss_factor', type=float,\n        help='Loss based on the norm of the activations in the prelogits layer.', default=0.0)\n    parser.add_argument('--prelogits_norm_p', type=float,\n        help='Norm to use for prelogits norm loss.', default=1.0)\n    parser.add_argument('--prelogits_hist_max', type=float,\n        help='The max value for the prelogits histogram.', default=10.0)\n    parser.add_argument('--optimizer', type=str, choices=['ADAGRAD', 'ADADELTA', 'ADAM', 'RMSPROP', 'MOM'],\n        help='The optimization algorithm to use', default='ADAGRAD')\n    parser.add_argument('--learning_rate', type=float,\n        help='Initial learning rate. If set to a negative value a learning rate ' +\n        'schedule can be specified in the file \"learning_rate_schedule.txt\"', default=0.1)\n    parser.add_argument('--learning_rate_decay_epochs', type=int,\n        help='Number of epochs between learning rate decay.', default=100)\n    parser.add_argument('--learning_rate_decay_factor', type=float,\n        help='Learning rate decay factor.', default=1.0)\n    parser.add_argument('--moving_average_decay', type=float,\n        help='Exponential decay for tracking of training parameters.', default=0.9999)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    parser.add_argument('--nrof_preprocess_threads', type=int,\n        help='Number of preprocessing (data loading and augmentation) threads.', default=4)\n    parser.add_argument('--log_histograms', \n        help='Enables logging of weight/bias histograms in tensorboard.', action='store_true')\n    parser.add_argument('--learning_rate_schedule_file', type=str,\n        help='File containing the learning rate schedule that is used when learning_rate is set to to -1.', default='data/learning_rate_schedule.txt')\n    parser.add_argument('--filter_filename', type=str,\n        help='File containing image data used for dataset filtering', default='')\n    parser.add_argument('--filter_percentile', type=float,\n        help='Keep only the percentile images closed to its class center', default=100.0)\n    parser.add_argument('--filter_min_nrof_images_per_class', type=int,\n        help='Keep only the classes with this number of examples or more', default=0)\n    parser.add_argument('--validate_every_n_epochs', type=int,\n        help='Number of epoch between validation', default=5)\n    parser.add_argument('--validation_set_split_ratio', type=float,\n        help='The ratio of the total dataset to use for validation', default=0.0)\n    parser.add_argument('--min_nrof_val_images_per_class', type=float,\n        help='Classes with fewer images will be removed from the validation set', default=0)\n \n    # Parameters for validation on LFW\n    parser.add_argument('--lfw_pairs', type=str,\n        help='The file containing the pairs to use for validation.', default='data/pairs.txt')\n    parser.add_argument('--lfw_dir', type=str,\n        help='Path to the data directory containing aligned face patches.', default='')\n    parser.add_argument('--lfw_batch_size', type=int,\n        help='Number of images to process in a batch in the LFW test set.', default=100)\n    parser.add_argument('--lfw_nrof_folds', type=int,\n        help='Number of folds to use for cross validation. Mainly used for testing.', default=10)\n    parser.add_argument('--lfw_distance_metric', type=int,\n        help='Type of distance metric to use. 0: Euclidian, 1:Cosine similarity distance.', default=0)\n    parser.add_argument('--lfw_use_flipped_images', \n        help='Concatenates embeddings for the image and its horizontally flipped counterpart.', action='store_true')\n    parser.add_argument('--lfw_subtract_mean', \n        help='Subtract feature mean before calculating distance.', action='store_true')\n    return parser.parse_args(argv)\n  \n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/train_tripletloss.py",
    "content": "\"\"\"Training a face recognizer with TensorFlow based on the FaceNet paper\nFaceNet: A Unified Embedding for Face Recognition and Clustering: http://arxiv.org/abs/1503.03832\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom datetime import datetime\nimport os.path\nimport time\nimport sys\nimport tensorflow as tf\nimport numpy as np\nimport importlib\nimport itertools\nimport argparse\nimport facenet\nimport lfw\n\nfrom tensorflow.python.ops import data_flow_ops\n\nfrom six.moves import xrange  # @UnresolvedImport\n\ndef main(args):\n  \n    network = importlib.import_module(args.model_def)\n\n    subdir = datetime.strftime(datetime.now(), '%Y%m%d-%H%M%S')\n    log_dir = os.path.join(os.path.expanduser(args.logs_base_dir), subdir)\n    if not os.path.isdir(log_dir):  # Create the log directory if it doesn't exist\n        os.makedirs(log_dir)\n    model_dir = os.path.join(os.path.expanduser(args.models_base_dir), subdir)\n    if not os.path.isdir(model_dir):  # Create the model directory if it doesn't exist\n        os.makedirs(model_dir)\n\n    # Write arguments to a text file\n    facenet.write_arguments_to_file(args, os.path.join(log_dir, 'arguments.txt'))\n        \n    # Store some git revision info in a text file in the log directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, log_dir, ' '.join(sys.argv))\n\n    np.random.seed(seed=args.seed)\n    train_set = facenet.get_dataset(args.data_dir)\n    \n    print('Model directory: %s' % model_dir)\n    print('Log directory: %s' % log_dir)\n    if args.pretrained_model:\n        print('Pre-trained model: %s' % os.path.expanduser(args.pretrained_model))\n    \n    if args.lfw_dir:\n        print('LFW directory: %s' % args.lfw_dir)\n        # Read the file containing the pairs used for testing\n        pairs = lfw.read_pairs(os.path.expanduser(args.lfw_pairs))\n        # Get the paths for the corresponding images\n        lfw_paths, actual_issame = lfw.get_paths(os.path.expanduser(args.lfw_dir), pairs)\n        \n    \n    with tf.Graph().as_default():\n        tf.set_random_seed(args.seed)\n        global_step = tf.Variable(0, trainable=False)\n\n        # Placeholder for the learning rate\n        learning_rate_placeholder = tf.placeholder(tf.float32, name='learning_rate')\n        \n        batch_size_placeholder = tf.placeholder(tf.int32, name='batch_size')\n        \n        phase_train_placeholder = tf.placeholder(tf.bool, name='phase_train')\n        \n        image_paths_placeholder = tf.placeholder(tf.string, shape=(None,3), name='image_paths')\n        labels_placeholder = tf.placeholder(tf.int64, shape=(None,3), name='labels')\n        \n        input_queue = data_flow_ops.FIFOQueue(capacity=100000,\n                                    dtypes=[tf.string, tf.int64],\n                                    shapes=[(3,), (3,)],\n                                    shared_name=None, name=None)\n        enqueue_op = input_queue.enqueue_many([image_paths_placeholder, labels_placeholder])\n        \n        nrof_preprocess_threads = 4\n        images_and_labels = []\n        for _ in range(nrof_preprocess_threads):\n            filenames, label = input_queue.dequeue()\n            images = []\n            for filename in tf.unstack(filenames):\n                file_contents = tf.read_file(filename)\n                image = tf.image.decode_image(file_contents, channels=3)\n                \n                if args.random_crop:\n                    image = tf.random_crop(image, [args.image_size, args.image_size, 3])\n                else:\n                    image = tf.image.resize_image_with_crop_or_pad(image, args.image_size, args.image_size)\n                if args.random_flip:\n                    image = tf.image.random_flip_left_right(image)\n    \n                #pylint: disable=no-member\n                image.set_shape((args.image_size, args.image_size, 3))\n                images.append(tf.image.per_image_standardization(image))\n            images_and_labels.append([images, label])\n    \n        image_batch, labels_batch = tf.train.batch_join(\n            images_and_labels, batch_size=batch_size_placeholder, \n            shapes=[(args.image_size, args.image_size, 3), ()], enqueue_many=True,\n            capacity=4 * nrof_preprocess_threads * args.batch_size,\n            allow_smaller_final_batch=True)\n        image_batch = tf.identity(image_batch, 'image_batch')\n        image_batch = tf.identity(image_batch, 'input')\n        labels_batch = tf.identity(labels_batch, 'label_batch')\n\n        # Build the inference graph\n        prelogits, _ = network.inference(image_batch, args.keep_probability, \n            phase_train=phase_train_placeholder, bottleneck_layer_size=args.embedding_size,\n            weight_decay=args.weight_decay)\n        \n        embeddings = tf.nn.l2_normalize(prelogits, 1, 1e-10, name='embeddings')\n        # Split embeddings into anchor, positive and negative and calculate triplet loss\n        anchor, positive, negative = tf.unstack(tf.reshape(embeddings, [-1,3,args.embedding_size]), 3, 1)\n        triplet_loss = facenet.triplet_loss(anchor, positive, negative, args.alpha)\n        \n        learning_rate = tf.train.exponential_decay(learning_rate_placeholder, global_step,\n            args.learning_rate_decay_epochs*args.epoch_size, args.learning_rate_decay_factor, staircase=True)\n        tf.summary.scalar('learning_rate', learning_rate)\n\n        # Calculate the total losses\n        regularization_losses = tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)\n        total_loss = tf.add_n([triplet_loss] + regularization_losses, name='total_loss')\n\n        # Build a Graph that trains the model with one batch of examples and updates the model parameters\n        train_op = facenet.train(total_loss, global_step, args.optimizer, \n            learning_rate, args.moving_average_decay, tf.global_variables())\n        \n        # Create a saver\n        saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=3)\n\n        # Build the summary operation based on the TF collection of Summaries.\n        summary_op = tf.summary.merge_all()\n\n        # Start running operations on the Graph.\n        gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=args.gpu_memory_fraction)\n        sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))        \n\n        # Initialize variables\n        sess.run(tf.global_variables_initializer(), feed_dict={phase_train_placeholder:True})\n        sess.run(tf.local_variables_initializer(), feed_dict={phase_train_placeholder:True})\n\n        summary_writer = tf.summary.FileWriter(log_dir, sess.graph)\n        coord = tf.train.Coordinator()\n        tf.train.start_queue_runners(coord=coord, sess=sess)\n\n        with sess.as_default():\n\n            if args.pretrained_model:\n                print('Restoring pretrained model: %s' % args.pretrained_model)\n                saver.restore(sess, os.path.expanduser(args.pretrained_model))\n\n            # Training and validation loop\n            epoch = 0\n            while epoch < args.max_nrof_epochs:\n                step = sess.run(global_step, feed_dict=None)\n                epoch = step // args.epoch_size\n                # Train for one epoch\n                train(args, sess, train_set, epoch, image_paths_placeholder, labels_placeholder, labels_batch,\n                    batch_size_placeholder, learning_rate_placeholder, phase_train_placeholder, enqueue_op, input_queue, global_step, \n                    embeddings, total_loss, train_op, summary_op, summary_writer, args.learning_rate_schedule_file,\n                    args.embedding_size, anchor, positive, negative, triplet_loss)\n\n                # Save variables and the metagraph if it doesn't exist already\n                save_variables_and_metagraph(sess, saver, summary_writer, model_dir, subdir, step)\n\n                # Evaluate on LFW\n                if args.lfw_dir:\n                    evaluate(sess, lfw_paths, embeddings, labels_batch, image_paths_placeholder, labels_placeholder, \n                            batch_size_placeholder, learning_rate_placeholder, phase_train_placeholder, enqueue_op, actual_issame, args.batch_size, \n                            args.lfw_nrof_folds, log_dir, step, summary_writer, args.embedding_size)\n\n    return model_dir\n\n\ndef train(args, sess, dataset, epoch, image_paths_placeholder, labels_placeholder, labels_batch,\n          batch_size_placeholder, learning_rate_placeholder, phase_train_placeholder, enqueue_op, input_queue, global_step, \n          embeddings, loss, train_op, summary_op, summary_writer, learning_rate_schedule_file,\n          embedding_size, anchor, positive, negative, triplet_loss):\n    batch_number = 0\n    \n    if args.learning_rate>0.0:\n        lr = args.learning_rate\n    else:\n        lr = facenet.get_learning_rate_from_file(learning_rate_schedule_file, epoch)\n    while batch_number < args.epoch_size:\n        # Sample people randomly from the dataset\n        image_paths, num_per_class = sample_people(dataset, args.people_per_batch, args.images_per_person)\n        \n        print('Running forward pass on sampled images: ', end='')\n        start_time = time.time()\n        nrof_examples = args.people_per_batch * args.images_per_person\n        labels_array = np.reshape(np.arange(nrof_examples),(-1,3))\n        image_paths_array = np.reshape(np.expand_dims(np.array(image_paths),1), (-1,3))\n        sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array})\n        emb_array = np.zeros((nrof_examples, embedding_size))\n        nrof_batches = int(np.ceil(nrof_examples / args.batch_size))\n        for i in range(nrof_batches):\n            batch_size = min(nrof_examples-i*args.batch_size, args.batch_size)\n            emb, lab = sess.run([embeddings, labels_batch], feed_dict={batch_size_placeholder: batch_size, \n                learning_rate_placeholder: lr, phase_train_placeholder: True})\n            emb_array[lab,:] = emb\n        print('%.3f' % (time.time()-start_time))\n\n        # Select triplets based on the embeddings\n        print('Selecting suitable triplets for training')\n        triplets, nrof_random_negs, nrof_triplets = select_triplets(emb_array, num_per_class, \n            image_paths, args.people_per_batch, args.alpha)\n        selection_time = time.time() - start_time\n        print('(nrof_random_negs, nrof_triplets) = (%d, %d): time=%.3f seconds' % \n            (nrof_random_negs, nrof_triplets, selection_time))\n\n        # Perform training on the selected triplets\n        nrof_batches = int(np.ceil(nrof_triplets*3/args.batch_size))\n        triplet_paths = list(itertools.chain(*triplets))\n        labels_array = np.reshape(np.arange(len(triplet_paths)),(-1,3))\n        triplet_paths_array = np.reshape(np.expand_dims(np.array(triplet_paths),1), (-1,3))\n        sess.run(enqueue_op, {image_paths_placeholder: triplet_paths_array, labels_placeholder: labels_array})\n        nrof_examples = len(triplet_paths)\n        train_time = 0\n        i = 0\n        emb_array = np.zeros((nrof_examples, embedding_size))\n        loss_array = np.zeros((nrof_triplets,))\n        summary = tf.Summary()\n        step = 0\n        while i < nrof_batches:\n            start_time = time.time()\n            batch_size = min(nrof_examples-i*args.batch_size, args.batch_size)\n            feed_dict = {batch_size_placeholder: batch_size, learning_rate_placeholder: lr, phase_train_placeholder: True}\n            err, _, step, emb, lab = sess.run([loss, train_op, global_step, embeddings, labels_batch], feed_dict=feed_dict)\n            emb_array[lab,:] = emb\n            loss_array[i] = err\n            duration = time.time() - start_time\n            print('Epoch: [%d][%d/%d]\\tTime %.3f\\tLoss %2.3f' %\n                  (epoch, batch_number+1, args.epoch_size, duration, err))\n            batch_number += 1\n            i += 1\n            train_time += duration\n            summary.value.add(tag='loss', simple_value=err)\n            \n        # Add validation loss and accuracy to summary\n        #pylint: disable=maybe-no-member\n        summary.value.add(tag='time/selection', simple_value=selection_time)\n        summary_writer.add_summary(summary, step)\n    return step\n  \ndef select_triplets(embeddings, nrof_images_per_class, image_paths, people_per_batch, alpha):\n    \"\"\" Select the triplets for training\n    \"\"\"\n    trip_idx = 0\n    emb_start_idx = 0\n    num_trips = 0\n    triplets = []\n    \n    # VGG Face: Choosing good triplets is crucial and should strike a balance between\n    #  selecting informative (i.e. challenging) examples and swamping training with examples that\n    #  are too hard. This is achieve by extending each pair (a, p) to a triplet (a, p, n) by sampling\n    #  the image n at random, but only between the ones that violate the triplet loss margin. The\n    #  latter is a form of hard-negative mining, but it is not as aggressive (and much cheaper) than\n    #  choosing the maximally violating example, as often done in structured output learning.\n\n    for i in xrange(people_per_batch):\n        nrof_images = int(nrof_images_per_class[i])\n        for j in xrange(1,nrof_images):\n            a_idx = emb_start_idx + j - 1\n            neg_dists_sqr = np.sum(np.square(embeddings[a_idx] - embeddings), 1)\n            for pair in xrange(j, nrof_images): # For every possible positive pair.\n                p_idx = emb_start_idx + pair\n                pos_dist_sqr = np.sum(np.square(embeddings[a_idx]-embeddings[p_idx]))\n                neg_dists_sqr[emb_start_idx:emb_start_idx+nrof_images] = np.NaN\n                #all_neg = np.where(np.logical_and(neg_dists_sqr-pos_dist_sqr<alpha, pos_dist_sqr<neg_dists_sqr))[0]  # FaceNet selection\n                all_neg = np.where(neg_dists_sqr-pos_dist_sqr<alpha)[0] # VGG Face selecction\n                nrof_random_negs = all_neg.shape[0]\n                if nrof_random_negs>0:\n                    rnd_idx = np.random.randint(nrof_random_negs)\n                    n_idx = all_neg[rnd_idx]\n                    triplets.append((image_paths[a_idx], image_paths[p_idx], image_paths[n_idx]))\n                    #print('Triplet %d: (%d, %d, %d), pos_dist=%2.6f, neg_dist=%2.6f (%d, %d, %d, %d, %d)' % \n                    #    (trip_idx, a_idx, p_idx, n_idx, pos_dist_sqr, neg_dists_sqr[n_idx], nrof_random_negs, rnd_idx, i, j, emb_start_idx))\n                    trip_idx += 1\n\n                num_trips += 1\n\n        emb_start_idx += nrof_images\n\n    np.random.shuffle(triplets)\n    return triplets, num_trips, len(triplets)\n\ndef sample_people(dataset, people_per_batch, images_per_person):\n    nrof_images = people_per_batch * images_per_person\n  \n    # Sample classes from the dataset\n    nrof_classes = len(dataset)\n    class_indices = np.arange(nrof_classes)\n    np.random.shuffle(class_indices)\n    \n    i = 0\n    image_paths = []\n    num_per_class = []\n    sampled_class_indices = []\n    # Sample images from these classes until we have enough\n    while len(image_paths)<nrof_images:\n        class_index = class_indices[i]\n        nrof_images_in_class = len(dataset[class_index])\n        image_indices = np.arange(nrof_images_in_class)\n        np.random.shuffle(image_indices)\n        nrof_images_from_class = min(nrof_images_in_class, images_per_person, nrof_images-len(image_paths))\n        idx = image_indices[0:nrof_images_from_class]\n        image_paths_for_class = [dataset[class_index].image_paths[j] for j in idx]\n        sampled_class_indices += [class_index]*nrof_images_from_class\n        image_paths += image_paths_for_class\n        num_per_class.append(nrof_images_from_class)\n        i+=1\n  \n    return image_paths, num_per_class\n\ndef evaluate(sess, image_paths, embeddings, labels_batch, image_paths_placeholder, labels_placeholder, \n        batch_size_placeholder, learning_rate_placeholder, phase_train_placeholder, enqueue_op, actual_issame, batch_size, \n        nrof_folds, log_dir, step, summary_writer, embedding_size):\n    start_time = time.time()\n    # Run forward pass to calculate embeddings\n    print('Running forward pass on LFW images: ', end='')\n    \n    nrof_images = len(actual_issame)*2\n    assert(len(image_paths)==nrof_images)\n    labels_array = np.reshape(np.arange(nrof_images),(-1,3))\n    image_paths_array = np.reshape(np.expand_dims(np.array(image_paths),1), (-1,3))\n    sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array})\n    emb_array = np.zeros((nrof_images, embedding_size))\n    nrof_batches = int(np.ceil(nrof_images / batch_size))\n    label_check_array = np.zeros((nrof_images,))\n    for i in xrange(nrof_batches):\n        batch_size = min(nrof_images-i*batch_size, batch_size)\n        emb, lab = sess.run([embeddings, labels_batch], feed_dict={batch_size_placeholder: batch_size,\n            learning_rate_placeholder: 0.0, phase_train_placeholder: False})\n        emb_array[lab,:] = emb\n        label_check_array[lab] = 1\n    print('%.3f' % (time.time()-start_time))\n    \n    assert(np.all(label_check_array==1))\n    \n    _, _, accuracy, val, val_std, far = lfw.evaluate(emb_array, actual_issame, nrof_folds=nrof_folds)\n    \n    print('Accuracy: %1.3f+-%1.3f' % (np.mean(accuracy), np.std(accuracy)))\n    print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far))\n    lfw_time = time.time() - start_time\n    # Add validation loss and accuracy to summary\n    summary = tf.Summary()\n    #pylint: disable=maybe-no-member\n    summary.value.add(tag='lfw/accuracy', simple_value=np.mean(accuracy))\n    summary.value.add(tag='lfw/val_rate', simple_value=val)\n    summary.value.add(tag='time/lfw', simple_value=lfw_time)\n    summary_writer.add_summary(summary, step)\n    with open(os.path.join(log_dir,'lfw_result.txt'),'at') as f:\n        f.write('%d\\t%.5f\\t%.5f\\n' % (step, np.mean(accuracy), val))\n\ndef save_variables_and_metagraph(sess, saver, summary_writer, model_dir, model_name, step):\n    # Save the model checkpoint\n    print('Saving variables')\n    start_time = time.time()\n    checkpoint_path = os.path.join(model_dir, 'model-%s.ckpt' % model_name)\n    saver.save(sess, checkpoint_path, global_step=step, write_meta_graph=False)\n    save_time_variables = time.time() - start_time\n    print('Variables saved in %.2f seconds' % save_time_variables)\n    metagraph_filename = os.path.join(model_dir, 'model-%s.meta' % model_name)\n    save_time_metagraph = 0  \n    if not os.path.exists(metagraph_filename):\n        print('Saving metagraph')\n        start_time = time.time()\n        saver.export_meta_graph(metagraph_filename)\n        save_time_metagraph = time.time() - start_time\n        print('Metagraph saved in %.2f seconds' % save_time_metagraph)\n    summary = tf.Summary()\n    #pylint: disable=maybe-no-member\n    summary.value.add(tag='time/save_variables', simple_value=save_time_variables)\n    summary.value.add(tag='time/save_metagraph', simple_value=save_time_metagraph)\n    summary_writer.add_summary(summary, step)\n  \n  \ndef get_learning_rate_from_file(filename, epoch):\n    with open(filename, 'r') as f:\n        for line in f.readlines():\n            line = line.split('#', 1)[0]\n            if line:\n                par = line.strip().split(':')\n                e = int(par[0])\n                lr = float(par[1])\n                if e <= epoch:\n                    learning_rate = lr\n                else:\n                    return learning_rate\n    \n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('--logs_base_dir', type=str, \n        help='Directory where to write event logs.', default='~/logs/facenet')\n    parser.add_argument('--models_base_dir', type=str,\n        help='Directory where to write trained models and checkpoints.', default='~/models/facenet')\n    parser.add_argument('--gpu_memory_fraction', type=float,\n        help='Upper bound on the amount of GPU memory that will be used by the process.', default=1.0)\n    parser.add_argument('--pretrained_model', type=str,\n        help='Load a pretrained model before training starts.')\n    parser.add_argument('--data_dir', type=str,\n        help='Path to the data directory containing aligned face patches.',\n        default='~/datasets/casia/casia_maxpy_mtcnnalign_182_160')\n    parser.add_argument('--model_def', type=str,\n        help='Model definition. Points to a module containing the definition of the inference graph.', default='models.inception_resnet_v1')\n    parser.add_argument('--max_nrof_epochs', type=int,\n        help='Number of epochs to run.', default=500)\n    parser.add_argument('--batch_size', type=int,\n        help='Number of images to process in a batch.', default=90)\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--people_per_batch', type=int,\n        help='Number of people per batch.', default=45)\n    parser.add_argument('--images_per_person', type=int,\n        help='Number of images per person.', default=40)\n    parser.add_argument('--epoch_size', type=int,\n        help='Number of batches per epoch.', default=1000)\n    parser.add_argument('--alpha', type=float,\n        help='Positive to negative triplet distance margin.', default=0.2)\n    parser.add_argument('--embedding_size', type=int,\n        help='Dimensionality of the embedding.', default=128)\n    parser.add_argument('--random_crop', \n        help='Performs random cropping of training images. If false, the center image_size pixels from the training images are used. ' +\n         'If the size of the images in the data directory is equal to image_size no cropping is performed', action='store_true')\n    parser.add_argument('--random_flip', \n        help='Performs random horizontal flipping of training images.', action='store_true')\n    parser.add_argument('--keep_probability', type=float,\n        help='Keep probability of dropout for the fully connected layer(s).', default=1.0)\n    parser.add_argument('--weight_decay', type=float,\n        help='L2 weight regularization.', default=0.0)\n    parser.add_argument('--optimizer', type=str, choices=['ADAGRAD', 'ADADELTA', 'ADAM', 'RMSPROP', 'MOM'],\n        help='The optimization algorithm to use', default='ADAGRAD')\n    parser.add_argument('--learning_rate', type=float,\n        help='Initial learning rate. If set to a negative value a learning rate ' +\n        'schedule can be specified in the file \"learning_rate_schedule.txt\"', default=0.1)\n    parser.add_argument('--learning_rate_decay_epochs', type=int,\n        help='Number of epochs between learning rate decay.', default=100)\n    parser.add_argument('--learning_rate_decay_factor', type=float,\n        help='Learning rate decay factor.', default=1.0)\n    parser.add_argument('--moving_average_decay', type=float,\n        help='Exponential decay for tracking of training parameters.', default=0.9999)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    parser.add_argument('--learning_rate_schedule_file', type=str,\n        help='File containing the learning rate schedule that is used when learning_rate is set to to -1.', default='data/learning_rate_schedule.txt')\n\n    # Parameters for validation on LFW\n    parser.add_argument('--lfw_pairs', type=str,\n        help='The file containing the pairs to use for validation.', default='data/pairs.txt')\n    parser.add_argument('--lfw_dir', type=str,\n        help='Path to the data directory containing aligned face patches.', default='')\n    parser.add_argument('--lfw_nrof_folds', type=int,\n        help='Number of folds to use for cross validation. Mainly used for testing.', default=10)\n    return parser.parse_args(argv)\n  \n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "src/validate_on_lfw.py",
    "content": "\"\"\"Validate a face recognizer on the \"Labeled Faces in the Wild\" dataset (http://vis-www.cs.umass.edu/lfw/).\nEmbeddings are calculated using the pairs from http://vis-www.cs.umass.edu/lfw/pairs.txt and the ROC curve\nis calculated and plotted. Both the model metagraph and the model parameters need to exist\nin the same directory, and the metagraph should have the extension '.meta'.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport argparse\nimport facenet\nimport lfw\nimport os\nimport sys\nfrom tensorflow.python.ops import data_flow_ops\nfrom sklearn import metrics\nfrom scipy.optimize import brentq\nfrom scipy import interpolate\n\ndef main(args):\n  \n    with tf.Graph().as_default():\n      \n        with tf.Session() as sess:\n            \n            # Read the file containing the pairs used for testing\n            pairs = lfw.read_pairs(os.path.expanduser(args.lfw_pairs))\n\n            # Get the paths for the corresponding images\n            paths, actual_issame = lfw.get_paths(os.path.expanduser(args.lfw_dir), pairs)\n            \n            image_paths_placeholder = tf.placeholder(tf.string, shape=(None,1), name='image_paths')\n            labels_placeholder = tf.placeholder(tf.int32, shape=(None,1), name='labels')\n            batch_size_placeholder = tf.placeholder(tf.int32, name='batch_size')\n            control_placeholder = tf.placeholder(tf.int32, shape=(None,1), name='control')\n            phase_train_placeholder = tf.placeholder(tf.bool, name='phase_train')\n \n            nrof_preprocess_threads = 4\n            image_size = (args.image_size, args.image_size)\n            eval_input_queue = data_flow_ops.FIFOQueue(capacity=2000000,\n                                        dtypes=[tf.string, tf.int32, tf.int32],\n                                        shapes=[(1,), (1,), (1,)],\n                                        shared_name=None, name=None)\n            eval_enqueue_op = eval_input_queue.enqueue_many([image_paths_placeholder, labels_placeholder, control_placeholder], name='eval_enqueue_op')\n            image_batch, label_batch = facenet.create_input_pipeline(eval_input_queue, image_size, nrof_preprocess_threads, batch_size_placeholder)\n     \n            # Load the model\n            input_map = {'image_batch': image_batch, 'label_batch': label_batch, 'phase_train': phase_train_placeholder}\n            facenet.load_model(args.model, input_map=input_map)\n\n            # Get output tensor\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n#              \n            coord = tf.train.Coordinator()\n            tf.train.start_queue_runners(coord=coord, sess=sess)\n\n            evaluate(sess, eval_enqueue_op, image_paths_placeholder, labels_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder,\n                embeddings, label_batch, paths, actual_issame, args.lfw_batch_size, args.lfw_nrof_folds, args.distance_metric, args.subtract_mean,\n                args.use_flipped_images, args.use_fixed_image_standardization)\n\n              \ndef evaluate(sess, enqueue_op, image_paths_placeholder, labels_placeholder, phase_train_placeholder, batch_size_placeholder, control_placeholder,\n        embeddings, labels, image_paths, actual_issame, batch_size, nrof_folds, distance_metric, subtract_mean, use_flipped_images, use_fixed_image_standardization):\n    # Run forward pass to calculate embeddings\n    print('Runnning forward pass on LFW images')\n    \n    # Enqueue one epoch of image paths and labels\n    nrof_embeddings = len(actual_issame)*2  # nrof_pairs * nrof_images_per_pair\n    nrof_flips = 2 if use_flipped_images else 1\n    nrof_images = nrof_embeddings * nrof_flips\n    labels_array = np.expand_dims(np.arange(0,nrof_images),1)\n    image_paths_array = np.expand_dims(np.repeat(np.array(image_paths),nrof_flips),1)\n    control_array = np.zeros_like(labels_array, np.int32)\n    if use_fixed_image_standardization:\n        control_array += np.ones_like(labels_array)*facenet.FIXED_STANDARDIZATION\n    if use_flipped_images:\n        # Flip every second image\n        control_array += (labels_array % 2)*facenet.FLIP\n    sess.run(enqueue_op, {image_paths_placeholder: image_paths_array, labels_placeholder: labels_array, control_placeholder: control_array})\n    \n    embedding_size = int(embeddings.get_shape()[1])\n    assert nrof_images % batch_size == 0, 'The number of LFW images must be an integer multiple of the LFW batch size'\n    nrof_batches = nrof_images // batch_size\n    emb_array = np.zeros((nrof_images, embedding_size))\n    lab_array = np.zeros((nrof_images,))\n    for i in range(nrof_batches):\n        feed_dict = {phase_train_placeholder:False, batch_size_placeholder:batch_size}\n        emb, lab = sess.run([embeddings, labels], feed_dict=feed_dict)\n        lab_array[lab] = lab\n        emb_array[lab, :] = emb\n        if i % 10 == 9:\n            print('.', end='')\n            sys.stdout.flush()\n    print('')\n    embeddings = np.zeros((nrof_embeddings, embedding_size*nrof_flips))\n    if use_flipped_images:\n        # Concatenate embeddings for flipped and non flipped version of the images\n        embeddings[:,:embedding_size] = emb_array[0::2,:]\n        embeddings[:,embedding_size:] = emb_array[1::2,:]\n    else:\n        embeddings = emb_array\n\n    assert np.array_equal(lab_array, np.arange(nrof_images))==True, 'Wrong labels used for evaluation, possibly caused by training examples left in the input pipeline'\n    tpr, fpr, accuracy, val, val_std, far = lfw.evaluate(embeddings, actual_issame, nrof_folds=nrof_folds, distance_metric=distance_metric, subtract_mean=subtract_mean)\n    \n    print('Accuracy: %2.5f+-%2.5f' % (np.mean(accuracy), np.std(accuracy)))\n    print('Validation rate: %2.5f+-%2.5f @ FAR=%2.5f' % (val, val_std, far))\n    \n    auc = metrics.auc(fpr, tpr)\n    print('Area Under Curve (AUC): %1.3f' % auc)\n    eer = brentq(lambda x: 1. - x - interpolate.interp1d(fpr, tpr)(x), 0., 1.)\n    print('Equal Error Rate (EER): %1.3f' % eer)\n    \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('lfw_dir', type=str,\n        help='Path to the data directory containing aligned LFW face patches.')\n    parser.add_argument('--lfw_batch_size', type=int,\n        help='Number of images to process in a batch in the LFW test set.', default=100)\n    parser.add_argument('model', type=str, \n        help='Could be either a directory containing the meta_file and ckpt_file or a model protobuf (.pb) file')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=160)\n    parser.add_argument('--lfw_pairs', type=str,\n        help='The file containing the pairs to use for validation.', default='data/pairs.txt')\n    parser.add_argument('--lfw_nrof_folds', type=int,\n        help='Number of folds to use for cross validation. Mainly used for testing.', default=10)\n    parser.add_argument('--distance_metric', type=int,\n        help='Distance metric  0:euclidian, 1:cosine similarity.', default=0)\n    parser.add_argument('--use_flipped_images', \n        help='Concatenates embeddings for the image and its horizontally flipped counterpart.', action='store_true')\n    parser.add_argument('--subtract_mean', \n        help='Subtract feature mean before calculating distance.', action='store_true')\n    parser.add_argument('--use_fixed_image_standardization', \n        help='Performs fixed standardization of images.', action='store_true')\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "test/batch_norm_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport unittest\nimport tensorflow as tf\nimport models\nimport numpy as np\nimport numpy.testing as testing\n\nclass BatchNormTest(unittest.TestCase):\n\n\n    @unittest.skip(\"Skip batch norm test case\")\n    def testBatchNorm(self):\n      \n        tf.set_random_seed(123)\n  \n        x = tf.placeholder(tf.float32, [None, 20, 20, 10], name='input')\n        phase_train = tf.placeholder(tf.bool, name='phase_train')\n        \n        # generate random noise to pass into batch norm\n        #x_gen = tf.random_normal([50,20,20,10])\n        \n        bn = models.network.batch_norm(x, phase_train)\n        \n        init = tf.global_variables_initializer()\n        sess = tf.Session(config=tf.ConfigProto())\n        sess.run(init)\n  \n        with sess.as_default():\n        \n            #generate a constant variable to pass into batch norm\n            y = np.random.normal(0, 1, size=(50,20,20,10))\n            \n            feed_dict = {x: y, phase_train: True}\n            sess.run(bn, feed_dict=feed_dict)\n            \n            feed_dict = {x: y, phase_train: False}\n            y1 = sess.run(bn, feed_dict=feed_dict)\n            y2 = sess.run(bn, feed_dict=feed_dict)\n            \n            testing.assert_almost_equal(y1, y2, 10, 'Output from two forward passes with phase_train==false should be equal')\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n    "
  },
  {
    "path": "test/center_loss_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport unittest\nimport tensorflow as tf\nimport numpy as np\nimport facenet\n\nclass CenterLossTest(unittest.TestCase):\n  \n\n\n    def testCenterLoss(self):\n        batch_size = 16\n        nrof_features = 2\n        nrof_classes = 16\n        alfa = 0.5\n        \n        with tf.Graph().as_default():\n        \n            features = tf.placeholder(tf.float32, shape=(batch_size, nrof_features), name='features')\n            labels = tf.placeholder(tf.int32, shape=(batch_size,), name='labels')\n\n            # Define center loss\n            center_loss, centers = facenet.center_loss(features, labels, alfa, nrof_classes)\n            \n            label_to_center = np.array( [ \n                 [-3,-3],  [-3,-1],  [-3,1],  [-3,3],\n                 [-1,-3],  [-1,-1],  [-1,1],  [-1,3],\n                 [ 1,-3],  [ 1,-1],  [ 1,1],  [ 1,3],\n                 [ 3,-3],  [ 3,-1],  [ 3,1],  [ 3,3] \n                 ])\n                \n            sess = tf.Session()\n            with sess.as_default():\n                sess.run(tf.global_variables_initializer())\n                np.random.seed(seed=666)\n                \n                for _ in range(0,100):\n                    # Create array of random labels\n                    lbls = np.random.randint(low=0, high=nrof_classes, size=(batch_size,))\n                    feats = create_features(label_to_center, batch_size, nrof_features, lbls)\n\n                    center_loss_, centers_ = sess.run([center_loss, centers], feed_dict={features:feats, labels:lbls})\n                    \n                # After a large number of updates the estimated centers should be close to the true ones\n                np.testing.assert_almost_equal(centers_, label_to_center, decimal=5, err_msg='Incorrect estimated centers')\n                np.testing.assert_almost_equal(center_loss_, 0.0, decimal=5, err_msg='Incorrect center loss')\n                \n\ndef create_features(label_to_center, batch_size, nrof_features, labels):\n    # Map label to center\n#     label_to_center_dict = { \n#          0:(-3,-3),  1:(-3,-1),  2:(-3,1),  3:(-3,3),\n#          4:(-1,-3),  5:(-1,-1),  6:(-1,1),  7:(-1,3),\n#          8:( 1,-3),  9:( 1,-1), 10:( 1,1), 11:( 1,3),\n#         12:( 3,-3), 13:( 3,-1), 14:( 3,1), 15:( 3,3),\n#         }\n    # Create array of features corresponding to the labels\n    feats = np.zeros((batch_size, nrof_features))\n    for i in range(batch_size):\n        cntr =  label_to_center[labels[i]]\n        for j in range(nrof_features):\n            feats[i,j] = cntr[j]\n    return feats\n                      \nif __name__ == \"__main__\":\n    unittest.main()\n"
  },
  {
    "path": "test/restore_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport unittest\nimport tempfile\nimport os\nimport shutil\nimport tensorflow as tf\nimport numpy as np\n\nclass TrainTest(unittest.TestCase):\n  \n    @classmethod\n    def setUpClass(self):\n        self.tmp_dir = tempfile.mkdtemp()\n        \n    @classmethod\n    def tearDownClass(self):\n        # Recursively remove the temporary directory\n        shutil.rmtree(self.tmp_dir)\n\n    def test_restore_noema(self):\n        \n        # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3\n        x_data = np.random.rand(100).astype(np.float32)\n        y_data = x_data * 0.1 + 0.3\n        \n        # Try to find values for W and b that compute y_data = W * x_data + b\n        # (We know that W should be 0.1 and b 0.3, but TensorFlow will\n        # figure that out for us.)\n        W = tf.Variable(tf.random_uniform([1], -1.0, 1.0), name='W')\n        b = tf.Variable(tf.zeros([1]), name='b')\n        y = W * x_data + b\n        \n        # Minimize the mean squared errors.\n        loss = tf.reduce_mean(tf.square(y - y_data))\n        optimizer = tf.train.GradientDescentOptimizer(0.5)\n        train = optimizer.minimize(loss)\n        \n        # Before starting, initialize the variables.  We will 'run' this first.\n        init = tf.global_variables_initializer()\n\n        saver = tf.train.Saver(tf.trainable_variables())\n        \n        # Launch the graph.\n        sess = tf.Session()\n        sess.run(init)\n        \n        # Fit the line.\n        for _ in range(201):\n            sess.run(train)\n        \n        w_reference = sess.run('W:0')\n        b_reference = sess.run('b:0')\n        \n        saver.save(sess, os.path.join(self.tmp_dir, \"model_ex1\"))\n        \n        tf.reset_default_graph()\n\n        saver = tf.train.import_meta_graph(os.path.join(self.tmp_dir, \"model_ex1.meta\"))\n        sess = tf.Session()\n        saver.restore(sess, os.path.join(self.tmp_dir, \"model_ex1\"))\n        \n        w_restored = sess.run('W:0')\n        b_restored = sess.run('b:0')\n        \n        self.assertAlmostEqual(w_reference, w_restored, 'Restored model use different weight than the original model')\n        self.assertAlmostEqual(b_reference, b_restored, 'Restored model use different weight than the original model')\n\n\n    @unittest.skip(\"Skip restore EMA test case for now\")\n    def test_restore_ema(self):\n        \n        # Create 100 phony x, y data points in NumPy, y = x * 0.1 + 0.3\n        x_data = np.random.rand(100).astype(np.float32)\n        y_data = x_data * 0.1 + 0.3\n        \n        # Try to find values for W and b that compute y_data = W * x_data + b\n        # (We know that W should be 0.1 and b 0.3, but TensorFlow will\n        # figure that out for us.)\n        W = tf.Variable(tf.random_uniform([1], -1.0, 1.0), name='W')\n        b = tf.Variable(tf.zeros([1]), name='b')\n        y = W * x_data + b\n        \n        # Minimize the mean squared errors.\n        loss = tf.reduce_mean(tf.square(y - y_data))\n        optimizer = tf.train.GradientDescentOptimizer(0.5)\n        opt_op = optimizer.minimize(loss)\n\n        # Track the moving averages of all trainable variables.\n        ema = tf.train.ExponentialMovingAverage(decay=0.9999)\n        averages_op = ema.apply(tf.trainable_variables())\n        with tf.control_dependencies([opt_op]):\n            train_op = tf.group(averages_op)\n  \n        # Before starting, initialize the variables.  We will 'run' this first.\n        init = tf.global_variables_initializer()\n\n        saver = tf.train.Saver(tf.trainable_variables())\n        \n        # Launch the graph.\n        sess = tf.Session()\n        sess.run(init)\n        \n        # Fit the line.\n        for _ in range(201):\n            sess.run(train_op)\n        \n        w_reference = sess.run('W/ExponentialMovingAverage:0')\n        b_reference = sess.run('b/ExponentialMovingAverage:0')\n        \n        saver.save(sess, os.path.join(self.tmp_dir, \"model_ex1\"))\n                \n        tf.reset_default_graph()\n\n        tf.train.import_meta_graph(os.path.join(self.tmp_dir, \"model_ex1.meta\"))\n        sess = tf.Session()\n        \n        print('------------------------------------------------------')\n        for var in tf.global_variables():\n            print('all variables: ' + var.op.name)\n        for var in tf.trainable_variables():\n            print('normal variable: ' + var.op.name)\n        for var in tf.moving_average_variables():\n            print('ema variable: ' + var.op.name)\n        print('------------------------------------------------------')\n\n        mode = 1\n        restore_vars = {}\n        if mode == 0:\n            ema = tf.train.ExponentialMovingAverage(1.0)\n            for var in tf.trainable_variables():\n                print('%s: %s' % (ema.average_name(var), var.op.name))\n                restore_vars[ema.average_name(var)] = var\n        elif mode == 1:\n            for var in tf.trainable_variables():\n                ema_name = var.op.name + '/ExponentialMovingAverage'\n                print('%s: %s' % (ema_name, var.op.name))\n                restore_vars[ema_name] = var\n            \n        saver = tf.train.Saver(restore_vars, name='ema_restore')\n        \n        saver.restore(sess, os.path.join(self.tmp_dir, \"model_ex1\"))\n        \n        w_restored = sess.run('W:0')\n        b_restored = sess.run('b:0')\n        \n        self.assertAlmostEqual(w_reference, w_restored, 'Restored model modes not use the EMA filtered weight')\n        self.assertAlmostEqual(b_reference, b_restored, 'Restored model modes not use the EMA filtered bias')\n\n        \n# Create a checkpoint file pointing to the model\ndef create_checkpoint_file(model_dir, model_file):\n    checkpoint_filename = os.path.join(model_dir, 'checkpoint')\n    full_model_filename = os.path.join(model_dir, model_file)\n    with open(checkpoint_filename, 'w') as f:\n        f.write('model_checkpoint_path: \"%s\"\\n' % full_model_filename)\n        f.write('all_model_checkpoint_paths: \"%s\"\\n' % full_model_filename)\n        \nif __name__ == \"__main__\":\n    unittest.main()\n    "
  },
  {
    "path": "test/train_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport unittest\nimport tempfile\nimport numpy as np\nimport cv2\nimport os\nimport shutil\nimport download_and_extract  # @UnresolvedImport\nimport subprocess\n\ndef memory_usage_psutil():\n    # return the memory usage in MB\n    import psutil\n    process = psutil.Process(os.getpid())\n    mem = process.memory_info()[0] / float(2 ** 20)\n    return mem\n\ndef align_dataset_if_needed(self):\n    if not os.path.exists('data/lfw_aligned'):\n        argv = ['python',\n                'src/align/align_dataset_mtcnn.py',\n                'data/lfw',\n                'data/lfw_aligned',\n                '--image_size', '160',\n                '--margin', '32' ]\n        subprocess.call(argv)\n        \n        \nclass TrainTest(unittest.TestCase):\n  \n    @classmethod\n    def setUpClass(self):\n        self.tmp_dir = tempfile.mkdtemp()\n        self.dataset_dir = os.path.join(self.tmp_dir, 'dataset')\n        create_mock_dataset(self.dataset_dir, 160)\n        self.lfw_pairs_file = create_mock_lfw_pairs(self.tmp_dir)\n        print(self.lfw_pairs_file)\n        self.pretrained_model_name = '20180402-114759'\n        download_and_extract.download_and_extract_file(self.pretrained_model_name, 'data/')\n        download_and_extract.download_and_extract_file('lfw-subset', 'data/')\n        self.model_file = os.path.join('data', self.pretrained_model_name, 'model-%s.ckpt-275' % self.pretrained_model_name)\n        self.pretrained_model = os.path.join('data', self.pretrained_model_name)\n        self.frozen_graph_filename = os.path.join('data', self.pretrained_model_name+'.pb')\n        print('Memory utilization (SetUpClass): %.3f MB' % memory_usage_psutil())\n\n    @classmethod\n    def tearDownClass(self):\n        # Recursively remove the temporary directory\n        shutil.rmtree(self.tmp_dir)\n\n    def tearDown(self):\n        print('Memory utilization (TearDown): %.3f MB' % memory_usage_psutil())\n\n    def test_training_classifier_inception_resnet_v1(self):\n        print('test_training_classifier_inception_resnet_v1')\n        argv = ['python',\n                'src/train_softmax.py',\n                '--logs_base_dir', self.tmp_dir,\n                '--models_base_dir', self.tmp_dir,\n                '--data_dir', self.dataset_dir,\n                '--model_def', 'models.inception_resnet_v1',\n                '--epoch_size', '1',\n                '--max_nrof_epochs', '1',\n                '--batch_size', '1',\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_dir', self.dataset_dir,\n                '--lfw_nrof_folds', '2',\n                '--lfw_batch_size', '1',\n                '--nrof_preprocess_threads', '1' ]\n        subprocess.call(argv)\n\n    def test_training_classifier_inception_resnet_v2(self):\n        print('test_training_classifier_inception_resnet_v2')\n        argv = ['python',\n                'src/train_softmax.py',\n                '--logs_base_dir', self.tmp_dir,\n                '--models_base_dir', self.tmp_dir,\n                '--data_dir', self.dataset_dir,\n                '--model_def', 'models.inception_resnet_v2',\n                '--epoch_size', '1',\n                '--max_nrof_epochs', '1',\n                '--batch_size', '1',\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_dir', self.dataset_dir,\n                '--lfw_nrof_folds', '2',\n                '--lfw_batch_size', '1' ]\n        subprocess.call(argv)\n  \n    def test_training_classifier_squeezenet(self):\n        print('test_training_classifier_squeezenet')\n        argv = ['python',\n                'src/train_softmax.py',\n                '--logs_base_dir', self.tmp_dir,\n                '--models_base_dir', self.tmp_dir,\n                '--data_dir', self.dataset_dir,\n                '--model_def', 'models.squeezenet',\n                '--epoch_size', '1',\n                '--max_nrof_epochs', '1',\n                '--batch_size', '1',\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_dir', self.dataset_dir,\n                '--lfw_nrof_folds', '2',\n                '--lfw_batch_size', '1',\n                '--nrof_preprocess_threads', '1' ]\n        subprocess.call(argv)\n \n    def test_train_tripletloss_inception_resnet_v1(self):\n        print('test_train_tripletloss_inception_resnet_v1')\n        argv = ['python',\n                'src/train_tripletloss.py',\n                '--logs_base_dir', self.tmp_dir,\n                '--models_base_dir', self.tmp_dir,\n                '--data_dir', self.dataset_dir,\n                '--model_def', 'models.inception_resnet_v1',\n                '--epoch_size', '1',\n                '--max_nrof_epochs', '1',\n                '--batch_size', '6',\n                '--people_per_batch', '2',\n                '--images_per_person', '3',\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_dir', self.dataset_dir,\n                '--lfw_nrof_folds', '2' ]\n        subprocess.call(argv)\n  \n    def test_finetune_tripletloss_inception_resnet_v1(self):\n        print('test_finetune_tripletloss_inception_resnet_v1')\n        argv = ['python',\n                'src/train_tripletloss.py',\n                '--logs_base_dir', self.tmp_dir,\n                '--models_base_dir', self.tmp_dir,\n                '--data_dir', self.dataset_dir,\n                '--model_def', 'models.inception_resnet_v1',\n                '--pretrained_model', self.model_file,\n                '--embedding_size', '512',\n                '--epoch_size', '1',\n                '--max_nrof_epochs', '1',\n                '--batch_size', '6',\n                '--people_per_batch', '2',\n                '--images_per_person', '3',\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_dir', self.dataset_dir,\n                '--lfw_nrof_folds', '2' ]\n        subprocess.call(argv)\n  \n    def test_compare(self):\n        print('test_compare')\n        argv = ['python',\n                'src/compare.py',\n                os.path.join('data/', self.pretrained_model_name),\n                'data/images/Anthony_Hopkins_0001.jpg',\n                'data/images/Anthony_Hopkins_0002.jpg' ]\n        subprocess.call(argv)\n         \n    def test_validate_on_lfw(self):\n        print('test_validate_on_lfw')\n        align_dataset_if_needed(self)\n        argv = ['python',\n                'src/validate_on_lfw.py', \n                'data/lfw_aligned',\n                self.pretrained_model,\n                '--lfw_pairs', 'data/lfw/pairs_small.txt',\n                '--lfw_nrof_folds', '2',\n                '--lfw_batch_size', '6']\n        subprocess.call(argv)\n \n    def test_validate_on_lfw_frozen_graph(self):\n        print('test_validate_on_lfw_frozen_graph')\n        self.pretrained_model = os.path.join('data', self.pretrained_model_name)\n        frozen_model = os.path.join(self.pretrained_model, self.pretrained_model_name+'.pb')\n        argv = ['python',\n                'src/validate_on_lfw.py',\n                self.dataset_dir,\n                frozen_model,\n                '--lfw_pairs', self.lfw_pairs_file,\n                '--lfw_nrof_folds', '2',\n                '--lfw_batch_size', '6']\n        subprocess.call(argv)\n \n    def test_freeze_graph(self):\n        print('test_freeze_graph')\n        argv = ['python',\n                'src/freeze_graph.py',\n                self.pretrained_model,\n                self.frozen_graph_filename ]\n        subprocess.call(argv)\n\n# Create a mock dataset with random pixel images\ndef create_mock_dataset(dataset_dir, image_size):\n   \n    nrof_persons = 3\n    nrof_images_per_person = 2\n    np.random.seed(seed=666)\n    os.mkdir(dataset_dir)\n    for i in range(nrof_persons):\n        class_name = '%04d' % (i+1)\n        class_dir = os.path.join(dataset_dir, class_name)\n        os.mkdir(class_dir)\n        for j in range(nrof_images_per_person):\n            img_name = '%04d' % (j+1)\n            img_path = os.path.join(class_dir, class_name+'_'+img_name + '.png')\n            img = np.random.uniform(low=0.0, high=255.0, size=(image_size,image_size,3))\n            cv2.imwrite(img_path, img) #@UndefinedVariable\n\n# Create a mock LFW pairs file\ndef create_mock_lfw_pairs(tmp_dir):\n    pairs_filename = os.path.join(tmp_dir, 'pairs_mock.txt')\n    with open(pairs_filename, 'w') as f:\n        f.write('10 300\\n')\n        f.write('0001 1 2\\n')\n        f.write('0001 1 0002 1\\n')\n        f.write('0002 1 0003 1\\n')\n        f.write('0001 1 0003 1\\n')\n        f.write('0002 1 2\\n')\n        f.write('0001 2 0002 2\\n')\n        f.write('0002 2 0003 2\\n')\n        f.write('0001 2 0003 2\\n')\n        f.write('0003 1 2\\n')\n        f.write('0001 1 0002 2\\n')\n        f.write('0002 1 0003 2\\n')\n        f.write('0001 1 0003 2\\n')\n    return pairs_filename\n\nif __name__ == \"__main__\":\n    unittest.main()\n    "
  },
  {
    "path": "test/triplet_loss_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nimport unittest\nimport tensorflow as tf\nimport numpy as np\nimport facenet\n\nclass DemuxEmbeddingsTest(unittest.TestCase):\n  \n    def testDemuxEmbeddings(self):\n        batch_size = 3*12\n        embedding_size = 16\n        alpha = 0.2\n        \n        with tf.Graph().as_default():\n        \n            embeddings = tf.placeholder(tf.float64, shape=(batch_size, embedding_size), name='embeddings')\n            anchor, positive, negative = tf.unstack(tf.reshape(embeddings, [-1,3,embedding_size]), 3, 1)\n            triplet_loss = facenet.triplet_loss(anchor, positive, negative, alpha)\n                \n            sess = tf.Session()\n            with sess.as_default():\n                np.random.seed(seed=666)\n                emb = np.random.uniform(size=(batch_size, embedding_size))\n                tf_triplet_loss = sess.run(triplet_loss, feed_dict={embeddings:emb})\n\n                pos_dist_sqr = np.sum(np.square(emb[0::3,:]-emb[1::3,:]),1)\n                neg_dist_sqr = np.sum(np.square(emb[0::3,:]-emb[2::3,:]),1)\n                np_triplet_loss = np.mean(np.maximum(0.0, pos_dist_sqr - neg_dist_sqr + alpha))\n                \n                np.testing.assert_almost_equal(tf_triplet_loss, np_triplet_loss, decimal=5, err_msg='Triplet loss is incorrect')\n                      \nif __name__ == \"__main__\":\n    unittest.main()\n"
  },
  {
    "path": "tmp/__init__.py",
    "content": "# flake8: noqa\n\n"
  },
  {
    "path": "tmp/align_dataset.m",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n% LFW\n% source_path = '/home/david/datasets/lfw/raw';\n% target_path = '/home/david/datasets/lfw/lfw_mtcnnalign_160';\n% image_size = 160 + 0;\n% margin = round(image_size*0.2) + 0;\n\n% FaceScrub\n% source_path = '/home/david/datasets/facescrub/facescrub/';\n% target_path = '/home/david/datasets/facescrub/facescrub_mtcnnalign_182_160';\n% failed_images_list = '/home/david/datasets/facescrub/facescrub_mtcnnalign_182_160/failed_images.txt';\n% image_size = 160 + 12;\n% margin = round(image_size*0.2) + 12;\n\nsource_path = '/home/david/datasets/casia/CASIA-maxpy-clean/';\ntarget_path = '/home/david/datasets/casia/casia_maxpy_mtcnnalign_182_160';\nfailed_images_list = '/home/david/datasets/casia/casia_maxpy_mtcnnalign_182_160/failed_images.txt';\nimage_size = 160 + 12;\nmargin = round(image_size*0.2) + 12;\n\nimage_extension = 'png';\nminsize=20; %minimum size of face\nuse_new = 0;\n\ncaffe_path='/home/david/repo2/caffe/matlab';\npdollar_toolbox_path='/home/david/repo2/toolbox';\nif use_new\n    caffe_model_path='/home/david/repo2/MTCNN_face_detection_alignment/code/codes/MTCNNv2/model';\nelse\n    caffe_model_path='/home/david/repo2/MTCNN_face_detection_alignment/code/codes/MTCNNv1/model';\nend;\naddpath(genpath(caffe_path));\naddpath(genpath(pdollar_toolbox_path));\n\ncaffe.set_mode_gpu();\ncaffe.set_device(0);\n\n%three steps's threshold\nthreshold=[0.6 0.7 0.7];\n\n%scale factor\nfactor=0.709;\n\n%load caffe models\nif use_new\n    prototxt_dir =  strcat(caffe_model_path,'/det4.prototxt');\n    model_dir =  strcat(caffe_model_path,'/det4.caffemodel');\nend;\n%faces=cell(0);\n\nk = 0;\nclasses = dir(source_path);\n%classes = classes(randperm(length(classes)));\nfor i=1:length(classes),\n    if classes(i).name(1)~='.'\n        source_class_path = sprintf('%s/%s', source_path, classes(i).name);\n        target_class_path = sprintf('%s/%s', target_path, classes(i).name);\n        imgs = dir(source_class_path);\n        %imgs = imgs(randperm(length(imgs)));\n        if ~exist(target_class_path, 'dir'),\n            mkdir(target_class_path);\n        end;\n        for j=1:length(imgs),\n            if imgs(j).isdir==0\n                [pathstr,name,ext] = fileparts(imgs(j).name);\n                target_img_path = sprintf('%s/%s.%s', target_class_path, name, image_extension);\n                if ~exist(target_img_path,'file') && any([ strcmpi(ext,'.jpg') strcmpi(ext,'.jpeg') strcmpi(ext,'.png') strcmpi(ext,'.gif') ])\n                    if mod(k,1000)==0\n                        fprintf('Resetting GPU\\n');\n                        caffe.reset_all();\n                        caffe.set_mode_gpu();\n                        caffe.set_device(0);\n                        prototxt_dir = strcat(caffe_model_path,'/det1.prototxt');\n                        model_dir = strcat(caffe_model_path,'/det1.caffemodel');\n                        PNet=caffe.Net(prototxt_dir,model_dir,'test');\n                        prototxt_dir = strcat(caffe_model_path,'/det2.prototxt');\n                        model_dir = strcat(caffe_model_path,'/det2.caffemodel');\n                        RNet=caffe.Net(prototxt_dir,model_dir,'test');\n                        prototxt_dir = strcat(caffe_model_path,'/det3.prototxt');\n                        model_dir = strcat(caffe_model_path,'/det3.caffemodel');\n                        ONet=caffe.Net(prototxt_dir,model_dir,'test');\n                        if use_new\n                            prototxt_dir = strcat(caffe_model_path,'/det4.prototxt');\n                            model_dir = strcat(caffe_model_path,'/det4.caffemodel');\n                            LNet=caffe.Net(prototxt_dir,model_dir,'test');\n                        end;\n                    end;\n                        \n                    source_img_path = sprintf('%s/%s', source_class_path, imgs(j).name);\n                    % source_img_path = '/home/david/datasets/facescrub/facescrub//Billy_Zane/095f83fefdf1dc493c013edb1ef860001193e8d9.jpg'\n                    try\n                        img = imread(source_img_path);\n                    catch exception\n                        fprintf('Unexpected error (%s): %s\\n', exception.identifier, exception.message);\n                        continue;\n                    end;\n                    fprintf('%6d: %s\\n', k, source_img_path);\n                    if length(size(img))<3\n                        img = repmat(img,[1,1,3]);\n                    end;\n                    img_size = size(img); % [height, width, channels]\n                    img_size = fliplr(img_size(1:2));  % [x,y]\n                    if use_new\n                        [boundingboxes, points]=detect_face_v2(img,minsize,PNet,RNet,ONet,LNet,threshold,false,factor);\n                    else\n                        [boundingboxes, points]=detect_face_v1(img,minsize,PNet,RNet,ONet,threshold,false,factor);\n                    end;\n                    nrof_faces = size(boundingboxes,1);\n                    det = boundingboxes;\n                    if nrof_faces>0\n                        if nrof_faces>1\n                            % select the faces with the largest bounding box\n                            %  closest to the image center\n                            bounding_box_size = (det(:,3)-det(:,1)).*(det(:,4)-det(:,2));\n                            img_center = img_size / 2;\n                            offsets = [ (det(:,1)+det(:,3))/2 (det(:,2)+det(:,4))/2 ] - ones(nrof_faces,1)*img_center;\n                            offset_dist_squared = sum(offsets.^2,2);\n                            [a, index] = max(bounding_box_size-offset_dist_squared*2.0); % some extra weight on the centering\n                            det = det(index,:);\n                            points = points(:,index);\n                        end;\n%                         if nrof_faces>0\n%                             figure(1); clf;\n%                             imshow(img);\n%                             hold on;\n%                             plot(points(1:5,1),points(6:10,1),'g.','MarkerSize',10);\n%                             bb = round(det(1:4));\n%                             rectangle('Position',[bb(1) bb(2) bb(3)-bb(1) bb(4)-bb(2)],'LineWidth',2,'LineStyle','-')\n%                             xxx = 1;\n%                         end;\n                        det(1) = max(det(1)-margin/2, 1);\n                        det(2) = max(det(2)-margin/2, 1);\n                        det(3) = min(det(3)+margin/2, img_size(1));\n                        det(4) = min(det(4)+margin/2, img_size(2));\n                        det(1:4) = round(det(1:4));\n                        \n                        img = img(det(2):det(4),det(1):det(3),:);\n                        img = imresize(img, [image_size, image_size]);\n                        \n                        imwrite(img, target_img_path);\n                        k = k + 1;\n                    else\n                        fprintf('Detection failed: %s\\n', source_img_path);\n                        fid = fopen(failed_images_list,'at');\n                        if fid>=0\n                            fprintf(fid, '%s\\n', source_img_path);\n                            fclose(fid);\n                        end;\n                    end;\n                    if mod(k,100)==0\n                        xxx = 1;\n                    end;\n                end;\n            end;\n        end;\n    end;\nend;\n"
  },
  {
    "path": "tmp/align_dataset.py",
    "content": "\"\"\"Performs face alignment and stores face thumbnails in the output directory.\"\"\"\n\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport sys\nimport os\nimport argparse\nimport random\nimport align_dlib  # @UnresolvedImport\nimport facenet\n\ndef main(args):\n    align = align_dlib.AlignDlib(os.path.expanduser(args.dlib_face_predictor))\n    landmarkIndices = align_dlib.AlignDlib.OUTER_EYES_AND_NOSE\n    output_dir = os.path.expanduser(args.output_dir)\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n    # Store some git revision info in a text file in the log directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))\n    dataset = facenet.get_dataset(args.input_dir)\n    random.shuffle(dataset)\n    # Scale the image such that the face fills the frame when cropped to crop_size\n    scale = float(args.face_size) / args.image_size\n    nrof_images_total = 0\n    nrof_prealigned_images = 0\n    nrof_successfully_aligned = 0\n    for cls in dataset:\n        output_class_dir = os.path.join(output_dir, cls.name)\n        if not os.path.exists(output_class_dir):\n            os.makedirs(output_class_dir)\n        random.shuffle(cls.image_paths)\n        for image_path in cls.image_paths:\n            nrof_images_total += 1\n            filename = os.path.splitext(os.path.split(image_path)[1])[0]\n            output_filename = os.path.join(output_class_dir, filename+'.png')\n            if not os.path.exists(output_filename):\n                try:\n                    img = misc.imread(image_path)\n                except (IOError, ValueError, IndexError) as e:\n                    errorMessage = '{}: {}'.format(image_path, e)\n                    print(errorMessage)\n                else:\n                    if img.ndim == 2:\n                        img = facenet.to_rgb(img)\n                    if args.use_center_crop:\n                        scaled = misc.imresize(img, args.prealigned_scale, interp='bilinear')\n                        sz1 = scaled.shape[1]/2\n                        sz2 = args.image_size/2\n                        aligned = scaled[(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]\n                    else:\n                        aligned = align.align(args.image_size, img, landmarkIndices=landmarkIndices, \n                                              skipMulti=False, scale=scale)\n                    if aligned is not None:\n                        print(image_path)\n                        nrof_successfully_aligned += 1\n                        misc.imsave(output_filename, aligned)\n                    elif args.prealigned_dir:\n                        # Face detection failed. Use center crop from pre-aligned dataset\n                        class_name = os.path.split(output_class_dir)[1]\n                        image_path_without_ext = os.path.join(os.path.expanduser(args.prealigned_dir), \n                                                              class_name, filename)\n                        # Find the extension of the image\n                        exts = ('jpg', 'png')\n                        for ext in exts:\n                            temp_path = image_path_without_ext + '.' + ext\n                            image_path = ''\n                            if os.path.exists(temp_path):\n                                image_path = temp_path\n                                break\n                        try:\n                            img = misc.imread(image_path)\n                        except (IOError, ValueError, IndexError) as e:\n                            errorMessage = '{}: {}'.format(image_path, e)\n                            print(errorMessage)\n                        else:\n                            scaled = misc.imresize(img, args.prealigned_scale, interp='bilinear')\n                            sz1 = scaled.shape[1]/2\n                            sz2 = args.image_size/2\n                            cropped = scaled[(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]\n                            print(image_path)\n                            nrof_prealigned_images += 1\n                            misc.imsave(output_filename, cropped)\n                    else:\n                        print('Unable to align \"%s\"' % image_path)\n                            \n    print('Total number of images: %d' % nrof_images_total)\n    print('Number of successfully aligned images: %d' % nrof_successfully_aligned)\n    print('Number of pre-aligned images: %d' % nrof_prealigned_images)\n            \n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('input_dir', type=str, help='Directory with unaligned images.')\n    parser.add_argument('output_dir', type=str, help='Directory with aligned face thumbnails.')\n    parser.add_argument('--dlib_face_predictor', type=str,\n        help='File containing the dlib face predictor.', default='../data/shape_predictor_68_face_landmarks.dat')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=110)\n    parser.add_argument('--face_size', type=int,\n        help='Size of the face thumbnail (height, width) in pixels.', default=96)\n    parser.add_argument('--use_center_crop', \n        help='Use the center crop of the original image after scaling the image using prealigned_scale.', action='store_true')\n    parser.add_argument('--prealigned_dir', type=str,\n        help='Replace image with a pre-aligned version when face detection fails.', default='')\n    parser.add_argument('--prealigned_scale', type=float,\n        help='The amount of scaling to apply to prealigned images before taking the center crop.', default=0.87)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/align_dlib.py",
    "content": "# Copyright 2015-2016 Carnegie Mellon University\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Module for dlib-based alignment.\"\"\"\n\n# NOTE: This file has been copied from the openface project.\n#  https://github.com/cmusatyalab/openface/blob/master/openface/align_dlib.py\n\nimport cv2\nimport dlib\nimport numpy as np\n\nTEMPLATE = np.float32([\n    (0.0792396913815, 0.339223741112), (0.0829219487236, 0.456955367943),\n    (0.0967927109165, 0.575648016728), (0.122141515615, 0.691921601066),\n    (0.168687863544, 0.800341263616), (0.239789390707, 0.895732504778),\n    (0.325662452515, 0.977068762493), (0.422318282013, 1.04329000149),\n    (0.531777802068, 1.06080371126), (0.641296298053, 1.03981924107),\n    (0.738105872266, 0.972268833998), (0.824444363295, 0.889624082279),\n    (0.894792677532, 0.792494155836), (0.939395486253, 0.681546643421),\n    (0.96111933829, 0.562238253072), (0.970579841181, 0.441758925744),\n    (0.971193274221, 0.322118743967), (0.163846223133, 0.249151738053),\n    (0.21780354657, 0.204255863861), (0.291299351124, 0.192367318323),\n    (0.367460241458, 0.203582210627), (0.4392945113, 0.233135599851),\n    (0.586445962425, 0.228141644834), (0.660152671635, 0.195923841854),\n    (0.737466449096, 0.182360984545), (0.813236546239, 0.192828009114),\n    (0.8707571886, 0.235293377042), (0.51534533827, 0.31863546193),\n    (0.516221448289, 0.396200446263), (0.517118861835, 0.473797687758),\n    (0.51816430343, 0.553157797772), (0.433701156035, 0.604054457668),\n    (0.475501237769, 0.62076344024), (0.520712933176, 0.634268222208),\n    (0.565874114041, 0.618796581487), (0.607054002672, 0.60157671656),\n    (0.252418718401, 0.331052263829), (0.298663015648, 0.302646354002),\n    (0.355749724218, 0.303020650651), (0.403718978315, 0.33867711083),\n    (0.352507175597, 0.349987615384), (0.296791759886, 0.350478978225),\n    (0.631326076346, 0.334136672344), (0.679073381078, 0.29645404267),\n    (0.73597236153, 0.294721285802), (0.782865376271, 0.321305281656),\n    (0.740312274764, 0.341849376713), (0.68499850091, 0.343734332172),\n    (0.353167761422, 0.746189164237), (0.414587777921, 0.719053835073),\n    (0.477677654595, 0.706835892494), (0.522732900812, 0.717092275768),\n    (0.569832064287, 0.705414478982), (0.635195811927, 0.71565572516),\n    (0.69951672331, 0.739419187253), (0.639447159575, 0.805236879972),\n    (0.576410514055, 0.835436670169), (0.525398405766, 0.841706377792),\n    (0.47641545769, 0.837505914975), (0.41379548902, 0.810045601727),\n    (0.380084785646, 0.749979603086), (0.477955996282, 0.74513234612),\n    (0.523389793327, 0.748924302636), (0.571057789237, 0.74332894691),\n    (0.672409137852, 0.744177032192), (0.572539621444, 0.776609286626),\n    (0.5240106503, 0.783370783245), (0.477561227414, 0.778476346951)])\n\nINV_TEMPLATE = np.float32([\n                            (-0.04099179660567834, -0.008425234314031194, 2.575498465013183),\n                            (0.04062510634554352, -0.009678089746831375, -1.2534351452524177),\n                            (0.0003666902601348179, 0.01810332406086298, -0.32206331976076663)])\n\nTPL_MIN, TPL_MAX = np.min(TEMPLATE, axis=0), np.max(TEMPLATE, axis=0)\nMINMAX_TEMPLATE = (TEMPLATE - TPL_MIN) / (TPL_MAX - TPL_MIN)\n\n\nclass AlignDlib:\n    \"\"\"\n    Use `dlib's landmark estimation <http://blog.dlib.net/2014/08/real-time-face-pose-estimation.html>`_ to align faces.\n\n    The alignment preprocess faces for input into a neural network.\n    Faces are resized to the same size (such as 96x96) and transformed\n    to make landmarks (such as the eyes and nose) appear at the same\n    location on every image.\n\n    Normalized landmarks:\n\n    .. image:: ../images/dlib-landmark-mean.png\n    \"\"\"\n\n    #: Landmark indices corresponding to the inner eyes and bottom lip.\n    INNER_EYES_AND_BOTTOM_LIP = [39, 42, 57]\n\n    #: Landmark indices corresponding to the outer eyes and nose.\n    OUTER_EYES_AND_NOSE = [36, 45, 33]\n\n    def __init__(self, facePredictor):\n        \"\"\"\n        Instantiate an 'AlignDlib' object.\n\n        :param facePredictor: The path to dlib's\n        :type facePredictor: str\n        \"\"\"\n        assert facePredictor is not None\n\n        #pylint: disable=no-member\n        self.detector = dlib.get_frontal_face_detector()\n        self.predictor = dlib.shape_predictor(facePredictor)\n\n    def getAllFaceBoundingBoxes(self, rgbImg):\n        \"\"\"\n        Find all face bounding boxes in an image.\n\n        :param rgbImg: RGB image to process. Shape: (height, width, 3)\n        :type rgbImg: numpy.ndarray\n        :return: All face bounding boxes in an image.\n        :rtype: dlib.rectangles\n        \"\"\"\n        assert rgbImg is not None\n\n        try:\n            return self.detector(rgbImg, 1)\n        except Exception as e: #pylint: disable=broad-except\n            print(\"Warning: {}\".format(e))\n            # In rare cases, exceptions are thrown.\n            return []\n\n    def getLargestFaceBoundingBox(self, rgbImg, skipMulti=False):\n        \"\"\"\n        Find the largest face bounding box in an image.\n\n        :param rgbImg: RGB image to process. Shape: (height, width, 3)\n        :type rgbImg: numpy.ndarray\n        :param skipMulti: Skip image if more than one face detected.\n        :type skipMulti: bool\n        :return: The largest face bounding box in an image, or None.\n        :rtype: dlib.rectangle\n        \"\"\"\n        assert rgbImg is not None\n\n        faces = self.getAllFaceBoundingBoxes(rgbImg)\n        if (not skipMulti and len(faces) > 0) or len(faces) == 1:\n            return max(faces, key=lambda rect: rect.width() * rect.height())\n        else:\n            return None\n\n    def findLandmarks(self, rgbImg, bb):\n        \"\"\"\n        Find the landmarks of a face.\n\n        :param rgbImg: RGB image to process. Shape: (height, width, 3)\n        :type rgbImg: numpy.ndarray\n        :param bb: Bounding box around the face to find landmarks for.\n        :type bb: dlib.rectangle\n        :return: Detected landmark locations.\n        :rtype: list of (x,y) tuples\n        \"\"\"\n        assert rgbImg is not None\n        assert bb is not None\n\n        points = self.predictor(rgbImg, bb)\n        #return list(map(lambda p: (p.x, p.y), points.parts()))\n        return [(p.x, p.y) for p in points.parts()]\n\n    #pylint: disable=dangerous-default-value\n    def align(self, imgDim, rgbImg, bb=None,\n              landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP,\n              skipMulti=False, scale=1.0):\n        r\"\"\"align(imgDim, rgbImg, bb=None, landmarks=None, landmarkIndices=INNER_EYES_AND_BOTTOM_LIP)\n\n        Transform and align a face in an image.\n\n        :param imgDim: The edge length in pixels of the square the image is resized to.\n        :type imgDim: int\n        :param rgbImg: RGB image to process. Shape: (height, width, 3)\n        :type rgbImg: numpy.ndarray\n        :param bb: Bounding box around the face to align. \\\n                   Defaults to the largest face.\n        :type bb: dlib.rectangle\n        :param landmarks: Detected landmark locations. \\\n                          Landmarks found on `bb` if not provided.\n        :type landmarks: list of (x,y) tuples\n        :param landmarkIndices: The indices to transform to.\n        :type landmarkIndices: list of ints\n        :param skipMulti: Skip image if more than one face detected.\n        :type skipMulti: bool\n        :param scale: Scale image before cropping to the size given by imgDim.\n        :type scale: float\n        :return: The aligned RGB image. Shape: (imgDim, imgDim, 3)\n        :rtype: numpy.ndarray\n        \"\"\"\n        assert imgDim is not None\n        assert rgbImg is not None\n        assert landmarkIndices is not None\n\n        if bb is None:\n            bb = self.getLargestFaceBoundingBox(rgbImg, skipMulti)\n            if bb is None:\n                return\n\n        if landmarks is None:\n            landmarks = self.findLandmarks(rgbImg, bb)\n\n        npLandmarks = np.float32(landmarks)\n        npLandmarkIndices = np.array(landmarkIndices)\n\n        #pylint: disable=maybe-no-member\n        H = cv2.getAffineTransform(npLandmarks[npLandmarkIndices],\n                                   imgDim * MINMAX_TEMPLATE[npLandmarkIndices]*scale + imgDim*(1-scale)/2)\n        thumbnail = cv2.warpAffine(rgbImg, H, (imgDim, imgDim))\n        \n        return thumbnail\n"
  },
  {
    "path": "tmp/cacd2000_split_identities.py",
    "content": "import shutil\nimport argparse\nimport os\nimport sys\n\ndef main(args):\n    src_path_exp = os.path.expanduser(args.src_path)\n    dst_path_exp = os.path.expanduser(args.dst_path)\n    if not os.path.exists(dst_path_exp):\n        os.makedirs(dst_path_exp)\n    files = os.listdir(src_path_exp)\n    for f in files:\n        file_name = '.'.join(f.split('.')[0:-1])\n        x = file_name.split('_')\n        dir_name = '_'.join(x[1:-1])\n        class_dst_path = os.path.join(dst_path_exp, dir_name)\n        if not os.path.exists(class_dst_path):\n            os.makedirs(class_dst_path)\n        src_file_path = os.path.join(src_path_exp, f)\n        dst_file = os.path.join(class_dst_path, f)\n        print('%s -> %s' % (src_file_path, dst_file))\n        shutil.copyfile(src_file_path, dst_file)\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('src_path', type=str, help='Path to the source directory.')\n    parser.add_argument('dst_path', type=str, help='Path to the destination directory.')\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/dataset_read_speed.py",
    "content": "import facenet\nimport argparse\nimport sys\nimport time\nimport numpy as np\n\ndef main(args):\n\n    dataset = facenet.get_dataset(args.dir)\n    paths, _ = facenet.get_image_paths_and_labels(dataset)\n    t = np.zeros((len(paths)))\n    x = time.time()\n    for i, path in enumerate(paths):\n        start_time = time.time()\n        with open(path, mode='rb') as f:\n            _ = f.read()\n        duration = time.time() - start_time\n        t[i] = duration\n        if i % 1000 == 0 or i==len(paths)-1:\n            print('File %d/%d  Total time: %.2f  Avg: %.3f  Std: %.3f' % (i, len(paths), time.time()-x, np.mean(t[0:i])*1000, np.std(t[0:i])*1000))\n\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    parser.add_argument('dir', type=str, \n        help='Directory with dataset to test')\n    return parser.parse_args(argv)\n\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/deepdream.py",
    "content": "# boilerplate code\nimport numpy as np\nfrom functools import partial\nimport PIL.Image\n\nimport tensorflow as tf\nimport matplotlib.pyplot as plt\nimport urllib2\nimport os\nimport zipfile\n\ndef main():\n    # download pre-trained model by running the command below in a shell\n    #  wget https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip && unzip inception5h.zip\n    url = 'https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip'\n    data_dir = '../data/'\n    model_name = os.path.split(url)[-1]\n    local_zip_file = os.path.join(data_dir, model_name)\n    if not os.path.exists(local_zip_file):\n        # Download\n        model_url = urllib2.urlopen(url)\n        with open(local_zip_file, 'wb') as output:\n            output.write(model_url.read())\n        # Extract\n        with zipfile.ZipFile(local_zip_file, 'r') as zip_ref:\n            zip_ref.extractall(data_dir)\n  \n    # start with a gray image with a little noise\n    img_noise = np.random.uniform(size=(224,224,3)) + 100.0\n  \n    model_fn = 'tensorflow_inception_graph.pb'\n    \n    # creating TensorFlow session and loading the model\n    graph = tf.Graph()\n    sess = tf.InteractiveSession(graph=graph)\n    with tf.gfile.FastGFile(os.path.join(data_dir, model_fn), 'rb') as f:\n        graph_def = tf.GraphDef()\n        graph_def.ParseFromString(f.read())\n    t_input = tf.placeholder(np.float32, name='input') # define the input tensor\n    imagenet_mean = 117.0\n    t_preprocessed = tf.expand_dims(t_input-imagenet_mean, 0)\n    tf.import_graph_def(graph_def, {'input':t_preprocessed})\n    \n    layers = [op.name for op in graph.get_operations() if op.type=='Conv2D' and 'import/' in op.name]\n    feature_nums = [int(graph.get_tensor_by_name(name+':0').get_shape()[-1]) for name in layers]\n    \n    print('Number of layers', len(layers))\n    print('Total number of feature channels:', sum(feature_nums))\n  \n  \n    # Helper functions for TF Graph visualization\n    #pylint: disable=unused-variable\n    def strip_consts(graph_def, max_const_size=32):\n        \"\"\"Strip large constant values from graph_def.\"\"\"\n        strip_def = tf.GraphDef()\n        for n0 in graph_def.node:\n            n = strip_def.node.add() #pylint: disable=maybe-no-member\n            n.MergeFrom(n0)\n            if n.op == 'Const':\n                tensor = n.attr['value'].tensor\n                size = len(tensor.tensor_content)\n                if size > max_const_size:\n                    tensor.tensor_content = \"<stripped %d bytes>\"%size\n        return strip_def\n      \n    def rename_nodes(graph_def, rename_func):\n        res_def = tf.GraphDef()\n        for n0 in graph_def.node:\n            n = res_def.node.add() #pylint: disable=maybe-no-member\n            n.MergeFrom(n0)\n            n.name = rename_func(n.name)\n            for i, s in enumerate(n.input):\n                n.input[i] = rename_func(s) if s[0]!='^' else '^'+rename_func(s[1:])\n        return res_def\n      \n    def showarray(a):\n        a = np.uint8(np.clip(a, 0, 1)*255)\n        plt.imshow(a)\n        plt.show()\n        \n    def visstd(a, s=0.1):\n        '''Normalize the image range for visualization'''\n        return (a-a.mean())/max(a.std(), 1e-4)*s + 0.5\n    \n    def T(layer):\n        '''Helper for getting layer output tensor'''\n        return graph.get_tensor_by_name(\"import/%s:0\"%layer)\n    \n    def render_naive(t_obj, img0=img_noise, iter_n=20, step=1.0):\n        t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n        t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n        \n        img = img0.copy()\n        for _ in range(iter_n):\n            g, _ = sess.run([t_grad, t_score], {t_input:img})\n            # normalizing the gradient, so the same step size should work \n            g /= g.std()+1e-8         # for different layers and networks\n            img += g*step\n        showarray(visstd(img))\n        \n    def tffunc(*argtypes):\n        '''Helper that transforms TF-graph generating function into a regular one.\n        See \"resize\" function below.\n        '''\n        placeholders = list(map(tf.placeholder, argtypes))\n        def wrap(f):\n            out = f(*placeholders)\n            def wrapper(*args, **kw):\n                return out.eval(dict(zip(placeholders, args)), session=kw.get('session'))\n            return wrapper\n        return wrap\n    \n    # Helper function that uses TF to resize an image\n    def resize(img, size):\n        img = tf.expand_dims(img, 0)\n        return tf.image.resize_bilinear(img, size)[0,:,:,:]\n    resize = tffunc(np.float32, np.int32)(resize)\n    \n    \n    def calc_grad_tiled(img, t_grad, tile_size=512):\n        '''Compute the value of tensor t_grad over the image in a tiled way.\n        Random shifts are applied to the image to blur tile boundaries over \n        multiple iterations.'''\n        sz = tile_size\n        h, w = img.shape[:2]\n        sx, sy = np.random.randint(sz, size=2)\n        img_shift = np.roll(np.roll(img, sx, 1), sy, 0)\n        grad = np.zeros_like(img)\n        for y in range(0, max(h-sz//2, sz),sz):\n            for x in range(0, max(w-sz//2, sz),sz):\n                sub = img_shift[y:y+sz,x:x+sz]\n                g = sess.run(t_grad, {t_input:sub})\n                grad[y:y+sz,x:x+sz] = g\n        return np.roll(np.roll(grad, -sx, 1), -sy, 0)    \n      \n    def render_multiscale(t_obj, img0=img_noise, iter_n=10, step=1.0, octave_n=3, octave_scale=1.4):\n        t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n        t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n        \n        img = img0.copy()\n        for octave in range(octave_n):\n            if octave>0:\n                hw = np.float32(img.shape[:2])*octave_scale\n                img = resize(img, np.int32(hw))\n            for _ in range(iter_n):\n                g = calc_grad_tiled(img, t_grad)\n                # normalizing the gradient, so the same step size should work \n                g /= g.std()+1e-8         # for different layers and networks\n                img += g*step\n            showarray(visstd(img))\n            \n    def lap_split(img):\n        '''Split the image into lo and hi frequency components'''\n        with tf.name_scope('split'):\n            lo = tf.nn.conv2d(img, k5x5, [1,2,2,1], 'SAME')\n            lo2 = tf.nn.conv2d_transpose(lo, k5x5*4, tf.shape(img), [1,2,2,1])\n            hi = img-lo2\n        return lo, hi\n    \n    def lap_split_n(img, n):\n        '''Build Laplacian pyramid with n splits'''\n        levels = []\n        for _ in range(n):\n            img, hi = lap_split(img)\n            levels.append(hi)\n        levels.append(img)\n        return levels[::-1]\n    \n    def lap_merge(levels):\n        '''Merge Laplacian pyramid'''\n        img = levels[0]\n        for hi in levels[1:]:\n            with tf.name_scope('merge'):\n                img = tf.nn.conv2d_transpose(img, k5x5*4, tf.shape(hi), [1,2,2,1]) + hi\n        return img\n    \n    def normalize_std(img, eps=1e-10):\n        '''Normalize image by making its standard deviation = 1.0'''\n        with tf.name_scope('normalize'):\n            std = tf.sqrt(tf.reduce_mean(tf.square(img)))\n            return img/tf.maximum(std, eps)\n    \n    def lap_normalize(img, scale_n=4):\n        '''Perform the Laplacian pyramid normalization.'''\n        img = tf.expand_dims(img,0)\n        tlevels = lap_split_n(img, scale_n)\n        tlevels = list(map(normalize_std, tlevels))\n        out = lap_merge(tlevels)\n        return out[0,:,:,:]\n  \n    def render_lapnorm(t_obj, img0=img_noise, visfunc=visstd,\n                       iter_n=10, step=1.0, octave_n=3, octave_scale=1.4, lap_n=4):\n        t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n        t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n        # build the laplacian normalization graph\n        lap_norm_func = tffunc(np.float32)(partial(lap_normalize, scale_n=lap_n))\n    \n        img = img0.copy()\n        for octave in range(octave_n):\n            if octave>0:\n                hw = np.float32(img.shape[:2])*octave_scale\n                img = resize(img, np.int32(hw))\n            for _ in range(iter_n):\n                g = calc_grad_tiled(img, t_grad)\n                g = lap_norm_func(g)\n                img += g*step\n            showarray(visfunc(img))\n  \n    def render_deepdream(t_obj, img0=img_noise,\n                         iter_n=10, step=1.5, octave_n=4, octave_scale=1.4):\n        t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n        t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n    \n        # split the image into a number of octaves\n        img = img0\n        octaves = []\n        for _ in range(octave_n-1):\n            hw = img.shape[:2]\n            lo = resize(img, np.int32(np.float32(hw)/octave_scale))\n            hi = img-resize(lo, hw)\n            img = lo\n            octaves.append(hi)\n        \n        # generate details octave by octave\n        for octave in range(octave_n):\n            if octave>0:\n                hi = octaves[-octave]\n                img = resize(img, hi.shape[:2])+hi\n            for _ in range(iter_n):\n                g = calc_grad_tiled(img, t_grad)\n                img += g*(step / (np.abs(g).mean()+1e-7))\n            showarray(img/255.0)\n  \n    # Picking some internal layer. Note that we use outputs before applying the ReLU nonlinearity\n    # to have non-zero gradients for features with negative initial activations.\n    layer = 'mixed4d_3x3_bottleneck_pre_relu'\n    channel = 139 # picking some feature channel to visualize\n    render_naive(T(layer)[:,:,:,channel])\n    \n    render_multiscale(T(layer)[:,:,:,channel])\n   \n    k = np.float32([1,4,6,4,1])\n    k = np.outer(k, k)\n    k5x5 = k[:,:,None,None]/k.sum()*np.eye(3, dtype=np.float32)\n     \n    render_lapnorm(T(layer)[:,:,:,channel])\n     \n    render_lapnorm(T(layer)[:,:,:,65])\n     \n    render_lapnorm(T('mixed3b_1x1_pre_relu')[:,:,:,101])\n     \n    render_lapnorm(T(layer)[:,:,:,65]+T(layer)[:,:,:,139], octave_n=4)\n     \n     \n    img0 = PIL.Image.open('pilatus800.jpg')\n    img0 = np.float32(img0)\n    showarray(img0/255.0)\n     \n    render_deepdream(tf.square(T('mixed4c')), img0)\n     \n    render_deepdream(T(layer)[:,:,:,139], img0)\n    \n  \nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "tmp/detect_face_v1.m",
    "content": "% MIT License\n% \n% Copyright (c) 2016 Kaipeng Zhang\n% \n% Permission is hereby granted, free of charge, to any person obtaining a copy\n% of this software and associated documentation files (the \"Software\"), to deal\n% in the Software without restriction, including without limitation the rights\n% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n% copies of the Software, and to permit persons to whom the Software is\n% furnished to do so, subject to the following conditions:\n% \n% The above copyright notice and this permission notice shall be included in all\n% copies or substantial portions of the Software.\n% \n% THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n% SOFTWARE.\n\nfunction [total_boxes, points] = detect_face_v1(img,minsize,PNet,RNet,ONet,threshold,fastresize,factor)\n\t%im: input image\n\t%minsize: minimum of faces' size\n\t%pnet, rnet, onet: caffemodel\n\t%threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold\n\t%fastresize: resize img from last scale (using in high-resolution images) if fastresize==true\n\tfactor_count=0;\n\ttotal_boxes=[];\n\tpoints=[];\n\th=size(img,1);\n\tw=size(img,2);\n\tminl=min([w h]);\n    img=single(img);\n\tif fastresize\n\t\tim_data=(single(img)-127.5)*0.0078125;\n    end\n    m=12/minsize;\n\tminl=minl*m;\n\t%creat scale pyramid\n    scales=[];\n\twhile (minl>=12)\n\t\tscales=[scales m*factor^(factor_count)];\n\t\tminl=minl*factor;\n\t\tfactor_count=factor_count+1;\n\tend\n\t%first stage\n\tfor j = 1:size(scales,2)\n\t\tscale=scales(j);\n\t\ths=ceil(h*scale);\n\t\tws=ceil(w*scale);\n\t\tif fastresize\n\t\t\tim_data=imResample(im_data,[hs ws],'bilinear');\n\t\telse \n\t\t\tim_data=(imResample(img,[hs ws],'bilinear')-127.5)*0.0078125;\n\t\tend\n\t\tPNet.blobs('data').reshape([hs ws 3 1]);\n\t\tout=PNet.forward({im_data});\n\t\tboxes=generateBoundingBox(out{2}(:,:,2),out{1},scale,threshold(1));\n\t\t%inter-scale nms\n\t\tpick=nms(boxes,0.5,'Union');\n\t\tboxes=boxes(pick,:);\n\t\tif ~isempty(boxes)\n\t\t\ttotal_boxes=[total_boxes;boxes];\n\t\tend\n\tend\n\tnumbox=size(total_boxes,1);\n\tif ~isempty(total_boxes)\n\t\tpick=nms(total_boxes,0.7,'Union');\n\t\ttotal_boxes=total_boxes(pick,:);\n\t\tregw=total_boxes(:,3)-total_boxes(:,1);\n\t\tregh=total_boxes(:,4)-total_boxes(:,2);\n\t\ttotal_boxes=[total_boxes(:,1)+total_boxes(:,6).*regw total_boxes(:,2)+total_boxes(:,7).*regh total_boxes(:,3)+total_boxes(:,8).*regw total_boxes(:,4)+total_boxes(:,9).*regh total_boxes(:,5)];\t\n\t\ttotal_boxes=rerec(total_boxes);\n\t\ttotal_boxes(:,1:4)=fix(total_boxes(:,1:4));\n\t\t[dy edy dx edx y ey x ex tmpw tmph]=pad(total_boxes,w,h);\n\tend\n\tnumbox=size(total_boxes,1);\n\tif numbox>0\n\t\t%second stage\n \t\ttempimg=zeros(24,24,3,numbox);\n\t\tfor k=1:numbox\n\t\t\ttmp=zeros(tmph(k),tmpw(k),3);\n\t\t\ttmp(dy(k):edy(k),dx(k):edx(k),:)=img(y(k):ey(k),x(k):ex(k),:);\n            if size(tmp,1)>0 && size(tmp,2)>0 || size(tmp,1)==0 && size(tmp,2)==0\n                tempimg(:,:,:,k)=imResample(tmp,[24 24],'bilinear');\n            else\n                total_boxes = [];\n                return;\n            end;\n\t\tend\n        tempimg=(tempimg-127.5)*0.0078125;\n\t\tRNet.blobs('data').reshape([24 24 3 numbox]);\n\t\tout=RNet.forward({tempimg});\n\t\tscore=squeeze(out{2}(2,:));\n\t\tpass=find(score>threshold(2));\n\t\ttotal_boxes=[total_boxes(pass,1:4) score(pass)'];\n\t\tmv=out{1}(:,pass);\n\t\tif size(total_boxes,1)>0\t\t\n\t\t\tpick=nms(total_boxes,0.7,'Union');\n\t\t\ttotal_boxes=total_boxes(pick,:);     \n            total_boxes=bbreg(total_boxes,mv(:,pick)');\t\n            total_boxes=rerec(total_boxes);\n\t\tend\n\t\tnumbox=size(total_boxes,1);\n\t\tif numbox>0\n\t\t\t%third stage\n\t\t\ttotal_boxes=fix(total_boxes);\n\t\t\t[dy edy dx edx y ey x ex tmpw tmph]=pad(total_boxes,w,h);\n            tempimg=zeros(48,48,3,numbox);\n\t\t\tfor k=1:numbox\n\t\t\t\ttmp=zeros(tmph(k),tmpw(k),3);\n\t\t\t\ttmp(dy(k):edy(k),dx(k):edx(k),:)=img(y(k):ey(k),x(k):ex(k),:);\n                if size(tmp,1)>0 && size(tmp,2)>0 || size(tmp,1)==0 && size(tmp,2)==0\n    \t\t\t\ttempimg(:,:,:,k)=imResample(tmp,[48 48],'bilinear');\n                else\n                    total_boxes = [];\n                    return;\n                end;\n\t\t\tend\n\t\t\ttempimg=(tempimg-127.5)*0.0078125;\n\t\t\tONet.blobs('data').reshape([48 48 3 numbox]);\n\t\t\tout=ONet.forward({tempimg});\n\t\t\tscore=squeeze(out{3}(2,:));\n\t\t\tpoints=out{2};\n\t\t\tpass=find(score>threshold(3));\n\t\t\tpoints=points(:,pass);\n\t\t\ttotal_boxes=[total_boxes(pass,1:4) score(pass)'];\n\t\t\tmv=out{1}(:,pass);\n\t\t\tw=total_boxes(:,3)-total_boxes(:,1)+1;\n            h=total_boxes(:,4)-total_boxes(:,2)+1;\n            points(1:5,:)=repmat(w',[5 1]).*points(1:5,:)+repmat(total_boxes(:,1)',[5 1])-1;\n            points(6:10,:)=repmat(h',[5 1]).*points(6:10,:)+repmat(total_boxes(:,2)',[5 1])-1;\n\t\t\tif size(total_boxes,1)>0\t\t\t\t\n\t\t\t\ttotal_boxes=bbreg(total_boxes,mv(:,:)');\t\n                pick=nms(total_boxes,0.7,'Min');\n\t\t\t\ttotal_boxes=total_boxes(pick,:);  \t\t\t\t\n                points=points(:,pick);\n\t\t\tend\n\t\tend\n    end \t\nend\n\nfunction [boundingbox] = bbreg(boundingbox,reg)\n\t%calibrate bouding boxes\n\tif size(reg,2)==1\n\t\treg=reshape(reg,[size(reg,3) size(reg,4)])';\n\tend\n\tw=[boundingbox(:,3)-boundingbox(:,1)]+1;\n\th=[boundingbox(:,4)-boundingbox(:,2)]+1;\n\tboundingbox(:,1:4)=[boundingbox(:,1)+reg(:,1).*w boundingbox(:,2)+reg(:,2).*h boundingbox(:,3)+reg(:,3).*w boundingbox(:,4)+reg(:,4).*h];\nend\n\nfunction [boundingbox reg] = generateBoundingBox(map,reg,scale,t)\n\t%use heatmap to generate bounding boxes\n    stride=2;\n    cellsize=12;\n    boundingbox=[];\n\tmap=map';\n\tdx1=reg(:,:,1)';\n\tdy1=reg(:,:,2)';\n\tdx2=reg(:,:,3)';\n\tdy2=reg(:,:,4)';\n    [y x]=find(map>=t);\n\ta=find(map>=t); \n    if size(y,1)==1\n\t\ty=y';x=x';score=map(a)';dx1=dx1';dy1=dy1';dx2=dx2';dy2=dy2';\n\telse\n\t\tscore=map(a);\n    end   \n\treg=[dx1(a) dy1(a) dx2(a) dy2(a)];\n\tif isempty(reg)\n\t\treg=reshape([],[0 3]);\n\tend\n    boundingbox=[y x];\n    boundingbox=[fix((stride*(boundingbox-1)+1)/scale) fix((stride*(boundingbox-1)+cellsize-1+1)/scale) score reg];\nend\n\nfunction pick = nms(boxes,threshold,type)\n\t%NMS\n\tif isempty(boxes)\n\t  pick = [];\n\t  return;\n\tend\n\tx1 = boxes(:,1);\n\ty1 = boxes(:,2);\n\tx2 = boxes(:,3);\n\ty2 = boxes(:,4);\n\ts = boxes(:,5);\n\tarea = (x2-x1+1) .* (y2-y1+1);\n\t[vals, I] = sort(s);\n\tpick = s*0;\n\tcounter = 1;\n\twhile ~isempty(I)\n\t\tlast = length(I);\n\t\ti = I(last);\n\t\tpick(counter) = i;\n\t\tcounter = counter + 1;  \n\t\txx1 = max(x1(i), x1(I(1:last-1)));\n\t\tyy1 = max(y1(i), y1(I(1:last-1)));\n\t\txx2 = min(x2(i), x2(I(1:last-1)));\n\t\tyy2 = min(y2(i), y2(I(1:last-1)));  \n\t\tw = max(0.0, xx2-xx1+1);\n\t\th = max(0.0, yy2-yy1+1); \n\t\tinter = w.*h;\n\t\tif strcmp(type,'Min')\n\t\t\to = inter ./ min(area(i),area(I(1:last-1)));\n\t\telse\n\t\t\to = inter ./ (area(i) + area(I(1:last-1)) - inter);\n\t\tend\n\t\tI = I(find(o<=threshold));\n\tend\n\tpick = pick(1:(counter-1));\nend\n\nfunction [dy edy dx edx y ey x ex tmpw tmph] = pad(total_boxes,w,h)\n\t%compute the padding coordinates (pad the bounding boxes to square)\n\ttmpw=total_boxes(:,3)-total_boxes(:,1)+1;\n\ttmph=total_boxes(:,4)-total_boxes(:,2)+1;\n\tnumbox=size(total_boxes,1);\n\t\n    dx=ones(numbox,1);dy=ones(numbox,1);\n\tedx=tmpw;edy=tmph;\n\t\n\tx=total_boxes(:,1);y=total_boxes(:,2);\n\tex=total_boxes(:,3);ey=total_boxes(:,4);\t\t\n\t\n\ttmp=find(ex>w);\n\tedx(tmp)=-ex(tmp)+w+tmpw(tmp);ex(tmp)=w;\t\t\n\t\n\ttmp=find(ey>h);\n\tedy(tmp)=-ey(tmp)+h+tmph(tmp);ey(tmp)=h;\t\n\t\n\ttmp=find(x<1);\n\tdx(tmp)=2-x(tmp);x(tmp)=1;\t\n\t\n\ttmp=find(y<1);\n\tdy(tmp)=2-y(tmp);y(tmp)=1;\nend\n\nfunction [bboxA] = rerec(bboxA)\n\t%convert bboxA to square\n\tbboxB=bboxA(:,1:4);\n    h=bboxA(:,4)-bboxA(:,2);\n\tw=bboxA(:,3)-bboxA(:,1);\n    l=max([w h]')';\n    bboxA(:,1)=bboxA(:,1)+w.*0.5-l.*0.5;\n    bboxA(:,2)=bboxA(:,2)+h.*0.5-l.*0.5;\n    bboxA(:,3:4)=bboxA(:,1:2)+repmat(l,[1 2]);\nend\n\n\n"
  },
  {
    "path": "tmp/detect_face_v2.m",
    "content": "% MIT License\n% \n% Copyright (c) 2016 Kaipeng Zhang\n% \n% Permission is hereby granted, free of charge, to any person obtaining a copy\n% of this software and associated documentation files (the \"Software\"), to deal\n% in the Software without restriction, including without limitation the rights\n% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n% copies of the Software, and to permit persons to whom the Software is\n% furnished to do so, subject to the following conditions:\n% \n% The above copyright notice and this permission notice shall be included in all\n% copies or substantial portions of the Software.\n% \n% THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n% SOFTWARE.\n\nfunction [total_boxes, points] = detect_face_v2(img,minsize,PNet,RNet,ONet,LNet,threshold,fastresize,factor)\n\t%im: input image\n\t%minsize: minimum of faces' size\n\t%pnet, rnet, onet: caffemodel\n\t%threshold: threshold=[th1 th2 th3], th1-3 are three steps's threshold\n\t%fastresize: resize img from last scale (using in high-resolution images) if fastresize==true\n\tfactor_count=0;\n\ttotal_boxes=[];\n\tpoints=[];\n\th=size(img,1);\n\tw=size(img,2);\n\tminl=min([w h]);\n    img=single(img);\n\tif fastresize\n\t\tim_data=(single(img)-127.5)*0.0078125;\n    end\n    m=12/minsize;\n\tminl=minl*m;\n\t%creat scale pyramid\n    scales=[];\n\twhile (minl>=12)\n\t\tscales=[scales m*factor^(factor_count)];\n\t\tminl=minl*factor;\n\t\tfactor_count=factor_count+1;\n\tend\n\t%first stage\n\tfor j = 1:size(scales,2)\n\t\tscale=scales(j);\n\t\ths=ceil(h*scale);\n\t\tws=ceil(w*scale);\n\t\tif fastresize\n\t\t\tim_data=imResample(im_data,[hs ws],'bilinear');\n\t\telse \n\t\t\tim_data=(imResample(img,[hs ws],'bilinear')-127.5)*0.0078125;\n\t\tend\n\t\tPNet.blobs('data').reshape([hs ws 3 1]);\n\t\tout=PNet.forward({im_data});\n\t\tboxes=generateBoundingBox(out{2}(:,:,2),out{1},scale,threshold(1));\n\t\t%inter-scale nms\n\t\tpick=nms(boxes,0.5,'Union');\n\t\tboxes=boxes(pick,:);\n\t\tif ~isempty(boxes)\n\t\t\ttotal_boxes=[total_boxes;boxes];\n\t\tend\n\tend\n\tnumbox=size(total_boxes,1);\n\tif ~isempty(total_boxes)\n\t\tpick=nms(total_boxes,0.7,'Union');\n\t\ttotal_boxes=total_boxes(pick,:);\n\t\tbbw=total_boxes(:,3)-total_boxes(:,1);\n\t\tbbh=total_boxes(:,4)-total_boxes(:,2);\n\t\ttotal_boxes=[total_boxes(:,1)+total_boxes(:,6).*bbw total_boxes(:,2)+total_boxes(:,7).*bbh total_boxes(:,3)+total_boxes(:,8).*bbw total_boxes(:,4)+total_boxes(:,9).*bbh total_boxes(:,5)];\t\n\t\ttotal_boxes=rerec(total_boxes);\n\t\ttotal_boxes(:,1:4)=fix(total_boxes(:,1:4));\n\t\t[dy edy dx edx y ey x ex tmpw tmph]=pad(total_boxes,w,h);\n\tend\n\tnumbox=size(total_boxes,1);\n\tif numbox>0\n\t\t%second stage\n \t\ttempimg=zeros(24,24,3,numbox);\n\t\tfor k=1:numbox\n\t\t\ttmp=zeros(tmph(k),tmpw(k),3);\n\t\t\ttmp(dy(k):edy(k),dx(k):edx(k),:)=img(y(k):ey(k),x(k):ex(k),:);\n\t\t\ttempimg(:,:,:,k)=imResample(tmp,[24 24],'bilinear');\n\t\tend\n        tempimg=(tempimg-127.5)*0.0078125;\n\t\tRNet.blobs('data').reshape([24 24 3 numbox]);\n\t\tout=RNet.forward({tempimg});\n\t\tscore=squeeze(out{2}(2,:));\n\t\tpass=find(score>threshold(2));\n\t\ttotal_boxes=[total_boxes(pass,1:4) score(pass)'];\n\t\tmv=out{1}(:,pass);\n\t\tif size(total_boxes,1)>0\t\t\n\t\t\tpick=nms(total_boxes,0.7,'Union');\n\t\t\ttotal_boxes=total_boxes(pick,:);     \n            total_boxes=bbreg(total_boxes,mv(:,pick)');\t\n            total_boxes=rerec(total_boxes);\n\t\tend\n\t\tnumbox=size(total_boxes,1);\n\t\tif numbox>0\n\t\t\t%third stage\n\t\t\ttotal_boxes=fix(total_boxes);\n\t\t\t[dy edy dx edx y ey x ex tmpw tmph]=pad(total_boxes,w,h);\n            tempimg=zeros(48,48,3,numbox);\n\t\t\tfor k=1:numbox\n\t\t\t\ttmp=zeros(tmph(k),tmpw(k),3);\n\t\t\t\ttmp(dy(k):edy(k),dx(k):edx(k),:)=img(y(k):ey(k),x(k):ex(k),:);\n\t\t\t\ttempimg(:,:,:,k)=imResample(tmp,[48 48],'bilinear');\n\t\t\tend\n\t\t\ttempimg=(tempimg-127.5)*0.0078125;\n\t\t\tONet.blobs('data').reshape([48 48 3 numbox]);\n\t\t\tout=ONet.forward({tempimg});\n\t\t\tscore=squeeze(out{3}(2,:));\n\t\t\tpoints=out{2};\n\t\t\tpass=find(score>threshold(3));\n\t\t\tpoints=points(:,pass);\n\t\t\ttotal_boxes=[total_boxes(pass,1:4) score(pass)'];\n\t\t\tmv=out{1}(:,pass);\n\t\t\tbbw=total_boxes(:,3)-total_boxes(:,1)+1;\n            bbh=total_boxes(:,4)-total_boxes(:,2)+1;\n            points(1:5,:)=repmat(bbw',[5 1]).*points(1:5,:)+repmat(total_boxes(:,1)',[5 1])-1;\n            points(6:10,:)=repmat(bbh',[5 1]).*points(6:10,:)+repmat(total_boxes(:,2)',[5 1])-1;\n\t\t\tif size(total_boxes,1)>0\t\t\t\t\n\t\t\t\ttotal_boxes=bbreg(total_boxes,mv(:,:)');\t\n                pick=nms(total_boxes,0.7,'Min');\n\t\t\t\ttotal_boxes=total_boxes(pick,:);  \t\t\t\t\n                points=points(:,pick);\n\t\t\tend\n\t\tend\n\t\tnumbox=size(total_boxes,1);\n\t\t%extended stage\n\t\tif numbox>0 \n\t\t\ttempimg=zeros(24,24,15,numbox);\n\t\t\tpatchw=max([total_boxes(:,3)-total_boxes(:,1)+1 total_boxes(:,4)-total_boxes(:,2)+1]');\n\t\t\tpatchw=fix(0.25*patchw);\t\n\t\t\ttmp=find(mod(patchw,2)==1);\n\t\t\tpatchw(tmp)=patchw(tmp)+1;\n\t\t\tpointx=ones(numbox,5);\n\t\t\tpointy=ones(numbox,5);\n\t\t\tfor k=1:5\n\t\t\t\ttmp=[points(k,:);points(k+5,:)];\n\t\t\t\tx=fix(tmp(1,:)-0.5*patchw);\n\t\t\t\ty=fix(tmp(2,:)-0.5*patchw);\n\t\t\t\t[dy edy dx edx y ey x ex tmpw tmph]=pad([x' y' x'+patchw' y'+patchw'],w,h);\n\t\t\t\tfor j=1:numbox\n\t\t\t\t\ttmpim=zeros(tmpw(j),tmpw(j),3);\n\t\t\t\t\ttmpim(dy(j):edy(j),dx(j):edx(j),:)=img(y(j):ey(j),x(j):ex(j),:);\n\t\t\t\t\ttempimg(:,:,(k-1)*3+1:(k-1)*3+3,j)=imResample(tmpim,[24 24],'bilinear');\n\t\t\t\tend\n\t\t\tend\n\t\t\tLNet.blobs('data').reshape([24 24 15 numbox]);\n\t\t\ttempimg=(tempimg-127.5)*0.0078125;\n\t\t\tout=LNet.forward({tempimg});\n\t\t\tscore=squeeze(out{3}(2,:));\n\t\t\tfor k=1:5\n\t\t\t\ttmp=[points(k,:);points(k+5,:)];\n\t\t\t\t%do not make a large movement\n\t\t\t\ttemp=find(abs(out{k}(1,:)-0.5)>0.35);\n\t\t\t\tif ~isempty(temp)\n\t\t\t\t\tl=length(temp);\n\t\t\t\t\tout{k}(:,temp)=ones(2,l)*0.5;\n\t\t\t\tend\n\t\t\t\ttemp=find(abs(out{k}(2,:)-0.5)>0.35);  \n\t\t\t\tif ~isempty(temp)\n\t\t\t\t\tl=length(temp);\n\t\t\t\t\tout{k}(:,temp)=ones(2,l)*0.5;\n\t\t\t\tend\n\t\t\t\tpointx(:,k)=(tmp(1,:)-0.5*patchw+out{k}(1,:).*patchw)';\n\t\t\t\tpointy(:,k)=(tmp(2,:)-0.5*patchw+out{k}(2,:).*patchw)';\n\t\t\tend\n\t\t\tfor j=1:numbox\n\t\t\t\tpoints(:,j)=[pointx(j,:)';pointy(j,:)'];\n\t\t\tend\n\t\tend\n    end \t\nend\n\nfunction [boundingbox] = bbreg(boundingbox,reg)\n\t%calibrate bouding boxes\n\tif size(reg,2)==1\n\t\treg=reshape(reg,[size(reg,3) size(reg,4)])';\n\tend\n\tw=[boundingbox(:,3)-boundingbox(:,1)]+1;\n\th=[boundingbox(:,4)-boundingbox(:,2)]+1;\n\tboundingbox(:,1:4)=[boundingbox(:,1)+reg(:,1).*w boundingbox(:,2)+reg(:,2).*h boundingbox(:,3)+reg(:,3).*w boundingbox(:,4)+reg(:,4).*h];\nend\n\nfunction [boundingbox reg] = generateBoundingBox(map,reg,scale,t)\n\t%use heatmap to generate bounding boxes\n    stride=2;\n    cellsize=12;\n    boundingbox=[];\n\tmap=map';\n\tdx1=reg(:,:,1)';\n\tdy1=reg(:,:,2)';\n\tdx2=reg(:,:,3)';\n\tdy2=reg(:,:,4)';\n    [y x]=find(map>=t);\n\ta=find(map>=t); \n    if size(y,1)==1\n\t\ty=y';x=x';score=map(a)';dx1=dx1';dy1=dy1';dx2=dx2';dy2=dy2';\n\telse\n\t\tscore=map(a);\n    end   \n\treg=[dx1(a) dy1(a) dx2(a) dy2(a)];\n\tif isempty(reg)\n\t\treg=reshape([],[0 3]);\n\tend\n    boundingbox=[y x];\n    boundingbox=[fix((stride*(boundingbox-1)+1)/scale) fix((stride*(boundingbox-1)+cellsize-1+1)/scale) score reg];\nend\n\nfunction pick = nms(boxes,threshold,type)\n\t%NMS\n\tif isempty(boxes)\n\t  pick = [];\n\t  return;\n\tend\n\tx1 = boxes(:,1);\n\ty1 = boxes(:,2);\n\tx2 = boxes(:,3);\n\ty2 = boxes(:,4);\n\ts = boxes(:,5);\n\tarea = (x2-x1+1) .* (y2-y1+1);\n\t[vals, I] = sort(s);\n\tpick = s*0;\n\tcounter = 1;\n\twhile ~isempty(I)\n\t\tlast = length(I);\n\t\ti = I(last);\n\t\tpick(counter) = i;\n\t\tcounter = counter + 1;  \n\t\txx1 = max(x1(i), x1(I(1:last-1)));\n\t\tyy1 = max(y1(i), y1(I(1:last-1)));\n\t\txx2 = min(x2(i), x2(I(1:last-1)));\n\t\tyy2 = min(y2(i), y2(I(1:last-1)));  \n\t\tw = max(0.0, xx2-xx1+1);\n\t\th = max(0.0, yy2-yy1+1); \n\t\tinter = w.*h;\n\t\tif strcmp(type,'Min')\n\t\t\to = inter ./ min(area(i),area(I(1:last-1)));\n\t\telse\n\t\t\to = inter ./ (area(i) + area(I(1:last-1)) - inter);\n\t\tend\n\t\tI = I(find(o<=threshold));\n\tend\n\tpick = pick(1:(counter-1));\nend\n\nfunction [dy edy dx edx y ey x ex tmpw tmph] = pad(total_boxes,w,h)\n\t%compute the padding coordinates (pad the bounding boxes to square)\n\ttmpw=total_boxes(:,3)-total_boxes(:,1)+1;\n\ttmph=total_boxes(:,4)-total_boxes(:,2)+1;\n\tnumbox=size(total_boxes,1);\n\t\n    dx=ones(numbox,1);dy=ones(numbox,1);\n\tedx=tmpw;edy=tmph;\n\t\n\tx=total_boxes(:,1);y=total_boxes(:,2);\n\tex=total_boxes(:,3);ey=total_boxes(:,4);\t\t\n\t\n\ttmp=find(ex>w);\n\tedx(tmp)=-ex(tmp)+w+tmpw(tmp);ex(tmp)=w;\t\t\n\t\n\ttmp=find(ey>h);\n\tedy(tmp)=-ey(tmp)+h+tmph(tmp);ey(tmp)=h;\t\n\t\n\ttmp=find(x<1);\n\tdx(tmp)=2-x(tmp);x(tmp)=1;\t\n\t\n\ttmp=find(y<1);\n\tdy(tmp)=2-y(tmp);y(tmp)=1;\nend\n\nfunction [bboxA] = rerec(bboxA)\n\t%convert bboxA to square\n\tbboxB=bboxA(:,1:4);\n    h=bboxA(:,4)-bboxA(:,2);\n\tw=bboxA(:,3)-bboxA(:,1);\n    l=max([w h]')';\n    bboxA(:,1)=bboxA(:,1)+w.*0.5-l.*0.5;\n    bboxA(:,2)=bboxA(:,2)+h.*0.5-l.*0.5;\n    bboxA(:,3:4)=bboxA(:,1:2)+repmat(l,[1 2]);\nend\n\n\n"
  },
  {
    "path": "tmp/download_vgg_face_dataset.py",
    "content": "\"\"\"Download the VGG face dataset from URLs given by http://www.robots.ox.ac.uk/~vgg/data/vgg_face/vgg_face_dataset.tar.gz\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport numpy as np\nfrom skimage import io\nimport sys\nimport argparse\nimport os\nimport socket\nfrom urllib2 import HTTPError, URLError\nfrom httplib import HTTPException\n\ndef main(args):\n    socket.setdefaulttimeout(30)\n    textfile_names = os.listdir(args.dataset_descriptor)\n    for textfile_name in textfile_names:\n        if textfile_name.endswith('.txt'):\n            with open(os.path.join(args.dataset_descriptor, textfile_name), 'rt') as f:\n                lines = f.readlines()\n            dir_name = textfile_name.split('.')[0]\n            class_path = os.path.join(args.dataset_descriptor, dir_name)\n            if not os.path.exists(class_path):\n                os.makedirs(class_path)\n            for line in lines:\n                x = line.split(' ')\n                filename = x[0]\n                url = x[1]\n                box = np.rint(np.array(map(float, x[2:6])))  # x1,y1,x2,y2\n                image_path = os.path.join(args.dataset_descriptor, dir_name, filename+'.'+args.output_format)\n                error_path = os.path.join(args.dataset_descriptor, dir_name, filename+'.err')\n                if not os.path.exists(image_path) and not os.path.exists(error_path):\n                    try:\n                        img = io.imread(url, mode='RGB')\n                    except (HTTPException, HTTPError, URLError, IOError, ValueError, IndexError, OSError) as e:\n                        error_message = '{}: {}'.format(url, e)\n                        save_error_message_file(error_path, error_message)\n                    else:\n                        try:\n                            if img.ndim == 2:\n                                img = to_rgb(img)\n                            if img.ndim != 3:\n                                raise ValueError('Wrong number of image dimensions')\n                            hist = np.histogram(img, 255, density=True)\n                            if hist[0][0]>0.9 and hist[0][254]>0.9:\n                                raise ValueError('Image is mainly black or white')\n                            else:\n                                # Crop image according to dataset descriptor\n                                img_cropped = img[int(box[1]):int(box[3]),int(box[0]):int(box[2]),:]\n                                # Scale to 256x256\n                                img_resized = misc.imresize(img_cropped, (args.image_size,args.image_size))\n                                # Save image as .png\n                                misc.imsave(image_path, img_resized)\n                        except ValueError as e:\n                            error_message = '{}: {}'.format(url, e)\n                            save_error_message_file(error_path, error_message)\n            \ndef save_error_message_file(filename, error_message):\n    print(error_message)\n    with open(filename, \"w\") as textfile:\n        textfile.write(error_message)\n          \ndef to_rgb(img):\n    w, h = img.shape\n    ret = np.empty((w, h, 3), dtype=np.uint8)\n    ret[:, :, 0] = ret[:, :, 1] = ret[:, :, 2] = img\n    return ret\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    parser.add_argument('dataset_descriptor', type=str, \n        help='Directory containing the text files with the image URLs. Image files will also be placed in this directory.')\n    parser.add_argument('--output_format', type=str, help='Format of the output images', default='png', choices=['png', 'jpg'])\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=256)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/funnel_dataset.py",
    "content": "\"\"\"Performs face alignment and stores face thumbnails in the output directory.\"\"\"\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nfrom scipy import misc\nimport sys\nimport os\nimport argparse\nimport facenet\nimport subprocess\nfrom contextlib import contextmanager\nimport tempfile\nimport shutil\nimport numpy as np\n\n@contextmanager\ndef TemporaryDirectory():\n    name = tempfile.mkdtemp()\n    try:\n        yield name\n    finally:\n        shutil.rmtree(name)\n\n\ndef main(args):\n    funnel_cmd = 'funnelReal'\n    funnel_model = 'people.train'\n\n    output_dir = os.path.expanduser(args.output_dir)\n    if not os.path.exists(output_dir):\n        os.makedirs(output_dir)\n    # Store some git revision info in a text file in the output directory\n    src_path,_ = os.path.split(os.path.realpath(__file__))\n    facenet.store_revision_info(src_path, output_dir, ' '.join(sys.argv))\n    dataset = facenet.get_dataset(args.input_dir)\n    np.random.shuffle(dataset)\n    # Scale the image such that the face fills the frame when cropped to crop_size\n    #scale = float(args.face_size) / args.image_size\n    with TemporaryDirectory() as tmp_dir:\n        for cls in dataset:\n            output_class_dir = os.path.join(output_dir, cls.name)\n            tmp_output_class_dir = os.path.join(tmp_dir, cls.name)\n            if not os.path.exists(output_class_dir) and not os.path.exists(tmp_output_class_dir):\n                print('Aligning class %s:' % cls.name)\n                tmp_filenames = []\n                if not os.path.exists(tmp_output_class_dir):\n                    os.makedirs(tmp_output_class_dir)\n                input_list_filename = os.path.join(tmp_dir, 'input_list.txt')\n                output_list_filename = os.path.join(tmp_dir, 'output_list.txt')\n                input_file = open(input_list_filename, 'w')\n                output_file = open(output_list_filename,'w')\n                for image_path in cls.image_paths:\n                    filename = os.path.split(image_path)[1]\n                    input_file.write(image_path+'\\n')\n                    output_filename = os.path.join(tmp_output_class_dir, filename)\n                    output_file.write(output_filename+'\\n')\n                    tmp_filenames.append(output_filename)\n                input_file.close()\n                output_file.close()\n                cmd = args.funnel_dir+funnel_cmd + ' ' + input_list_filename + ' ' + args.funnel_dir+funnel_model + ' ' + output_list_filename\n                subprocess.call(cmd, shell=True)\n                \n                # Resize and crop images\n                if not os.path.exists(output_class_dir):\n                    os.makedirs(output_class_dir)\n                scale = 1.0\n                for tmp_filename in tmp_filenames:\n                    img = misc.imread(tmp_filename)\n                    img_scale = misc.imresize(img, scale)\n                    sz1 = img.shape[1]/2\n                    sz2 = args.image_size/2\n                    img_crop = img_scale[int(sz1-sz2):int(sz1+sz2),int(sz1-sz2):int(sz1+sz2),:]\n                    filename = os.path.splitext(os.path.split(tmp_filename)[1])[0]\n                    output_filename = os.path.join(output_class_dir, filename+'.png')\n                    print('Saving image %s' % output_filename)\n                    misc.imsave(output_filename, img_crop)\n                    \n                # Remove tmp directory with images\n                shutil.rmtree(tmp_output_class_dir)\n                \ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('input_dir', type=str, help='Directory with unaligned images.')\n    parser.add_argument('output_dir', type=str, help='Directory with aligned face thumbnails.')\n    parser.add_argument('funnel_dir', type=str, help='Directory containing the funnelReal binary and the people.train model file')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=110)\n    parser.add_argument('--face_size', type=int,\n        help='Size of the face thumbnail (height, width) in pixels.', default=96)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/invariance_test.txt",
    "content": "Accuracy: 0.860±0.009\nAccuracy: 0.861±0.008\nAccuracy: 0.870±0.011\nAccuracy: 0.885±0.012\nAccuracy: 0.896±0.013\nAccuracy: 0.899±0.015\nAccuracy: 0.887±0.011\nAccuracy: 0.885±0.011\nAccuracy: 0.890±0.011\nAccuracy: 0.910±0.014\nAccuracy: 0.918±0.012\nAccuracy: 0.904±0.013\nAccuracy: 0.895±0.012\nAccuracy: 0.884±0.018\nAccuracy: 0.891±0.012\nAccuracy: 0.891±0.008\nAccuracy: 0.889±0.009\nAccuracy: 0.871±0.012\nAccuracy: 0.844±0.012\nAccuracy: 0.835±0.016\nAccuracy: 0.823±0.015\nHoffset:\tAccuracy:\n-30.0000\t0.8600\n-27.0000\t0.8607\n-24.0000\t0.8697\n-21.0000\t0.8848\n-18.0000\t0.8963\n-15.0000\t0.8992\n-12.0000\t0.8865\n-9.0000\t0.8853\n-6.0000\t0.8900\n-3.0000\t0.9097\n0.0000\t0.9182\n3.0000\t0.9040\n6.0000\t0.8953\n9.0000\t0.8843\n12.0000\t0.8905\n15.0000\t0.8913\n18.0000\t0.8888\n21.0000\t0.8708\n24.0000\t0.8440\n27.0000\t0.8348\n30.0000\t0.8233\nAccuracy: 0.823±0.014\nAccuracy: 0.800±0.010\nAccuracy: 0.800±0.015\nAccuracy: 0.818±0.018\nAccuracy: 0.852±0.012\nAccuracy: 0.864±0.011\nAccuracy: 0.844±0.016\nAccuracy: 0.851±0.014\nAccuracy: 0.875±0.012\nAccuracy: 0.898±0.010\nAccuracy: 0.918±0.012\nAccuracy: 0.886±0.015\nAccuracy: 0.849±0.012\nAccuracy: 0.812±0.015\nAccuracy: 0.780±0.012\nAccuracy: 0.787±0.012\nAccuracy: 0.755±0.016\nAccuracy: 0.709±0.010\nAccuracy: 0.676±0.017\nAccuracy: 0.653±0.011\nAccuracy: 0.648±0.016\nVoffset:\tAccuracy:\n-30.0000\t0.8230\n-27.0000\t0.7997\n-24.0000\t0.7995\n-21.0000\t0.8183\n-18.0000\t0.8523\n-15.0000\t0.8638\n-12.0000\t0.8442\n-9.0000\t0.8507\n-6.0000\t0.8755\n-3.0000\t0.8982\n0.0000\t0.9182\n3.0000\t0.8862\n6.0000\t0.8493\n9.0000\t0.8118\n12.0000\t0.7803\n15.0000\t0.7868\n18.0000\t0.7548\n21.0000\t0.7093\n24.0000\t0.6763\n27.0000\t0.6533\n30.0000\t0.6483\n"
  },
  {
    "path": "tmp/mnist_center_loss.py",
    "content": "# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\n\"\"\"Simple, end-to-end, LeNet-5-like convolutional MNIST model example.\nThis should achieve a test error of 0.7%. Please keep this model as simple and\nlinear as possible, it is meant as a tutorial for simple convolutional models.\nRun with --self_test on the command line to execute a short self-test.\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport gzip\nimport os\nimport sys\nimport time\n\nfrom six.moves import urllib  # @UnresolvedImport\nimport tensorflow as tf\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom tensorflow.python.ops import control_flow_ops\nimport facenet\nfrom six.moves import xrange\n\nSOURCE_URL = 'http://yann.lecun.com/exdb/mnist/'\nWORK_DIRECTORY = 'data'\nIMAGE_SIZE = 28\nNUM_CHANNELS = 1\nPIXEL_DEPTH = 255\nNUM_LABELS = 10\nVALIDATION_SIZE = 5000  # Size of the validation set.\nSEED = 66478  # Set to None for random seed.\nBATCH_SIZE = 64\nNUM_EPOCHS = 10\nEVAL_BATCH_SIZE = 64\nEVAL_FREQUENCY = 100  # Number of steps between evaluations.\n\n\ntf.app.flags.DEFINE_boolean(\"self_test\", False, \"True if running a self test.\")\ntf.app.flags.DEFINE_boolean('use_fp16', False,\n                            \"Use half floats instead of full floats if True.\")\nFLAGS = tf.app.flags.FLAGS\n\n\ndef data_type():\n    \"\"\"Return the type of the activations, weights, and placeholder variables.\"\"\"\n    if FLAGS.use_fp16:\n        return tf.float16\n    else:\n        return tf.float32\n\n\ndef maybe_download(filename):\n    \"\"\"Download the data from Yann's website, unless it's already here.\"\"\"\n    if not tf.gfile.Exists(WORK_DIRECTORY):\n        tf.gfile.MakeDirs(WORK_DIRECTORY)\n    filepath = os.path.join(WORK_DIRECTORY, filename)\n    if not tf.gfile.Exists(filepath):\n        filepath, _ = urllib.request.urlretrieve(SOURCE_URL + filename, filepath)\n        with tf.gfile.GFile(filepath) as f:\n            size = f.size()\n        print('Successfully downloaded', filename, size, 'bytes.')\n    return filepath\n\n\ndef extract_data(filename, num_images):\n    \"\"\"Extract the images into a 4D tensor [image index, y, x, channels].\n    Values are rescaled from [0, 255] down to [-0.5, 0.5].\n    \"\"\"\n    print('Extracting', filename)\n    with gzip.open(filename) as bytestream:\n        bytestream.read(16)\n        buf = bytestream.read(IMAGE_SIZE * IMAGE_SIZE * num_images * NUM_CHANNELS)\n        data = np.frombuffer(buf, dtype=np.uint8).astype(np.float32)\n        data = (data - (PIXEL_DEPTH / 2.0)) / PIXEL_DEPTH\n        data = data.reshape(num_images, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS)\n        return data\n\n\ndef extract_labels(filename, num_images):\n    \"\"\"Extract the labels into a vector of int64 label IDs.\"\"\"\n    print('Extracting', filename)\n    with gzip.open(filename) as bytestream:\n        bytestream.read(8)\n        buf = bytestream.read(1 * num_images)\n        labels = np.frombuffer(buf, dtype=np.uint8).astype(np.int64)\n    return labels\n\n\ndef fake_data(num_images):\n    \"\"\"Generate a fake dataset that matches the dimensions of MNIST.\"\"\"\n    data = np.ndarray(\n        shape=(num_images, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS),\n        dtype=np.float32)\n    labels = np.zeros(shape=(num_images,), dtype=np.int64)\n    for image in range(num_images):\n        label = image % 2\n        data[image, :, :, 0] = label - 0.5\n        labels[image] = label\n    return data, labels\n\n\ndef error_rate(predictions, labels):\n    \"\"\"Return the error rate based on dense predictions and sparse labels.\"\"\"\n    return 100.0 - (\n        100.0 *\n        np.sum(np.argmax(predictions, 1) == labels) /\n        predictions.shape[0])\n\n\ndef main(argv=None):  # pylint: disable=unused-argument\n    if FLAGS.self_test:\n        print('Running self-test.')\n        train_data, train_labels = fake_data(256)\n        validation_data, validation_labels = fake_data(EVAL_BATCH_SIZE)\n        test_data, test_labels = fake_data(EVAL_BATCH_SIZE)\n        num_epochs = 1\n    else:\n        # Get the data.\n        train_data_filename = maybe_download('train-images-idx3-ubyte.gz')\n        train_labels_filename = maybe_download('train-labels-idx1-ubyte.gz')\n        test_data_filename = maybe_download('t10k-images-idx3-ubyte.gz')\n        test_labels_filename = maybe_download('t10k-labels-idx1-ubyte.gz')\n    \n        # Extract it into numpy arrays.\n        train_data = extract_data(train_data_filename, 60000)\n        train_labels = extract_labels(train_labels_filename, 60000)\n        test_data = extract_data(test_data_filename, 10000)\n        test_labels = extract_labels(test_labels_filename, 10000)\n    \n        # Generate a validation set.\n        validation_data = train_data[:VALIDATION_SIZE, ...]\n        validation_labels = train_labels[:VALIDATION_SIZE]\n        train_data = train_data[VALIDATION_SIZE:, ...]\n        train_labels = train_labels[VALIDATION_SIZE:]\n        num_epochs = NUM_EPOCHS\n    train_size = train_labels.shape[0]\n\n    # This is where training samples and labels are fed to the graph.\n    # These placeholder nodes will be fed a batch of training data at each\n    # training step using the {feed_dict} argument to the Run() call below.\n    train_data_node = tf.placeholder(\n        data_type(),\n        shape=(BATCH_SIZE, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS))\n    train_labels_node = tf.placeholder(tf.int64, shape=(BATCH_SIZE,))\n    eval_data = tf.placeholder(\n        data_type(),\n        shape=(EVAL_BATCH_SIZE, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS))\n\n    # The variables below hold all the trainable weights. They are passed an\n    # initial value which will be assigned when we call:\n    # {tf.global_variables_initializer().run()}\n    conv1_weights = tf.Variable(\n        tf.truncated_normal([5, 5, NUM_CHANNELS, 32],  # 5x5 filter, depth 32.\n                            stddev=0.1,\n                            seed=SEED, dtype=data_type()))\n    conv1_biases = tf.Variable(tf.zeros([32], dtype=data_type()))\n    conv2_weights = tf.Variable(tf.truncated_normal(\n        [5, 5, 32, 64], stddev=0.1,\n        seed=SEED, dtype=data_type()))\n    conv2_biases = tf.Variable(tf.constant(0.1, shape=[64], dtype=data_type()))\n    fc1_weights = tf.Variable(  # fully connected, depth 512.\n        tf.truncated_normal([IMAGE_SIZE // 4 * IMAGE_SIZE // 4 * 64, 512],\n                            stddev=0.1,\n                            seed=SEED,\n                            dtype=data_type()))\n    fc1_biases = tf.Variable(tf.constant(0.1, shape=[512], dtype=data_type()))\n    fc1p_weights = tf.Variable(  # fully connected, depth 512.\n        tf.truncated_normal([512, 2],\n                            stddev=0.1,\n                            seed=SEED,\n                            dtype=data_type()))\n    fc1p_biases = tf.Variable(tf.constant(0.1, shape=[2], dtype=data_type()))\n    fc2_weights = tf.Variable(tf.truncated_normal([2, NUM_LABELS],\n                                                  stddev=0.1,\n                                                  seed=SEED,\n                                                  dtype=data_type()))\n    fc2_biases = tf.Variable(tf.constant(\n        0.1, shape=[NUM_LABELS], dtype=data_type()))\n    \n    def batch_norm(x, phase_train):  #pylint: disable=unused-variable\n        \"\"\"\n        Batch normalization on convolutional maps.\n        Args:\n            x:           Tensor, 4D BHWD input maps\n            n_out:       integer, depth of input maps\n            phase_train: boolean tf.Variable, true indicates training phase\n            scope:       string, variable scope\n            affn:      whether to affn-transform outputs\n        Return:\n            normed:      batch-normalized maps\n        Ref: http://stackoverflow.com/questions/33949786/how-could-i-use-batch-normalization-in-tensorflow/33950177\n        \"\"\"\n        name = 'batch_norm'\n        with tf.variable_scope(name):\n            phase_train = tf.convert_to_tensor(phase_train, dtype=tf.bool)\n            n_out = int(x.get_shape()[-1])\n            beta = tf.Variable(tf.constant(0.0, shape=[n_out], dtype=x.dtype),\n                               name=name+'/beta', trainable=True, dtype=x.dtype)\n            gamma = tf.Variable(tf.constant(1.0, shape=[n_out], dtype=x.dtype),\n                                name=name+'/gamma', trainable=True, dtype=x.dtype)\n          \n            batch_mean, batch_var = tf.nn.moments(x, [0], name='moments')\n            ema = tf.train.ExponentialMovingAverage(decay=0.9)\n            def mean_var_with_update():\n                ema_apply_op = ema.apply([batch_mean, batch_var])\n                with tf.control_dependencies([ema_apply_op]):\n                    return tf.identity(batch_mean), tf.identity(batch_var)\n            mean, var = control_flow_ops.cond(phase_train,\n                                              mean_var_with_update,\n                                              lambda: (ema.average(batch_mean), ema.average(batch_var)))\n            normed = tf.nn.batch_normalization(x, mean, var, beta, gamma, 1e-3)\n        return normed\n    \n\n    # We will replicate the model structure for the training subgraph, as well\n    # as the evaluation subgraphs, while sharing the trainable parameters.\n    def model(data, train=False):\n        \"\"\"The Model definition.\"\"\"\n        # 2D convolution, with 'SAME' padding (i.e. the output feature map has\n        # the same size as the input). Note that {strides} is a 4D array whose\n        # shape matches the data layout: [image index, y, x, depth].\n        conv = tf.nn.conv2d(data,\n                            conv1_weights,\n                            strides=[1, 1, 1, 1],\n                            padding='SAME')\n        # Bias and rectified linear non-linearity.\n        relu = tf.nn.relu(tf.nn.bias_add(conv, conv1_biases))\n        # Max pooling. The kernel size spec {ksize} also follows the layout of\n        # the data. Here we have a pooling window of 2, and a stride of 2.\n        pool = tf.nn.max_pool(relu,\n                              ksize=[1, 2, 2, 1],\n                              strides=[1, 2, 2, 1],\n                              padding='SAME')\n        conv = tf.nn.conv2d(pool,\n                            conv2_weights,\n                            strides=[1, 1, 1, 1],\n                            padding='SAME')\n        relu = tf.nn.relu(tf.nn.bias_add(conv, conv2_biases))\n        pool = tf.nn.max_pool(relu,\n                              ksize=[1, 2, 2, 1],\n                              strides=[1, 2, 2, 1],\n                              padding='SAME')\n        # Reshape the feature map cuboid into a 2D matrix to feed it to the\n        # fully connected layers.\n        pool_shape = pool.get_shape().as_list() #pylint: disable=no-member\n        reshape = tf.reshape(\n            pool,\n            [pool_shape[0], pool_shape[1] * pool_shape[2] * pool_shape[3]])\n        # Fully connected layer. Note that the '+' operation automatically\n        # broadcasts the biases.\n        hidden = tf.nn.relu(tf.matmul(reshape, fc1_weights) + fc1_biases)\n        # Add a 50% dropout during training only. Dropout also scales\n        # activations such that no rescaling is needed at evaluation time.\n        if train:\n            hidden = tf.nn.dropout(hidden, 0.5, seed=SEED)\n\n        hidden = tf.matmul(hidden, fc1p_weights) + fc1p_biases\n\n        return tf.nn.relu(tf.matmul(hidden, fc2_weights) + fc2_biases), hidden\n\n    # Training computation: logits + cross-entropy loss.\n    logits, hidden = model(train_data_node, True)\n    #logits = batch_norm(logits, True)\n    xent_loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(\n        logits, train_labels_node))\n    beta = 1e-3\n    #center_loss, update_centers = center_loss_op(hidden, train_labels_node)\n    center_loss, _ = facenet.center_loss(hidden, train_labels_node, 0.95, NUM_LABELS)\n    loss = xent_loss + beta * center_loss\n  \n    # L2 regularization for the fully connected parameters.\n    regularizers = (tf.nn.l2_loss(fc1_weights) + tf.nn.l2_loss(fc1_biases) +\n                    tf.nn.l2_loss(fc2_weights) + tf.nn.l2_loss(fc2_biases))\n    # Add the regularization term to the loss.\n    loss += 5e-4 * regularizers\n  \n    # Optimizer: set up a variable that's incremented once per batch and\n    # controls the learning rate decay.\n    batch = tf.Variable(0, dtype=data_type())\n    # Decay once per epoch, using an exponential schedule starting at 0.01.\n    learning_rate = tf.train.exponential_decay(\n        0.01,                # Base learning rate.\n        batch * BATCH_SIZE,  # Current index into the dataset.\n        train_size,          # Decay step.\n        0.95,                # Decay rate.\n        staircase=True)\n    # Use simple momentum for the optimization.\n    optimizer = tf.train.MomentumOptimizer(learning_rate,\n                                           0.9).minimize(loss,\n                                                         global_step=batch)\n  \n    # Predictions for the current training minibatch.\n    train_prediction = tf.nn.softmax(logits)\n  \n    # Predictions for the test and validation, which we'll compute less often.\n    eval_logits, eval_embeddings = model(eval_data)\n    eval_prediction = tf.nn.softmax(eval_logits)\n    \n    # Small utility function to evaluate a dataset by feeding batches of data to\n    # {eval_data} and pulling the results from {eval_predictions}.\n    # Saves memory and enables this to run on smaller GPUs.\n    def eval_in_batches(data, sess):\n        \"\"\"Get all predictions for a dataset by running it in small batches.\"\"\"\n        size = data.shape[0]\n        if size < EVAL_BATCH_SIZE:\n            raise ValueError(\"batch size for evals larger than dataset: %d\" % size)\n        predictions = np.ndarray(shape=(size, NUM_LABELS), dtype=np.float32)\n        for begin in xrange(0, size, EVAL_BATCH_SIZE):\n            end = begin + EVAL_BATCH_SIZE\n            if end <= size:\n                predictions[begin:end, :] = sess.run(\n                    eval_prediction,\n                    feed_dict={eval_data: data[begin:end, ...]})\n            else:\n                batch_predictions = sess.run(\n                    eval_prediction,\n                    feed_dict={eval_data: data[-EVAL_BATCH_SIZE:, ...]})\n                predictions[begin:, :] = batch_predictions[begin - size:, :]\n        return predictions\n  \n    def calculate_embeddings(data, sess):\n        \"\"\"Get all predictions for a dataset by running it in small batches.\"\"\"\n        size = data.shape[0]\n        if size < EVAL_BATCH_SIZE:\n            raise ValueError(\"batch size for evals larger than dataset: %d\" % size)\n        predictions = np.ndarray(shape=(size, 2), dtype=np.float32)\n        for begin in xrange(0, size, EVAL_BATCH_SIZE):\n            end = begin + EVAL_BATCH_SIZE\n            if end <= size:\n                predictions[begin:end, :] = sess.run(\n                    eval_embeddings,\n                    feed_dict={eval_data: data[begin:end, ...]})\n            else:\n                batch_predictions = sess.run(\n                    eval_embeddings,\n                    feed_dict={eval_data: data[-EVAL_BATCH_SIZE:, ...]})\n                predictions[begin:, :] = batch_predictions[begin - size:, :]\n        return predictions\n\n    # Create a local session to run the training.\n    start_time = time.time()\n    with tf.Session() as sess:\n        # Run all the initializers to prepare the trainable parameters.\n        tf.global_variables_initializer().run() #pylint: disable=no-member\n        print('Initialized!')\n        # Loop through training steps.\n        for step in xrange(int(num_epochs * train_size) // BATCH_SIZE):\n            # Compute the offset of the current minibatch in the data.\n            # Note that we could use better randomization across epochs.\n            offset = (step * BATCH_SIZE) % (train_size - BATCH_SIZE)\n            batch_data = train_data[offset:(offset + BATCH_SIZE), ...]\n            batch_labels = train_labels[offset:(offset + BATCH_SIZE)]\n            # This dictionary maps the batch data (as a numpy array) to the\n            # node in the graph it should be fed to.\n            feed_dict = {train_data_node: batch_data,\n                         train_labels_node: batch_labels}\n            # Run the graph and fetch some of the nodes.\n            #_, l, lr, predictions = sess.run([optimizer, loss, learning_rate, train_prediction], feed_dict=feed_dict)\n            _, cl, l, lr, predictions = sess.run([optimizer, center_loss, loss, learning_rate, train_prediction], feed_dict=feed_dict)\n            if step % EVAL_FREQUENCY == 0:\n                elapsed_time = time.time() - start_time\n                start_time = time.time()\n                print('Step %d (epoch %.2f), %.1f ms' %\n                      (step, float(step) * BATCH_SIZE / train_size,\n                       1000 * elapsed_time / EVAL_FREQUENCY))\n                print('Minibatch loss: %.3f  %.3f, learning rate: %.6f' % (l, cl*beta, lr))\n                print('Minibatch error: %.1f%%' % error_rate(predictions, batch_labels))\n                print('Validation error: %.1f%%' % error_rate(\n                    eval_in_batches(validation_data, sess), validation_labels))\n                sys.stdout.flush()\n        # Finally print the result!\n        test_error = error_rate(eval_in_batches(test_data, sess), test_labels)\n        print('Test error: %.1f%%' % test_error)\n        if FLAGS.self_test:\n            print('test_error', test_error)\n            assert test_error == 0.0, 'expected 0.0 test_error, got %.2f' % (\n                test_error,)\n            \n        train_embeddings = calculate_embeddings(train_data, sess)\n        \n        color_list = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'b', 'g', 'r', 'c' ]\n        plt.figure(1)\n        for n in range(0,10):\n            idx = np.where(train_labels[0:10000]==n)\n            plt.plot(train_embeddings[idx,0], train_embeddings[idx,1], color_list[n]+'.')\n        plt.show()\n\n\nif __name__ == '__main__':\n    tf.app.run()\n"
  },
  {
    "path": "tmp/mnist_noise_labels.py",
    "content": "# Copyright 2015 The TensorFlow Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ==============================================================================\n\n\"\"\"Simple, end-to-end, LeNet-5-like convolutional MNIST model example.\nThis should achieve a test error of 0.7%. Please keep this model as simple and\nlinear as possible, it is meant as a tutorial for simple convolutional models.\nRun with --self_test on the command line to execute a short self-test.\n\"\"\"\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport gzip\nimport os\nimport sys\nimport time\n\nfrom six.moves import urllib  # @UnresolvedImport\nimport tensorflow as tf\nimport numpy as np\nfrom six.moves import xrange\n\nSOURCE_URL = 'http://yann.lecun.com/exdb/mnist/'\nWORK_DIRECTORY = 'data'\nIMAGE_SIZE = 28\nNUM_CHANNELS = 1\nPIXEL_DEPTH = 255\nNUM_LABELS = 10\nVALIDATION_SIZE = 5000  # Size of the validation set.\nSEED = 66478  # Set to None for random seed.\nBATCH_SIZE = 64\nNUM_EPOCHS = 10\nEVAL_BATCH_SIZE = 64\nEVAL_FREQUENCY = 100  # Number of steps between evaluations.\nNOISE_FACTOR = 0.2\nBETA = 0.8\n\n\ntf.app.flags.DEFINE_boolean(\"self_test\", False, \"True if running a self test.\")\ntf.app.flags.DEFINE_boolean('use_fp16', False,\n                            \"Use half floats instead of full floats if True.\")\nFLAGS = tf.app.flags.FLAGS\n\n\ndef data_type():\n    \"\"\"Return the type of the activations, weights, and placeholder variables.\"\"\"\n    if FLAGS.use_fp16:\n        return tf.float16\n    else:\n        return tf.float32\n\n\ndef maybe_download(filename):\n    \"\"\"Download the data from Yann's website, unless it's already here.\"\"\"\n    if not tf.gfile.Exists(WORK_DIRECTORY):\n        tf.gfile.MakeDirs(WORK_DIRECTORY)\n    filepath = os.path.join(WORK_DIRECTORY, filename)\n    if not tf.gfile.Exists(filepath):\n        filepath, _ = urllib.request.urlretrieve(SOURCE_URL + filename, filepath)\n        with tf.gfile.GFile(filepath) as f:\n            size = f.size()\n        print('Successfully downloaded', filename, size, 'bytes.')\n    return filepath\n\n\ndef extract_data(filename, num_images):\n    \"\"\"Extract the images into a 4D tensor [image index, y, x, channels].\n    Values are rescaled from [0, 255] down to [-0.5, 0.5].\n    \"\"\"\n    print('Extracting', filename)\n    with gzip.open(filename) as bytestream:\n        bytestream.read(16)\n        buf = bytestream.read(IMAGE_SIZE * IMAGE_SIZE * num_images * NUM_CHANNELS)\n        data = np.frombuffer(buf, dtype=np.uint8).astype(np.float32)\n        data = (data - (PIXEL_DEPTH / 2.0)) / PIXEL_DEPTH\n        data = data.reshape(num_images, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS)\n        return data\n\n\ndef extract_labels(filename, num_images):\n    \"\"\"Extract the labels into a vector of int64 label IDs.\"\"\"\n    print('Extracting', filename)\n    with gzip.open(filename) as bytestream:\n        bytestream.read(8)\n        buf = bytestream.read(1 * num_images)\n        labels = np.frombuffer(buf, dtype=np.uint8).astype(np.int64)\n    return labels\n\n\ndef fake_data(num_images):\n    \"\"\"Generate a fake dataset that matches the dimensions of MNIST.\"\"\"\n    data = np.ndarray(\n        shape=(num_images, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS),\n        dtype=np.float32)\n    labels = np.zeros(shape=(num_images,), dtype=np.int64)\n    for image in range(num_images):\n        label = image % 2\n        data[image, :, :, 0] = label - 0.5\n        labels[image] = label\n    return data, labels\n\n\ndef error_rate(predictions, labels):\n    \"\"\"Return the error rate based on dense predictions and sparse labels.\"\"\"\n    return 100.0 - (\n        100.0 *\n        np.sum(np.argmax(predictions, 1) == labels) /\n        predictions.shape[0])\n\n\ndef main(argv=None):  # pylint: disable=unused-argument\n    if FLAGS.self_test:\n        print('Running self-test.')\n        train_data, train_labels = fake_data(256)\n        validation_data, validation_labels = fake_data(EVAL_BATCH_SIZE)\n        test_data, test_labels = fake_data(EVAL_BATCH_SIZE)\n        num_epochs = 1\n    else:\n        # Get the data.\n        train_data_filename = maybe_download('train-images-idx3-ubyte.gz')\n        train_labels_filename = maybe_download('train-labels-idx1-ubyte.gz')\n        test_data_filename = maybe_download('t10k-images-idx3-ubyte.gz')\n        test_labels_filename = maybe_download('t10k-labels-idx1-ubyte.gz')\n    \n        # Extract it into numpy arrays.\n        train_data = extract_data(train_data_filename, 60000)\n        train_labels = extract_labels(train_labels_filename, 60000)\n        test_data = extract_data(test_data_filename, 10000)\n        test_labels = extract_labels(test_labels_filename, 10000)\n    \n        # Generate a validation set.\n        validation_data = train_data[:VALIDATION_SIZE, ...]\n        validation_labels = train_labels[:VALIDATION_SIZE]\n        train_data = train_data[VALIDATION_SIZE:, ...]\n        train_labels = train_labels[VALIDATION_SIZE:]\n        nrof_training_examples = train_labels.shape[0]\n        nrof_changed_labels = int(nrof_training_examples*NOISE_FACTOR)\n        shuf = np.arange(0,nrof_training_examples)\n        np.random.shuffle(shuf)\n        change_idx = shuf[0:nrof_changed_labels]\n        train_labels[change_idx] = (train_labels[change_idx] + np.random.randint(1,9,size=(nrof_changed_labels,))) % NUM_LABELS\n        num_epochs = NUM_EPOCHS\n    train_size = train_labels.shape[0]\n\n    # This is where training samples and labels are fed to the graph.\n    # These placeholder nodes will be fed a batch of training data at each\n    # training step using the {feed_dict} argument to the Run() call below.\n    train_data_node = tf.placeholder(\n        data_type(),\n        shape=(BATCH_SIZE, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS))\n    train_labels_node = tf.placeholder(tf.int64, shape=(BATCH_SIZE,))\n    eval_data = tf.placeholder(\n        data_type(),\n        shape=(EVAL_BATCH_SIZE, IMAGE_SIZE, IMAGE_SIZE, NUM_CHANNELS))\n\n    # The variables below hold all the trainable weights. They are passed an\n    # initial value which will be assigned when we call:\n    # {tf.global_variables_initializer().run()}\n    conv1_weights = tf.Variable(\n        tf.truncated_normal([5, 5, NUM_CHANNELS, 32],  # 5x5 filter, depth 32.\n                            stddev=0.1,\n                            seed=SEED, dtype=data_type()))\n    conv1_biases = tf.Variable(tf.zeros([32], dtype=data_type()))\n    conv2_weights = tf.Variable(tf.truncated_normal(\n        [5, 5, 32, 64], stddev=0.1,\n        seed=SEED, dtype=data_type()))\n    conv2_biases = tf.Variable(tf.constant(0.1, shape=[64], dtype=data_type()))\n    fc1_weights = tf.Variable(  # fully connected, depth 512.\n        tf.truncated_normal([IMAGE_SIZE // 4 * IMAGE_SIZE // 4 * 64, 512],\n                            stddev=0.1,\n                            seed=SEED,\n                            dtype=data_type()))\n    fc1_biases = tf.Variable(tf.constant(0.1, shape=[512], dtype=data_type()))\n    fc2_weights = tf.Variable(tf.truncated_normal([512, NUM_LABELS],\n                                                  stddev=0.1,\n                                                  seed=SEED,\n                                                  dtype=data_type()))\n    fc2_biases = tf.Variable(tf.constant(\n        0.1, shape=[NUM_LABELS], dtype=data_type()))\n\n    # We will replicate the model structure for the training subgraph, as well\n    # as the evaluation subgraphs, while sharing the trainable parameters.\n    def model(data, train=False):\n        \"\"\"The Model definition.\"\"\"\n        # 2D convolution, with 'SAME' padding (i.e. the output feature map has\n        # the same size as the input). Note that {strides} is a 4D array whose\n        # shape matches the data layout: [image index, y, x, depth].\n        conv = tf.nn.conv2d(data,\n                            conv1_weights,\n                            strides=[1, 1, 1, 1],\n                            padding='SAME')\n        # Bias and rectified linear non-linearity.\n        relu = tf.nn.relu(tf.nn.bias_add(conv, conv1_biases))\n        # Max pooling. The kernel size spec {ksize} also follows the layout of\n        # the data. Here we have a pooling window of 2, and a stride of 2.\n        pool = tf.nn.max_pool(relu,\n                              ksize=[1, 2, 2, 1],\n                              strides=[1, 2, 2, 1],\n                              padding='SAME')\n        conv = tf.nn.conv2d(pool,\n                            conv2_weights,\n                            strides=[1, 1, 1, 1],\n                            padding='SAME')\n        relu = tf.nn.relu(tf.nn.bias_add(conv, conv2_biases))\n        pool = tf.nn.max_pool(relu,\n                              ksize=[1, 2, 2, 1],\n                              strides=[1, 2, 2, 1],\n                              padding='SAME')\n        # Reshape the feature map cuboid into a 2D matrix to feed it to the\n        # fully connected layers.\n        pool_shape = pool.get_shape().as_list() #pylint: disable=no-member\n        reshape = tf.reshape(\n            pool,\n            [pool_shape[0], pool_shape[1] * pool_shape[2] * pool_shape[3]])\n        # Fully connected layer. Note that the '+' operation automatically\n        # broadcasts the biases.\n        hidden = tf.nn.relu(tf.matmul(reshape, fc1_weights) + fc1_biases)\n\n        # Add a 50% dropout during training only. Dropout also scales\n        # activations such that no rescaling is needed at evaluation time.\n        if train:\n            hidden = tf.nn.dropout(hidden, 0.5, seed=SEED)\n        return tf.matmul(hidden, fc2_weights) + fc2_biases\n\n    # Training computation: logits + cross-entropy loss.\n    logits = model(train_data_node, True)\n    \n    # t: observed noisy labels\n    # q: estimated class probabilities (output from softmax)\n    # z: argmax of q\n\n    t = tf.one_hot(train_labels_node, NUM_LABELS)\n    q = tf.nn.softmax(logits)\n    qqq = tf.arg_max(q, dimension=1)\n    z = tf.one_hot(qqq, NUM_LABELS)\n    #cross_entropy = -tf.reduce_sum(t*tf.log(q),reduction_indices=1)\n    cross_entropy = -tf.reduce_sum((BETA*t+(1-BETA)*z)*tf.log(q),reduction_indices=1)\n    \n    loss = tf.reduce_mean(cross_entropy)\n    \n#     loss = tf.reduce_mean(tf.nn.sparse_softmax_cross_entropy_with_logits(\n#         logits, train_labels_node))\n  \n    # L2 regularization for the fully connected parameters.\n    regularizers = (tf.nn.l2_loss(fc1_weights) + tf.nn.l2_loss(fc1_biases) +\n                    tf.nn.l2_loss(fc2_weights) + tf.nn.l2_loss(fc2_biases))\n    # Add the regularization term to the loss.\n    loss += 5e-4 * regularizers\n  \n    # Optimizer: set up a variable that's incremented once per batch and\n    # controls the learning rate decay.\n    batch = tf.Variable(0, dtype=data_type())\n    # Decay once per epoch, using an exponential schedule starting at 0.01.\n    learning_rate = tf.train.exponential_decay(\n        0.01,                # Base learning rate.\n        batch * BATCH_SIZE,  # Current index into the dataset.\n        train_size,          # Decay step.\n        0.95,                # Decay rate.\n        staircase=True)\n    # Use simple momentum for the optimization.\n    optimizer = tf.train.MomentumOptimizer(learning_rate,\n                                           0.9).minimize(loss,\n                                                         global_step=batch)\n  \n    # Predictions for the current training minibatch.\n    train_prediction = tf.nn.softmax(logits)\n  \n    # Predictions for the test and validation, which we'll compute less often.\n    eval_prediction = tf.nn.softmax(model(eval_data))\n    \n    # Small utility function to evaluate a dataset by feeding batches of data to\n    # {eval_data} and pulling the results from {eval_predictions}.\n    # Saves memory and enables this to run on smaller GPUs.\n    def eval_in_batches(data, sess):\n        \"\"\"Get all predictions for a dataset by running it in small batches.\"\"\"\n        size = data.shape[0]\n        if size < EVAL_BATCH_SIZE:\n            raise ValueError(\"batch size for evals larger than dataset: %d\" % size)\n        predictions = np.ndarray(shape=(size, NUM_LABELS), dtype=np.float32)\n        for begin in xrange(0, size, EVAL_BATCH_SIZE):\n            end = begin + EVAL_BATCH_SIZE\n            if end <= size:\n                predictions[begin:end, :] = sess.run(\n                    eval_prediction,\n                    feed_dict={eval_data: data[begin:end, ...]})\n            else:\n                batch_predictions = sess.run(\n                    eval_prediction,\n                    feed_dict={eval_data: data[-EVAL_BATCH_SIZE:, ...]})\n                predictions[begin:, :] = batch_predictions[begin - size:, :]\n        return predictions\n  \n    # Create a local session to run the training.\n    start_time = time.time()\n    with tf.Session() as sess:\n        # Run all the initializers to prepare the trainable parameters.\n        tf.global_variables_initializer().run() #pylint: disable=no-member\n        print('Initialized!')\n        # Loop through training steps.\n        for step in xrange(int(num_epochs * train_size) // BATCH_SIZE):\n            # Compute the offset of the current minibatch in the data.\n            # Note that we could use better randomization across epochs.\n            offset = (step * BATCH_SIZE) % (train_size - BATCH_SIZE)\n            batch_data = train_data[offset:(offset + BATCH_SIZE), ...]\n            batch_labels = train_labels[offset:(offset + BATCH_SIZE)]\n            # This dictionary maps the batch data (as a numpy array) to the\n            # node in the graph it should be fed to.\n            feed_dict = {train_data_node: batch_data,\n                         train_labels_node: batch_labels}\n            # Run the graph and fetch some of the nodes.\n            _, l, lr, predictions = sess.run(\n                [optimizer, loss, learning_rate, train_prediction],\n                feed_dict=feed_dict)\n            if step % EVAL_FREQUENCY == 0:\n                elapsed_time = time.time() - start_time\n                start_time = time.time()\n                print('Step %d (epoch %.2f), %.1f ms' %\n                      (step, float(step) * BATCH_SIZE / train_size,\n                       1000 * elapsed_time / EVAL_FREQUENCY))\n                print('Minibatch loss: %.3f, learning rate: %.6f' % (l, lr))\n                print('Minibatch error: %.1f%%' % error_rate(predictions, batch_labels))\n                print('Validation error: %.1f%%' % error_rate(\n                    eval_in_batches(validation_data, sess), validation_labels))\n                sys.stdout.flush()\n        # Finally print the result!\n        test_error = error_rate(eval_in_batches(test_data, sess), test_labels)\n        print('Test error: %.1f%%' % test_error)\n        if FLAGS.self_test:\n            print('test_error', test_error)\n            assert test_error == 0.0, 'expected 0.0 test_error, got %.2f' % (\n                test_error,)\n\n\nif __name__ == '__main__':\n    tf.app.run()\n"
  },
  {
    "path": "tmp/mtcnn.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport align.detect_face\nfrom scipy import misc\n\nwith tf.Graph().as_default():\n  \n    sess = tf.Session()\n    with sess.as_default():\n        with tf.variable_scope('pnet'):\n            data = tf.placeholder(tf.float32, (None,None,None,3), 'input')\n            pnet = align.detect_face.PNet({'data':data})\n            pnet.load('../../data/det1.npy', sess)\n        with tf.variable_scope('rnet'):\n            data = tf.placeholder(tf.float32, (None,24,24,3), 'input')\n            rnet = align.detect_face.RNet({'data':data})\n            rnet.load('../../data/det2.npy', sess)\n        with tf.variable_scope('onet'):\n            data = tf.placeholder(tf.float32, (None,48,48,3), 'input')\n            onet = align.detect_face.ONet({'data':data})\n            onet.load('../../data/det3.npy', sess)\n            \n        pnet_fun = lambda img : sess.run(('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0':img})\n        rnet_fun = lambda img : sess.run(('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0':img})\n        onet_fun = lambda img : sess.run(('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0'), feed_dict={'onet/input:0':img})\n\nminsize = 20 # minimum size of face\nthreshold = [ 0.6, 0.7, 0.7 ]  # three steps's threshold\nfactor = 0.709 # scale factor\n\nsource_path = '/home/david/datasets/casia/CASIA-maxpy-clean/0000045/002.jpg'\nimg = misc.imread(source_path)\n\nbounding_boxes, points = align.detect_face.detect_face(img, minsize, pnet_fun, rnet_fun, onet_fun, threshold, factor)\n\nprint('Bounding box: %s' % bounding_boxes)\n\n\n"
  },
  {
    "path": "tmp/mtcnn_test.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport align.detect_face\n\ng1 = tf.Graph()\nwith g1.as_default():\n    data = tf.placeholder(tf.float32, (None,None,None,3), 'input')\n    pnet = align.detect_face.PNet({'data':data})\n    sess1 = tf.Session(graph=g1)\n    pnet.load('../../data/det1.npy', sess1)\n    pnet_fun = lambda img : sess1.run(('conv4-2/BiasAdd:0', 'prob1:0'), feed_dict={'input:0':img})\nnp.random.seed(666)\nimg = np.random.rand(1,3,150,150)\nimg = np.transpose(img, (0,2,3,1))\n      \nnp.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n       \n# prob1=sess1.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,0,0,:])\n# conv42=sess1.run('conv4-2/BiasAdd:0', feed_dict={data:img})\n# print(conv42[0,0,0,:])\n      \n# conv42, prob1 = pnet_fun(img)\n# print(prob1[0,0,0,:])\n# print(conv42[0,0,0,:])\n\n\n# [ 0.9929  0.0071] prob1, caffe\n# [ 0.9929  0.0071] prob1, tensorflow\n  \n# [ 0.1207 -0.0116 -0.1231 -0.0463] conv4-2, caffe\n# [ 0.1207 -0.0116 -0.1231 -0.0463] conv4-2, tensorflow\n      \n\ng2 = tf.Graph()\nwith g2.as_default():\n    data = tf.placeholder(tf.float32, (None,24,24,3), 'input')\n    rnet = align.detect_face.RNet({'data':data})\n    sess2 = tf.Session(graph=g2)\n    rnet.load('../../data/det2.npy', sess2)\n    rnet_fun = lambda img : sess2.run(('conv5-2/conv5-2:0', 'prob1:0'), feed_dict={'input:0':img})\nnp.random.seed(666)\nimg = np.random.rand(73,3,24,24)\nimg = np.transpose(img, (0,2,3,1))\n \n# np.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n#  \n# prob1=sess2.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,:])\n# \n# conv52=sess2.run('conv5-2/conv5-2:0', feed_dict={data:img})\n# print(conv52[0,:])\n  \n# [ 0.9945  0.0055] prob1, caffe\n# [ 0.1108 -0.0038 -0.1631 -0.0890] conv5-2, caffe\n \n# [ 0.9945  0.0055] prob1, tensorflow\n# [ 0.1108 -0.0038 -0.1631 -0.0890] conv5-2, tensorflow\n\n    \ng3 = tf.Graph()\nwith g3.as_default():\n    data = tf.placeholder(tf.float32, (None,48,48,3), 'input')\n    onet = align.detect_face.ONet({'data':data})\n    sess3 = tf.Session(graph=g3)\n    onet.load('../../data/det3.npy', sess3)\n    onet_fun = lambda img : sess3.run(('conv6-2/conv6-2:0', 'conv6-3/conv6-3:0', 'prob1:0'), feed_dict={'input:0':img})\nnp.random.seed(666)\nimg = np.random.rand(11,3,48,48)\nimg = np.transpose(img, (0,2,3,1))\n \n# np.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n#  \n# prob1=sess3.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,:])\n# print('prob1, tensorflow')\n# \n# conv62=sess3.run('conv6-2/conv6-2:0', feed_dict={data:img})\n# print(conv62[0,:])\n# print('conv6-2, tensorflow')\n#  \n# conv63=sess3.run('conv6-3/conv6-3:0', feed_dict={data:img})\n# print(conv63[0,:])\n# print('conv6-3, tensorflow')\n\n# [ 0.9988  0.0012] prob1, caffe\n# [ 0.0446 -0.0968 -0.1091 -0.0212] conv6-2, caffe\n# [ 0.2429  0.6104  0.4074  0.3104  0.5939  0.2729  0.2132  0.5462  0.7863  0.7568] conv6-3, caffe\n  \n# [ 0.9988  0.0012] prob1, tensorflow\n# [ 0.0446 -0.0968 -0.1091 -0.0212] conv6-2, tensorflow\n# [ 0.2429  0.6104  0.4074  0.3104  0.5939  0.2729  0.2132  0.5462  0.7863  0.7568] conv6-3, tensorflow\n\n#pnet_fun = lambda img : sess1.run(('conv4-2/BiasAdd:0', 'prob1:0'), feed_dict={'input:0':img})\n\n"
  },
  {
    "path": "tmp/mtcnn_test_pnet_dbg.py",
    "content": "from __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport scipy.io as io\nimport align.detect_face\n\n#ref = io.loadmat('pnet_dbg.mat')\nwith tf.Graph().as_default():\n    sess = tf.Session()\n    with sess.as_default():\n        with tf.variable_scope('pnet'):\n#            data = tf.placeholder(tf.float32, (None,None,None,3), 'input')\n            data = tf.placeholder(tf.float32, (1,1610, 1901,3), 'input')\n            pnet = align.detect_face.PNet({'data':data})\n            pnet.load('../../data/det1.npy', sess)\n#         with tf.variable_scope('rnet'):\n#             data = tf.placeholder(tf.float32, (None,24,24,3), 'input')\n#             rnet = align.detect_face.RNet({'data':data})\n#             rnet.load('../../data/det2.npy', sess)\n#         with tf.variable_scope('onet'):\n#             data = tf.placeholder(tf.float32, (None,48,48,3), 'input')\n#             onet = align.detect_face.ONet({'data':data})\n#             onet.load('../../data/det3.npy', sess)\n            \n        pnet_fun = lambda img : sess.run(('pnet/conv4-2/BiasAdd:0', 'pnet/prob1:0'), feed_dict={'pnet/input:0':img})\n#         rnet_fun = lambda img : sess.run(('rnet/conv5-2/conv5-2:0', 'rnet/prob1:0'), feed_dict={'rnet/input:0':img})\n#         onet_fun = lambda img : sess.run(('onet/conv6-2/conv6-2:0', 'onet/conv6-3/conv6-3:0', 'onet/prob1:0'), feed_dict={'onet/input:0':img})\n        \n        \nref = io.loadmat('pnet_dbg.mat')\n\nimg_x = np.expand_dims(ref['im_data'], 0)\nimg_y = np.transpose(img_x, (0,2,1,3))\nout = pnet_fun(img_y)\nout0 = np.transpose(out[0], (0,2,1,3))\nout1 = np.transpose(out[1], (0,2,1,3))\n\n#np.where(abs(out0[0,:,:,:]-ref['out0'])>1e-18)\nqqq3 = np.where(abs(out1[0,:,:,:]-ref['out1'])>1e-7) # 3390 diffs with softmax2\nprint(qqq3[0].shape)\n      \nnp.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n       \n# prob1=sess1.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,0,0,:])\n# conv42=sess1.run('conv4-2/BiasAdd:0', feed_dict={data:img})\n# print(conv42[0,0,0,:])\n      \n# conv42, prob1 = pnet_fun(img)\n# print(prob1[0,0,0,:])\n# print(conv42[0,0,0,:])\n\n\n# [ 0.9929  0.0071] prob1, caffe\n# [ 0.9929  0.0071] prob1, tensorflow\n  \n# [ 0.1207 -0.0116 -0.1231 -0.0463] conv4-2, caffe\n# [ 0.1207 -0.0116 -0.1231 -0.0463] conv4-2, tensorflow\n      \n\n# g2 = tf.Graph()\n# with g2.as_default():\n#     data = tf.placeholder(tf.float32, (None,24,24,3), 'input')\n#     rnet = align.detect_face.RNet({'data':data})\n#     sess2 = tf.Session(graph=g2)\n#     rnet.load('../../data/det2.npy', sess2)\n#     rnet_fun = lambda img : sess2.run(('conv5-2/conv5-2:0', 'prob1:0'), feed_dict={'input:0':img})\n# np.random.seed(666)\n# img = np.random.rand(73,3,24,24)\n# img = np.transpose(img, (0,2,3,1))\n \n# np.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n#  \n# prob1=sess2.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,:])\n# \n# conv52=sess2.run('conv5-2/conv5-2:0', feed_dict={data:img})\n# print(conv52[0,:])\n  \n# [ 0.9945  0.0055] prob1, caffe\n# [ 0.1108 -0.0038 -0.1631 -0.0890] conv5-2, caffe\n \n# [ 0.9945  0.0055] prob1, tensorflow\n# [ 0.1108 -0.0038 -0.1631 -0.0890] conv5-2, tensorflow\n\n    \n# g3 = tf.Graph()\n# with g3.as_default():\n#     data = tf.placeholder(tf.float32, (None,48,48,3), 'input')\n#     onet = align.detect_face.ONet({'data':data})\n#     sess3 = tf.Session(graph=g3)\n#     onet.load('../../data/det3.npy', sess3)\n#     onet_fun = lambda img : sess3.run(('conv6-2/conv6-2:0', 'conv6-3/conv6-3:0', 'prob1:0'), feed_dict={'input:0':img})\n# np.random.seed(666)\n# img = np.random.rand(11,3,48,48)\n# img = np.transpose(img, (0,2,3,1))\n \n# np.set_printoptions(formatter={'float': '{: 0.4f}'.format})\n#  \n# prob1=sess3.run('prob1:0', feed_dict={data:img})\n# print(prob1[0,:])\n# print('prob1, tensorflow')\n# \n# conv62=sess3.run('conv6-2/conv6-2:0', feed_dict={data:img})\n# print(conv62[0,:])\n# print('conv6-2, tensorflow')\n#  \n# conv63=sess3.run('conv6-3/conv6-3:0', feed_dict={data:img})\n# print(conv63[0,:])\n# print('conv6-3, tensorflow')\n\n# [ 0.9988  0.0012] prob1, caffe\n# [ 0.0446 -0.0968 -0.1091 -0.0212] conv6-2, caffe\n# [ 0.2429  0.6104  0.4074  0.3104  0.5939  0.2729  0.2132  0.5462  0.7863  0.7568] conv6-3, caffe\n  \n# [ 0.9988  0.0012] prob1, tensorflow\n# [ 0.0446 -0.0968 -0.1091 -0.0212] conv6-2, tensorflow\n# [ 0.2429  0.6104  0.4074  0.3104  0.5939  0.2729  0.2132  0.5462  0.7863  0.7568] conv6-3, tensorflow\n\n#pnet_fun = lambda img : sess1.run(('conv4-2/BiasAdd:0', 'prob1:0'), feed_dict={'input:0':img})\n\n"
  },
  {
    "path": "tmp/network.py",
    "content": "\"\"\"Functions for building the face recognition network.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nfrom tensorflow.python.ops import array_ops\nfrom tensorflow.python.ops import control_flow_ops\n\n\ndef conv(inpOp, nIn, nOut, kH, kW, dH, dW, padType, name, phase_train=True, use_batch_norm=True, weight_decay=0.0):\n    with tf.variable_scope(name):\n        l2_regularizer = lambda t: l2_loss(t, weight=weight_decay)\n        kernel = tf.get_variable(\"weights\", [kH, kW, nIn, nOut],\n            initializer=tf.truncated_normal_initializer(stddev=1e-1),\n            regularizer=l2_regularizer, dtype=inpOp.dtype)\n        cnv = tf.nn.conv2d(inpOp, kernel, [1, dH, dW, 1], padding=padType)\n        \n        if use_batch_norm:\n            conv_bn = batch_norm(cnv, phase_train)\n        else:\n            conv_bn = cnv\n        biases = tf.get_variable(\"biases\", [nOut], initializer=tf.constant_initializer(), dtype=inpOp.dtype)\n        bias = tf.nn.bias_add(conv_bn, biases)\n        conv1 = tf.nn.relu(bias)\n    return conv1\n\ndef affine(inpOp, nIn, nOut, name, weight_decay=0.0):\n    with tf.variable_scope(name):\n        l2_regularizer = lambda t: l2_loss(t, weight=weight_decay)\n        weights = tf.get_variable(\"weights\", [nIn, nOut],\n            initializer=tf.truncated_normal_initializer(stddev=1e-1),\n            regularizer=l2_regularizer, dtype=inpOp.dtype)\n        biases = tf.get_variable(\"biases\", [nOut], initializer=tf.constant_initializer(), dtype=inpOp.dtype)\n        affine1 = tf.nn.relu_layer(inpOp, weights, biases)\n    return affine1\n\ndef l2_loss(tensor, weight=1.0, scope=None):\n    \"\"\"Define a L2Loss, useful for regularize, i.e. weight decay.\n    Args:\n      tensor: tensor to regularize.\n      weight: an optional weight to modulate the loss.\n      scope: Optional scope for op_scope.\n    Returns:\n      the L2 loss op.\n    \"\"\"\n    with tf.name_scope(scope):\n        weight = tf.convert_to_tensor(weight,\n                                      dtype=tensor.dtype.base_dtype,\n                                      name='loss_weight')\n        loss = tf.multiply(weight, tf.nn.l2_loss(tensor), name='value')\n    return loss\n\ndef lppool(inpOp, pnorm, kH, kW, dH, dW, padding, name):\n    with tf.variable_scope(name):\n        if pnorm == 2:\n            pwr = tf.square(inpOp)\n        else:\n            pwr = tf.pow(inpOp, pnorm)\n          \n        subsamp = tf.nn.avg_pool(pwr,\n                              ksize=[1, kH, kW, 1],\n                              strides=[1, dH, dW, 1],\n                              padding=padding)\n        subsamp_sum = tf.multiply(subsamp, kH*kW)\n        \n        if pnorm == 2:\n            out = tf.sqrt(subsamp_sum)\n        else:\n            out = tf.pow(subsamp_sum, 1/pnorm)\n    \n    return out\n\ndef mpool(inpOp, kH, kW, dH, dW, padding, name):\n    with tf.variable_scope(name):\n        maxpool = tf.nn.max_pool(inpOp,\n                       ksize=[1, kH, kW, 1],\n                       strides=[1, dH, dW, 1],\n                       padding=padding)  \n    return maxpool\n\ndef apool(inpOp, kH, kW, dH, dW, padding, name):\n    with tf.variable_scope(name):\n        avgpool = tf.nn.avg_pool(inpOp,\n                              ksize=[1, kH, kW, 1],\n                              strides=[1, dH, dW, 1],\n                              padding=padding)\n    return avgpool\n\ndef batch_norm(x, phase_train):\n    \"\"\"\n    Batch normalization on convolutional maps.\n    Args:\n        x:           Tensor, 4D BHWD input maps\n        n_out:       integer, depth of input maps\n        phase_train: boolean tf.Variable, true indicates training phase\n        scope:       string, variable scope\n        affn:      whether to affn-transform outputs\n    Return:\n        normed:      batch-normalized maps\n    Ref: http://stackoverflow.com/questions/33949786/how-could-i-use-batch-normalization-in-tensorflow/33950177\n    \"\"\"\n    name = 'batch_norm'\n    with tf.variable_scope(name):\n        phase_train = tf.convert_to_tensor(phase_train, dtype=tf.bool)\n        n_out = int(x.get_shape()[3])\n        beta = tf.Variable(tf.constant(0.0, shape=[n_out], dtype=x.dtype),\n                           name=name+'/beta', trainable=True, dtype=x.dtype)\n        gamma = tf.Variable(tf.constant(1.0, shape=[n_out], dtype=x.dtype),\n                            name=name+'/gamma', trainable=True, dtype=x.dtype)\n      \n        batch_mean, batch_var = tf.nn.moments(x, [0,1,2], name='moments')\n        ema = tf.train.ExponentialMovingAverage(decay=0.9)\n        def mean_var_with_update():\n            ema_apply_op = ema.apply([batch_mean, batch_var])\n            with tf.control_dependencies([ema_apply_op]):\n                return tf.identity(batch_mean), tf.identity(batch_var)\n        mean, var = control_flow_ops.cond(phase_train,\n                                          mean_var_with_update,\n                                          lambda: (ema.average(batch_mean), ema.average(batch_var)))\n        normed = tf.nn.batch_normalization(x, mean, var, beta, gamma, 1e-3)\n    return normed\n\ndef inception(inp, inSize, ks, o1s, o2s1, o2s2, o3s1, o3s2, o4s1, o4s2, o4s3, poolType, name, \n              phase_train=True, use_batch_norm=True, weight_decay=0.0):\n  \n    print('name = ', name)\n    print('inputSize = ', inSize)\n    print('kernelSize = {3,5}')\n    print('kernelStride = {%d,%d}' % (ks,ks))\n    print('outputSize = {%d,%d}' % (o2s2,o3s2))\n    print('reduceSize = {%d,%d,%d,%d}' % (o2s1,o3s1,o4s2,o1s))\n    print('pooling = {%s, %d, %d, %d, %d}' % (poolType, o4s1, o4s1, o4s3, o4s3))\n    if (o4s2>0):\n        o4 = o4s2\n    else:\n        o4 = inSize\n    print('outputSize = ', o1s+o2s2+o3s2+o4)\n    print()\n    \n    net = []\n    \n    with tf.variable_scope(name):\n        with tf.variable_scope('branch1_1x1'):\n            if o1s>0:\n                conv1 = conv(inp, inSize, o1s, 1, 1, 1, 1, 'SAME', 'conv1x1', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n                net.append(conv1)\n      \n        with tf.variable_scope('branch2_3x3'):\n            if o2s1>0:\n                conv3a = conv(inp, inSize, o2s1, 1, 1, 1, 1, 'SAME', 'conv1x1', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n                conv3 = conv(conv3a, o2s1, o2s2, 3, 3, ks, ks, 'SAME', 'conv3x3', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n                net.append(conv3)\n      \n        with tf.variable_scope('branch3_5x5'):\n            if o3s1>0:\n                conv5a = conv(inp, inSize, o3s1, 1, 1, 1, 1, 'SAME', 'conv1x1', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n                conv5 = conv(conv5a, o3s1, o3s2, 5, 5, ks, ks, 'SAME', 'conv5x5', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n                net.append(conv5)\n      \n        with tf.variable_scope('branch4_pool'):\n            if poolType=='MAX':\n                pool = mpool(inp, o4s1, o4s1, o4s3, o4s3, 'SAME', 'pool')\n            elif poolType=='L2':\n                pool = lppool(inp, 2, o4s1, o4s1, o4s3, o4s3, 'SAME', 'pool')\n            else:\n                raise ValueError('Invalid pooling type \"%s\"' % poolType)\n            \n            if o4s2>0:\n                pool_conv = conv(pool, inSize, o4s2, 1, 1, 1, 1, 'SAME', 'conv1x1', phase_train=phase_train, use_batch_norm=use_batch_norm, weight_decay=weight_decay)\n            else:\n                pool_conv = pool\n            net.append(pool_conv)\n      \n        incept = array_ops.concat(net, 3, name=name)\n    return incept\n"
  },
  {
    "path": "tmp/nn2.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport models.network as network\n\ndef inference(images, keep_probability, phase_train=True, weight_decay=0.0):\n    \"\"\" Define an inference network for face recognition based \n           on inception modules using batch normalization\n    \n    Args:\n      images: The images to run inference on, dimensions batch_size x height x width x channels\n      phase_train: True if batch normalization should operate in training mode\n    \"\"\"\n    endpoints = {}\n    net = network.conv(images, 3, 64, 7, 7, 2, 2, 'SAME', 'conv1_7x7', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv1'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool1')\n    endpoints['pool1'] = net\n    net = network.conv(net,  64, 64, 1, 1, 1, 1, 'SAME', 'conv2_1x1', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv2_1x1'] = net\n    net = network.conv(net,  64, 192, 3, 3, 1, 1, 'SAME', 'conv3_3x3', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv3_3x3'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool3')\n    endpoints['pool3'] = net\n  \n    net = network.inception(net, 192, 1, 64, 96, 128, 16, 32, 3, 32, 1, 'MAX', 'incept3a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3a'] = net\n    net = network.inception(net, 256, 1, 64, 96, 128, 32, 64, 3, 64, 1, 'MAX', 'incept3b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3b'] = net\n    net = network.inception(net, 320, 2, 0, 128, 256, 32, 64, 3, 0, 2, 'MAX', 'incept3c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3c'] = net\n    \n    net = network.inception(net, 640, 1, 256, 96, 192, 32, 64, 3, 128, 1, 'MAX', 'incept4a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4a'] = net\n    net = network.inception(net, 640, 1, 224, 112, 224, 32, 64, 3, 128, 1, 'MAX', 'incept4b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4b'] = net\n    net = network.inception(net, 640, 1, 192, 128, 256, 32, 64, 3, 128, 1, 'MAX', 'incept4c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4c'] = net\n    net = network.inception(net, 640, 1, 160, 144, 288, 32, 64, 3, 128, 1, 'MAX', 'incept4d', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4d'] = net\n    net = network.inception(net, 640, 2, 0, 160, 256, 64, 128, 3, 0, 2, 'MAX', 'incept4e', phase_train=phase_train, use_batch_norm=True)\n    endpoints['incept4e'] = net\n    \n    net = network.inception(net, 1024, 1, 384, 192, 384, 48, 128, 3, 128, 1, 'MAX', 'incept5a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5a'] = net\n    net = network.inception(net, 1024, 1, 384, 192, 384, 48, 128, 3, 128, 1, 'MAX', 'incept5b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5b'] = net\n    net = network.apool(net,  7, 7, 1, 1, 'VALID', 'pool6')\n    endpoints['pool6'] = net\n    net = tf.reshape(net, [-1, 1024])\n    endpoints['prelogits'] = net\n    net = tf.nn.dropout(net, keep_probability)\n    endpoints['dropout'] = net\n    \n    return net, endpoints\n"
  },
  {
    "path": "tmp/nn3.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport models.network as network\n\ndef inference(images, keep_probability, phase_train=True, weight_decay=0.0):\n    \"\"\" Define an inference network for face recognition based \n           on inception modules using batch normalization\n    \n    Args:\n      images: The images to run inference on, dimensions batch_size x height x width x channels\n      phase_train: True if batch normalization should operate in training mode\n    \"\"\"\n    endpoints = {}\n    net = network.conv(images, 3, 64, 7, 7, 2, 2, 'SAME', 'conv1_7x7', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv1'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool1')\n    endpoints['pool1'] = net\n    net = network.conv(net,  64, 64, 1, 1, 1, 1, 'SAME', 'conv2_1x1', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv2_1x1'] = net\n    net = network.conv(net,  64, 192, 3, 3, 1, 1, 'SAME', 'conv3_3x3', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv3_3x3'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool3')\n    endpoints['pool3'] = net\n  \n    net = network.inception(net, 192, 1, 64, 96, 128, 16, 32, 3, 32, 1, 'MAX', 'incept3a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3a'] = net\n    net = network.inception(net, 256, 1, 64, 96, 128, 32, 64, 3, 64, 1, 'MAX', 'incept3b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3b'] = net\n    net = network.inception(net, 320, 2, 0, 128, 256, 32, 64, 3, 0, 2, 'MAX', 'incept3c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3c'] = net\n    \n    net = network.inception(net, 640, 1, 256, 96, 192, 32, 64, 3, 128, 1, 'MAX', 'incept4a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4a'] = net\n    net = network.inception(net, 640, 1, 224, 112, 224, 32, 64, 3, 128, 1, 'MAX', 'incept4b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4b'] = net\n    net = network.inception(net, 640, 1, 192, 128, 256, 32, 64, 3, 128, 1, 'MAX', 'incept4c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4c'] = net\n    net = network.inception(net, 640, 1, 160, 144, 288, 32, 64, 3, 128, 1, 'MAX', 'incept4d', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4d'] = net\n    net = network.inception(net, 640, 2, 0, 160, 256, 64, 128, 3, 0, 2, 'MAX', 'incept4e', phase_train=phase_train, use_batch_norm=True)\n    endpoints['incept4e'] = net\n    \n    net = network.inception(net, 1024, 1, 384, 192, 384, 48, 128, 3, 128, 1, 'MAX', 'incept5a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5a'] = net\n    net = network.inception(net, 1024, 1, 384, 192, 384, 48, 128, 3, 128, 1, 'MAX', 'incept5b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5b'] = net\n    net = network.apool(net,  5, 5, 1, 1, 'VALID', 'pool6')\n    endpoints['pool6'] = net\n    net = tf.reshape(net, [-1, 1024])\n    endpoints['prelogits'] = net\n    net = tf.nn.dropout(net, keep_probability)\n    endpoints['dropout'] = net\n    \n    return net, endpoints\n"
  },
  {
    "path": "tmp/nn4.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport models.network as network\n\ndef inference(images, keep_probability, phase_train=True, weight_decay=0.0):\n    \"\"\" Define an inference network for face recognition based \n           on inception modules using batch normalization\n    \n    Args:\n      images: The images to run inference on, dimensions batch_size x height x width x channels\n      phase_train: True if batch normalization should operate in training mode\n    \"\"\"\n    endpoints = {}\n    net = network.conv(images, 3, 64, 7, 7, 2, 2, 'SAME', 'conv1_7x7', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv1'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool1')\n    endpoints['pool1'] = net\n    net = network.conv(net,  64, 64, 1, 1, 1, 1, 'SAME', 'conv2_1x1', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv2_1x1'] = net\n    net = network.conv(net,  64, 192, 3, 3, 1, 1, 'SAME', 'conv3_3x3', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv3_3x3'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool3')\n    endpoints['pool3'] = net\n  \n    net = network.inception(net, 192, 1, 64, 96, 128, 16, 32, 3, 32, 1, 'MAX', 'incept3a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3a'] = net\n    net = network.inception(net, 256, 1, 64, 96, 128, 32, 64, 3, 64, 1, 'MAX', 'incept3b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3b'] = net\n    net = network.inception(net, 320, 2, 0, 128, 256, 32, 64, 3, 0, 2, 'MAX', 'incept3c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3c'] = net\n    \n    net = network.inception(net, 640, 1, 256, 96, 192, 32, 64, 3, 128, 1, 'MAX', 'incept4a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4a'] = net\n    net = network.inception(net, 640, 1, 224, 112, 224, 32, 64, 3, 128, 1, 'MAX', 'incept4b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4b'] = net\n    net = network.inception(net, 640, 1, 192, 128, 256, 32, 64, 3, 128, 1, 'MAX', 'incept4c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4c'] = net\n    net = network.inception(net, 640, 1, 160, 144, 288, 32, 64, 3, 128, 1, 'MAX', 'incept4d', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4d'] = net\n    net = network.inception(net, 640, 2, 0, 160, 256, 64, 128, 3, 0, 2, 'MAX', 'incept4e', phase_train=phase_train, use_batch_norm=True)\n    endpoints['incept4e'] = net\n    \n    net = network.inception(net, 1024, 1, 384, 192, 384, 0, 0, 3, 128, 1, 'MAX', 'incept5a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5a'] = net\n    net = network.inception(net, 896, 1, 384, 192, 384, 0, 0, 3, 128, 1, 'MAX', 'incept5b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5b'] = net\n    net = network.apool(net,  3, 3, 1, 1, 'VALID', 'pool6')\n    endpoints['pool6'] = net\n    net = tf.reshape(net, [-1, 896])\n    endpoints['prelogits'] = net\n    net = tf.nn.dropout(net, keep_probability)\n    endpoints['dropout'] = net\n    \n    return net, endpoints\n"
  },
  {
    "path": "tmp/nn4_small2_v1.py",
    "content": "# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\n# pylint: disable=missing-docstring\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport models.network as network\n\ndef inference(images, keep_probability, phase_train=True, weight_decay=0.0):\n    \"\"\" Define an inference network for face recognition based \n           on inception modules using batch normalization\n    \n    Args:\n      images: The images to run inference on, dimensions batch_size x height x width x channels\n      phase_train: True if batch normalization should operate in training mode\n    \"\"\"\n    endpoints = {}\n    net = network.conv(images, 3, 64, 7, 7, 2, 2, 'SAME', 'conv1_7x7', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv1'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool1')\n    endpoints['pool1'] = net\n    net = network.conv(net,  64, 64, 1, 1, 1, 1, 'SAME', 'conv2_1x1', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv2_1x1'] = net\n    net = network.conv(net,  64, 192, 3, 3, 1, 1, 'SAME', 'conv3_3x3', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['conv3_3x3'] = net\n    net = network.mpool(net,  3, 3, 2, 2, 'SAME', 'pool3')\n    endpoints['pool3'] = net\n  \n    net = network.inception(net, 192, 1, 64, 96, 128, 16, 32, 3, 32, 1, 'MAX', 'incept3a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3a'] = net\n    net = network.inception(net, 256, 1, 64, 96, 128, 32, 64, 3, 64, 1, 'MAX', 'incept3b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3b'] = net\n    net = network.inception(net, 320, 2, 0, 128, 256, 32, 64, 3, 0, 2, 'MAX', 'incept3c', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept3c'] = net\n    \n    net = network.inception(net, 640, 1, 256, 96, 192, 32, 64, 3, 128, 1, 'MAX', 'incept4a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4a'] = net\n    net = network.inception(net, 640, 2, 0, 160, 256, 64, 128, 3, 0, 2, 'MAX', 'incept4e', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept4e'] = net\n    \n    net = network.inception(net, 1024, 1, 256, 96,  384, 0, 0, 3, 96,  1, 'MAX', 'incept5a', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5a'] = net\n    net = network.inception(net, 736, 1, 256, 96, 384, 0, 0, 3, 96, 1, 'MAX', 'incept5b', phase_train=phase_train, use_batch_norm=True, weight_decay=weight_decay)\n    endpoints['incept5b'] = net\n    net = network.apool(net,  3, 3, 1, 1, 'VALID', 'pool6')\n    endpoints['pool6'] = net\n    net = tf.reshape(net, [-1, 736])\n    endpoints['prelogits'] = net\n    net = tf.nn.dropout(net, keep_probability)\n    endpoints['dropout'] = net\n    \n    return net, endpoints\n  "
  },
  {
    "path": "tmp/random_test.py",
    "content": "import tensorflow as tf\nimport numpy as np\nfrom six.moves import xrange\n\n\nwith tf.Graph().as_default():\n  tf.set_random_seed(666)\n\n\n  # Placeholder for input images\n  input_placeholder = tf.placeholder(tf.float32, shape=(9, 7), name='input')\n  \n  # Split example embeddings into anchor, positive and negative\n  #anchor, positive, negative = tf.split(0, 3, input)\n  resh1 = tf.reshape(input_placeholder, [3,3,7])\n  anchor = resh1[0,:,:]\n  positive = resh1[1,:,:]\n  negative = resh1[2,:,:]\n  \n  # Build an initialization operation to run below.\n  init = tf.global_variables_initializer()\n\n  # Start running operations on the Graph.\n  sess = tf.Session(config=tf.ConfigProto(log_device_placement=False))\n  sess.run(init)\n  \n  with sess.as_default():\n    batch = np.zeros((9,7))\n    batch[0,:] = 1.1\n    batch[1,:] = 2.1\n    batch[2,:] = 3.1\n    batch[3,:] = 1.2\n    batch[4,:] = 2.2\n    batch[5,:] = 3.2\n    batch[6,:] = 1.3\n    batch[7,:] = 2.3\n    batch[8,:] = 3.3\n    feed_dict = {input_placeholder: batch }\n    print(batch)\n    print(sess.run([anchor, positive, negative], feed_dict=feed_dict))\n\n\n\n\n#feed_dict = { images_placeholder: np.zeros((90,96,96,3)), phase_train_placeholder: True }\n#vars_eval  = sess.run(tf.global_variables(), feed_dict=feed_dict)\n#for gt in vars_eval:\n  #print('%.20f' % (np.sum(gt)))\n#for gt, gv in zip(grads_eval, grad_vars):\n  #print('%40s: %.20f' % (gv.op.name, np.sum(gt)))\n\n  \n\n#import h5py\n#myFile = h5py.File('/home/david/repo/TensorFace/network.h5', 'r')\n\n## The '...' means retrieve the whole tensor\n#data = myFile[...]\n#print(data)\n\n\n#import h5py    # HDF5 support\n\n#fileName = \"/home/david/repo/TensorFace/network.h5\"\n#f = h5py.File(fileName,  \"r\")\n##for item in f.keys():\n  ##print item\n#for item in f.values():\n  #print item\n\n\n#import tensorflow as tf\n#import numpy as np\n#import matplotlib.pyplot as plt\n#import math\n#import facenet\n#import os\n#import glob\n#from scipy import misc\n\n#def plot_triplet(apn, idx):\n    #plt.subplot(1,3,1)\n    #plt.imshow(np.multiply(apn[idx*3+0,:,:,:],1/256))\n    #plt.subplot(1,3,2)\n    #plt.imshow(np.multiply(apn[idx*3+1,:,:,:],1/256))\n    #plt.subplot(1,3,3)\n    #plt.imshow(np.multiply(apn[idx*3+2,:,:,:],1/256))\n\n\n#input_image = tf.placeholder(tf.float32, name='input_image')\n#phase_train = tf.placeholder(tf.bool, name='phase_train')\n\n#n_in, n_out = 3, 16\n#ksize = 3\n#stride = 1\n#kernel = tf.Variable(tf.truncated_normal([ksize, ksize, n_in, n_out],\n                                         #stddev=math.sqrt(2/(ksize*ksize*n_out))),\n                     #name='kernel')\n#conv = tf.nn.conv2d(input_image, kernel, [1,stride,stride,1], padding=\"SAME\")\n#conv_bn = facenet.batch_norm(conv, n_out, phase_train)\n#relu = tf.nn.relu(conv_bn)\n\n## Build an initialization operation to run below.\n#init = tf.global_variables_initializer()\n\n## Start running operations on the Graph.\n#sess = tf.Session()\n#sess.run(init)\n\n#path = '/home/david/datasets/fs_aligned/Zooey_Deschanel/'\n#files = glob.glob(os.path.join(path, '*.png'))\n#nrof_samples = 30\n#img_list = [None] * nrof_samples\n#for i in xrange(nrof_samples):\n    #img_list[i] = misc.imread(files[i])\n#images = np.stack(img_list)\n\n#feed_dict = {\n    #input_image: images.astype(np.float32),\n    #phase_train: True\n#}\n\n#out = sess.run([relu], feed_dict=feed_dict)\n#print(out[0].shape)\n\n##print(out)\n\n#plot_triplet(images, 0)\n\n\n\n#import matplotlib.pyplot as plt\n#import numpy as np\n\n#a=[3,4,5,6]\n#b = [1,a[1:3]]\n#print(b)\n\n## Generate some data...\n#x, y = np.meshgrid(np.linspace(-2,2,200), np.linspace(-2,2,200))\n#x, y = x - x.mean(), y - y.mean()\n#z = x * np.exp(-x**2 - y**2)\n#print(z.shape)\n\n## Plot the grid\n#plt.imshow(z)\n#plt.gray()\n#plt.show()\n\n#import numpy as np\n\n#np.random.seed(123)\n#rnd = 1.0*np.random.randint(1,2**32)/2**32\n#print(rnd)\n"
  },
  {
    "path": "tmp/rename_casia_directories.py",
    "content": "import shutil\nimport argparse\nimport os\nimport sys\n\ndef main(args):\n  \n    identity_map = {}\n    with open(os.path.expanduser(args.map_file_name), \"r\") as f:\n        for line in f:\n            fields = line.split(' ')\n            dir_name = fields[0]\n            class_name = fields[1].replace('\\n', '').replace('\\r', '')\n            if class_name not in identity_map.values():\n                identity_map[dir_name] = class_name\n            else:\n                print('Duplicate class names: %s' % class_name)\n            \n    dataset_path_exp = os.path.expanduser(args.dataset_path)\n    dirs = os.listdir(dataset_path_exp)\n    for f in dirs:\n        old_path = os.path.join(dataset_path_exp, f)\n        if f in identity_map:\n            new_path = os.path.join(dataset_path_exp, identity_map[f])\n            if os.path.isdir(old_path):\n                print('Renaming %s to %s' % (old_path, new_path))\n                shutil.move(old_path, new_path)\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('map_file_name', type=str, help='Name of the text file that contains the directory to class name mappings.')\n    parser.add_argument('dataset_path', type=str, help='Path to the dataset directory.')\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/seed_test.py",
    "content": "import tensorflow as tf\nimport numpy as np\nimport sys\nimport time\nsys.path.append('../src')\nimport facenet\nfrom tensorflow.python.ops import control_flow_ops\nfrom tensorflow.python.ops import array_ops\n\nfrom six.moves import xrange\n\ntf.app.flags.DEFINE_integer('batch_size', 90,\n                            \"\"\"Number of images to process in a batch.\"\"\")\ntf.app.flags.DEFINE_integer('image_size', 96,\n                            \"\"\"Image size (height, width) in pixels.\"\"\")\ntf.app.flags.DEFINE_float('alpha', 0.2,\n                          \"\"\"Positive to negative triplet distance margin.\"\"\")\ntf.app.flags.DEFINE_float('learning_rate', 0.1,\n                          \"\"\"Initial learning rate.\"\"\")\ntf.app.flags.DEFINE_float('moving_average_decay', 0.9999,\n                          \"\"\"Expontential decay for tracking of training parameters.\"\"\")\n\nFLAGS = tf.app.flags.FLAGS\n\ndef run_train():\n  \n  with tf.Graph().as_default():\n  \n    # Set the seed for the graph\n    tf.set_random_seed(666)\n\n    # Placeholder for input images\n    images_placeholder = tf.placeholder(tf.float32, shape=(FLAGS.batch_size, FLAGS.image_size, FLAGS.image_size, 3), name='input')\n    \n    # Build the inference graph\n    embeddings = inference_conv_test(images_placeholder)\n    #embeddings = inference_affine_test(images_placeholder)\n    \n    # Split example embeddings into anchor, positive and negative\n    anchor, positive, negative = tf.split(0, 3, embeddings)\n\n    # Alternative implementation of the split operation\n    # This produces the same error\n    #resh1 = tf.reshape(embeddings, [3,int(FLAGS.batch_size/3), 128])\n    #anchor = resh1[0,:,:]\n    #positive = resh1[1,:,:]\n    #negative = resh1[2,:,:]\n    \n    # Calculate triplet loss\n    pos_dist = tf.reduce_sum(tf.square(tf.sub(anchor, positive)), 1)\n    neg_dist = tf.reduce_sum(tf.square(tf.sub(anchor, negative)), 1)\n    basic_loss = tf.add(tf.sub(pos_dist,neg_dist), FLAGS.alpha)\n    loss = tf.reduce_mean(tf.maximum(basic_loss, 0.0), 0)\n\n    # Build a Graph that trains the model with one batch of examples and updates the model parameters\n    opt = tf.train.GradientDescentOptimizer(FLAGS.learning_rate)\n    #opt = tf.train.AdagradOptimizer(FLAGS.learning_rate)  # Optimizer does not seem to matter\n    grads = opt.compute_gradients(loss)\n    train_op = opt.apply_gradients(grads)\n    \n    # Initialize the variables\n    init = tf.global_variables_initializer()\n    \n    # Launch the graph.\n    sess = tf.Session()\n    sess.run(init)\n\n    # Set the numpy seed\n    np.random.seed(666)\n    \n    with sess.as_default():\n      grads_eval = []\n      all_vars = []\n      for step in xrange(1):\n        # Generate some random input data\n        batch = np.random.random((FLAGS.batch_size, FLAGS.image_size, FLAGS.image_size, 3))\n        feed_dict = { images_placeholder: batch }\n        # Get the variables\n        var_names = tf.global_variables()\n        all_vars  += sess.run(var_names, feed_dict=feed_dict)\n        # Get the gradients\n        grad_tensors, grad_vars = zip(*grads)\n        grads_eval  += sess.run(grad_tensors, feed_dict=feed_dict)\n        # Run training\n        sess.run(train_op, feed_dict=feed_dict)\n    \n    sess.close()\n  return (var_names, all_vars, grad_vars, grads_eval)\n\ndef _conv(inpOp, nIn, nOut, kH, kW, dH, dW, padType):\n  kernel = tf.Variable(tf.truncated_normal([kH, kW, nIn, nOut],\n                                           dtype=tf.float32,\n                                           stddev=1e-1), name='weights')\n  conv = tf.nn.conv2d(inpOp, kernel, [1, dH, dW, 1], padding=padType)\n  \n  biases = tf.Variable(tf.constant(0.0, shape=[nOut], dtype=tf.float32),\n                       trainable=True, name='biases')\n  bias = tf.reshape(tf.nn.bias_add(conv, biases), conv.get_shape())\n  conv1 = tf.nn.relu(bias)\n  return conv1\n\ndef _affine(inpOp, nIn, nOut):\n  kernel = tf.Variable(tf.truncated_normal([nIn, nOut],\n                                           dtype=tf.float32,\n                                           stddev=1e-1), name='weights')\n  biases = tf.Variable(tf.constant(0.0, shape=[nOut], dtype=tf.float32),\n                       trainable=True, name='biases')\n  affine1 = tf.nn.relu_layer(inpOp, kernel, biases)\n  return affine1\n  \ndef inference_conv_test(images):\n  conv1 = _conv(images, 3, 64, 7, 7, 2, 2, 'SAME')\n  resh1 = tf.reshape(conv1, [-1, 147456])\n  affn = _affine(resh1, 147456, 128)  # Affine layer not needed to reproduce the error\n  return affn\n\ndef inference_affine_test(images):\n  resh1 = tf.reshape(images, [-1, 27648])\n  affn1 = _affine(resh1, 27648, 1024)\n  affn2 = _affine(affn1, 1024, 1024)\n  affn3 = _affine(affn2, 1024, 1024)\n  affn4 = _affine(affn3, 1024, 128)\n  return affn4\n\n# Run two sessions with the same seed. These runs should produce the same result.\nvar_names1, all_vars1, grad_names1, all_grads1 = run_train()\nvar_names2, all_vars2, grad_names2, all_grads2 = run_train()\n\nall_vars_close = [None] * len(all_vars1)\nfor i in range(len(all_vars1)):\n  all_vars_close[i] = np.allclose(all_vars1[i], all_vars2[i], rtol=1.e-16)\n  print('%d var %s: %s' % (i, var_names1[i].op.name, all_vars_close[i]))\n  \nall_grads_close = [None] * len(all_grads1)\nfor i in range(len(all_grads1)):\n  all_grads_close[i] = np.allclose(all_grads1[i], all_grads2[i], rtol=1.e-16)\n  print('%d grad %s: %s' % (i, grad_names1[i].op.name, all_grads_close[i]))\n\nassert all(all_vars_close), 'Variable values differ between the two sessions (with the same seed)'\nassert all(all_grads_close), 'Gradient values differ between the two sessions (with the same seed)'\n"
  },
  {
    "path": "tmp/select_triplets_test.py",
    "content": "import facenet\nimport numpy as np\nimport tensorflow as tf\n\nFLAGS = tf.app.flags.FLAGS\n\ntf.app.flags.DEFINE_integer('people_per_batch', 45,\n                            \"\"\"Number of people per batch.\"\"\")\ntf.app.flags.DEFINE_integer('alpha', 0.2,\n                            \"\"\"Positive to negative triplet distance margin.\"\"\")\n\n\nembeddings = np.zeros((1800,128))\n\nnp.random.seed(123)\nfor ix in range(embeddings.shape[0]):\n    for jx in range(embeddings.shape[1]):\n        rnd = 1.0*np.random.randint(1,2**32)/2**32\n        embeddings[ix][jx] = rnd\n\n\nemb_array = embeddings\nimage_data = np.zeros((1800,96,96,3))\n\n\nnum_per_class = [40 for i in range(45)]\n\n\nnp.random.seed(123)\napn, nrof_random_negs, nrof_triplets = facenet.select_triplets(emb_array, num_per_class, image_data)\n"
  },
  {
    "path": "tmp/test1.py",
    "content": "print('Hello world')\n"
  },
  {
    "path": "tmp/test_align.py",
    "content": "import facenet\nimport os\nimport matplotlib.pyplot as plt\nimport numpy as np\n\n\ndef main():\n    image_size = 96\n    old_dataset = '/home/david/datasets/facescrub/fs_aligned_new_oean/'\n    new_dataset = '/home/david/datasets/facescrub/facescrub_110_96/'\n    eq = 0\n    num = 0\n    l = []\n    dataset = facenet.get_dataset(old_dataset)\n    for cls in dataset:\n        new_class_dir = os.path.join(new_dataset, cls.name)\n        for image_path in cls.image_paths:\n          try:\n            filename = os.path.splitext(os.path.split(image_path)[1])[0]\n            new_filename = os.path.join(new_class_dir, filename+'.png')\n            #print(image_path)\n            if os.path.exists(new_filename):\n                a = facenet.load_data([image_path, new_filename], False, False, image_size, do_prewhiten=False)\n                if np.array_equal(a[0], a[1]):\n                  eq+=1\n                num+=1\n                err = np.sum(np.square(np.subtract(a[0], a[1])))\n                #print(err)\n                l.append(err)\n                if err>2000:\n                  fig = plt.figure(1)\n                  p1 = fig.add_subplot(121)\n                  p1.imshow(a[0])\n                  p2 = fig.add_subplot(122)\n                  p2.imshow(a[1])\n                  print('%6.1f: %s\\n' % (err, new_filename))\n                  pass\n            else:\n                pass\n                #print('File not found: %s' % new_filename)\n          except:\n            pass\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "tmp/test_invariance_on_lfw.py",
    "content": "\"\"\"Test invariance to translation, scaling and rotation on the \"Labeled Faces in the Wild\" dataset (http://vis-www.cs.umass.edu/lfw/).\nThis requires test images to be cropped a bit wider than the normal to give some room for the transformations.\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport tensorflow as tf\nimport numpy as np\nimport argparse\nimport facenet\nimport lfw\nimport matplotlib.pyplot as plt\nfrom scipy import misc\nimport os\nimport sys\nimport math\n\ndef main(args):\n    \n    pairs = lfw.read_pairs(os.path.expanduser(args.lfw_pairs))\n    paths, actual_issame = lfw.get_paths(os.path.expanduser(args.lfw_dir), pairs)\n    result_dir = '../data/'\n    plt.ioff()  # Disable interactive plotting mode\n    \n    with tf.Graph().as_default():\n\n        with tf.Session() as sess:\n    \n            # Load the model\n            print('Loading model \"%s\"' % args.model_file)\n            facenet.load_model(args.model_file)\n            \n            # Get input and output tensors\n            images_placeholder = tf.get_default_graph().get_tensor_by_name(\"input:0\")\n            phase_train_placeholder = tf.get_default_graph().get_tensor_by_name(\"phase_train:0\")\n            embeddings = tf.get_default_graph().get_tensor_by_name(\"embeddings:0\")\n            image_size = int(images_placeholder.get_shape()[1])\n            \n            # Run test on LFW to check accuracy for different horizontal/vertical translations of input images\n            if args.nrof_offsets>0:\n                step = 3\n                offsets = np.asarray([x*step for x in range(-args.nrof_offsets//2+1, args.nrof_offsets//2+1)])\n                horizontal_offset_accuracy = [None] * len(offsets)\n                for idx, offset in enumerate(offsets):\n                    accuracy = evaluate_accuracy(sess, images_placeholder, phase_train_placeholder, image_size, embeddings, \n                        paths, actual_issame, translate_images, (offset,0), 60, args.orig_image_size, args.seed)\n                    print('Hoffset: %1.3f  Accuracy: %1.3f+-%1.3f' % (offset, np.mean(accuracy), np.std(accuracy)))\n                    horizontal_offset_accuracy[idx] = np.mean(accuracy)\n                vertical_offset_accuracy = [None] * len(offsets)\n                for idx, offset in enumerate(offsets):\n                    accuracy = evaluate_accuracy(sess, images_placeholder, phase_train_placeholder, image_size, embeddings, \n                        paths, actual_issame, translate_images, (0,offset), 60, args.orig_image_size, args.seed)\n                    print('Voffset: %1.3f  Accuracy: %1.3f+-%1.3f' % (offset, np.mean(accuracy), np.std(accuracy)))\n                    vertical_offset_accuracy[idx] = np.mean(accuracy)\n                fig = plt.figure(1)\n                plt.plot(offsets, horizontal_offset_accuracy, label='Horizontal')\n                plt.plot(offsets, vertical_offset_accuracy, label='Vertical')\n                plt.legend()\n                plt.grid(True)\n                plt.title('Translation invariance on LFW')\n                plt.xlabel('Offset [pixels]')\n                plt.ylabel('Accuracy')\n#                plt.show()\n                print('Saving results in %s' % result_dir)\n                fig.savefig(os.path.join(result_dir, 'invariance_translation.png'))\n                save_result(offsets, horizontal_offset_accuracy, os.path.join(result_dir, 'invariance_translation_horizontal.txt'))\n                save_result(offsets, vertical_offset_accuracy, os.path.join(result_dir, 'invariance_translation_vertical.txt'))\n\n            # Run test on LFW to check accuracy for different rotation of input images\n            if args.nrof_angles>0:\n                step = 3\n                angles = np.asarray([x*step for x in range(-args.nrof_offsets//2+1, args.nrof_offsets//2+1)])\n                rotation_accuracy = [None] * len(angles)\n                for idx, angle in enumerate(angles):\n                    accuracy = evaluate_accuracy(sess, images_placeholder, phase_train_placeholder, image_size, embeddings, \n                        paths, actual_issame, rotate_images, angle, 60, args.orig_image_size, args.seed)\n                    print('Angle: %1.3f  Accuracy: %1.3f+-%1.3f' % (angle, np.mean(accuracy), np.std(accuracy)))\n                    rotation_accuracy[idx] = np.mean(accuracy)\n                fig = plt.figure(2)\n                plt.plot(angles, rotation_accuracy)\n                plt.grid(True)\n                plt.title('Rotation invariance on LFW')\n                plt.xlabel('Angle [deg]')\n                plt.ylabel('Accuracy')\n#                plt.show()\n                print('Saving results in %s' % result_dir)\n                fig.savefig(os.path.join(result_dir, 'invariance_rotation.png'))\n                save_result(angles, rotation_accuracy, os.path.join(result_dir, 'invariance_rotation.txt'))\n\n            # Run test on LFW to check accuracy for different scaling of input images\n            if args.nrof_scales>0:\n                step = 0.05\n                scales = np.asarray([x*step+1 for x in range(-args.nrof_offsets//2+1, args.nrof_offsets//2+1)])\n                scale_accuracy = [None] * len(scales)\n                for scale_idx, scale in enumerate(scales):\n                    accuracy = evaluate_accuracy(sess, images_placeholder, phase_train_placeholder, image_size, embeddings, \n                        paths, actual_issame, scale_images, scale, 60, args.orig_image_size, args.seed)\n                    print('Scale: %1.3f  Accuracy: %1.3f+-%1.3f' % (scale, np.mean(accuracy), np.std(accuracy)))\n                    scale_accuracy[scale_idx] = np.mean(accuracy)\n                fig = plt.figure(3)\n                plt.plot(scales, scale_accuracy)\n                plt.grid(True)\n                plt.title('Scale invariance on LFW')\n                plt.xlabel('Scale')\n                plt.ylabel('Accuracy')\n#                plt.show()\n                print('Saving results in %s' % result_dir)\n                fig.savefig(os.path.join(result_dir, 'invariance_scale.png'))\n                save_result(scales, scale_accuracy, os.path.join(result_dir, 'invariance_scale.txt'))\n                \ndef save_result(aug, acc, filename):\n    with open(filename, \"w\") as f:\n        for i in range(aug.size):\n            f.write('%6.4f %6.4f\\n' % (aug[i], acc[i]))\n            \ndef evaluate_accuracy(sess, images_placeholder, phase_train_placeholder, image_size, embeddings, \n        paths, actual_issame, augment_images, aug_value, batch_size, orig_image_size, seed):\n    nrof_images = len(paths)\n    nrof_batches = int(math.ceil(1.0*nrof_images / batch_size))\n    emb_list = []\n    for i in range(nrof_batches):\n        start_index = i*batch_size\n        end_index = min((i+1)*batch_size, nrof_images)\n        paths_batch = paths[start_index:end_index]\n        images = facenet.load_data(paths_batch, False, False, orig_image_size)\n        images_aug = augment_images(images, aug_value, image_size)\n        feed_dict = { images_placeholder: images_aug, phase_train_placeholder: False }\n        emb_list += sess.run([embeddings], feed_dict=feed_dict)\n    emb_array = np.vstack(emb_list)  # Stack the embeddings to a nrof_examples_per_epoch x 128 matrix\n    \n    thresholds = np.arange(0, 4, 0.01)\n    embeddings1 = emb_array[0::2]\n    embeddings2 = emb_array[1::2]\n    _, _, accuracy = facenet.calculate_roc(thresholds, embeddings1, embeddings2, np.asarray(actual_issame), seed)\n    return accuracy\n\ndef scale_images(images, scale, image_size):\n    images_scale_list = [None] * images.shape[0]\n    for i in range(images.shape[0]):\n        images_scale_list[i] = misc.imresize(images[i,:,:,:], scale)\n    images_scale = np.stack(images_scale_list,axis=0)\n    sz1 = images_scale.shape[1]/2\n    sz2 = image_size/2\n    images_crop = images_scale[:,(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]\n    return images_crop\n\ndef rotate_images(images, angle, image_size):\n    images_list = [None] * images.shape[0]\n    for i in range(images.shape[0]):\n        images_list[i] = misc.imrotate(images[i,:,:,:], angle)\n    images_rot = np.stack(images_list,axis=0)\n    sz1 = images_rot.shape[1]/2\n    sz2 = image_size/2\n    images_crop = images_rot[:,(sz1-sz2):(sz1+sz2),(sz1-sz2):(sz1+sz2),:]\n    return images_crop\n\ndef translate_images(images, offset, image_size):\n    h, v = offset\n    sz1 = images.shape[1]/2\n    sz2 = image_size/2\n    images_crop = images[:,(sz1-sz2+v):(sz1+sz2+v),(sz1-sz2+h):(sz1+sz2+h),:]\n    return images_crop\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('--model_file', type=str, \n        help='File containing the model parameters as well as the model metagraph (with extension \".meta\")', \n        default='~/models/facenet/20160514-234418/model.ckpt-500000')\n    parser.add_argument('--nrof_offsets', type=int,\n        help='Number of horizontal and vertical offsets to evaluate.', default=21)\n    parser.add_argument('--nrof_angles', type=int,\n        help='Number of angles to evaluate.', default=21)\n    parser.add_argument('--nrof_scales', type=int,\n        help='Number of scales to evaluate.', default=21)\n    parser.add_argument('--lfw_pairs', type=str,\n        help='The file containing the pairs to use for validation.', default='../data/pairs.txt')\n    parser.add_argument('--lfw_dir', type=str,\n        help='Path to the data directory containing aligned face patches.', default='~/datasets/lfw/lfw_realigned/')\n    parser.add_argument('--orig_image_size', type=int,\n        help='Image size (height, width) in pixels of the original (uncropped/unscaled) images.', default=224)\n    parser.add_argument('--lfw_nrof_folds', type=int,\n        help='Number of folds to use for cross validation. Mainly used for testing.', default=10)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    return parser.parse_args(argv)\n\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/vggface16.py",
    "content": "\"\"\"Load the VGG Face model into TensorFlow.\nDownload the model from http://www.robots.ox.ac.uk/~vgg/software/vgg_face/\nand point to the file 'vgg_face.mat'\n\"\"\"\nimport numpy as np\nfrom scipy import io\nimport tensorflow as tf\n\ndef load(filename, images):\n    #filename = '../data/vgg_face_matconvnet/data/vgg_face.mat'\n    vgg16 = io.loadmat(filename)\n    vgg16Layers = vgg16['net'][0][0]['layers']\n    \n    # A function to get the weights of the VGG layers\n    def vbbWeights(layerNumber):\n        W = vgg16Layers[0][layerNumber][0][0][2][0][0]\n        W = tf.constant(W)\n        return W\n     \n    def vbbConstants(layerNumber):\n        b = vgg16Layers[0][layerNumber][0][0][2][0][1].T\n        b = tf.constant(np.reshape(b, (b.size)))\n        return b\n    \n    modelGraph = {}\n    modelGraph['input'] = images\n    \n    modelGraph['conv1_1'] = tf.nn.conv2d(modelGraph['input'], filter = vbbWeights(0), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu1_1'] = tf.nn.relu(modelGraph['conv1_1'] + vbbConstants(0))\n    modelGraph['conv1_2'] = tf.nn.conv2d(modelGraph['relu1_1'], filter = vbbWeights(2), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu1_2'] = tf.nn.relu(modelGraph['conv1_2'] + vbbConstants(2))\n    modelGraph['pool1'] = tf.nn.max_pool(modelGraph['relu1_2'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    modelGraph['conv2_1'] = tf.nn.conv2d(modelGraph['pool1'], filter = vbbWeights(5), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu2_1'] = tf.nn.relu(modelGraph['conv2_1'] + vbbConstants(5))\n    modelGraph['conv2_2'] = tf.nn.conv2d(modelGraph['relu2_1'], filter = vbbWeights(7), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu2_2'] = tf.nn.relu(modelGraph['conv2_2'] + vbbConstants(7))\n    modelGraph['pool2'] = tf.nn.max_pool(modelGraph['relu2_2'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    modelGraph['conv3_1'] = tf.nn.conv2d(modelGraph['pool2'], filter = vbbWeights(10), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu3_1'] = tf.nn.relu(modelGraph['conv3_1'] + vbbConstants(10))\n    modelGraph['conv3_2'] = tf.nn.conv2d(modelGraph['relu3_1'], filter = vbbWeights(12), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu3_2'] = tf.nn.relu(modelGraph['conv3_2'] + vbbConstants(12))\n    modelGraph['conv3_3'] = tf.nn.conv2d(modelGraph['relu3_2'], filter = vbbWeights(14), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu3_3'] = tf.nn.relu(modelGraph['conv3_3'] + vbbConstants(14))\n    modelGraph['pool3'] = tf.nn.max_pool(modelGraph['relu3_3'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    modelGraph['conv4_1'] = tf.nn.conv2d(modelGraph['pool3'], filter = vbbWeights(17), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu4_1'] = tf.nn.relu(modelGraph['conv4_1'] + vbbConstants(17))\n    modelGraph['conv4_2'] = tf.nn.conv2d(modelGraph['relu4_1'], filter = vbbWeights(19), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu4_2'] = tf.nn.relu(modelGraph['conv4_2'] + vbbConstants(19))\n    modelGraph['conv4_3'] = tf.nn.conv2d(modelGraph['relu4_2'], filter = vbbWeights(21), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu4_3'] = tf.nn.relu(modelGraph['conv4_3'] + vbbConstants(21))\n    modelGraph['pool4'] = tf.nn.max_pool(modelGraph['relu4_3'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    modelGraph['conv5_1'] = tf.nn.conv2d(modelGraph['pool4'], filter = vbbWeights(24), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu5_1'] = tf.nn.relu(modelGraph['conv5_1'] + vbbConstants(24))\n    modelGraph['conv5_2'] = tf.nn.conv2d(modelGraph['relu5_1'], filter = vbbWeights(26), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu5_2'] = tf.nn.relu(modelGraph['conv5_2'] + vbbConstants(26))\n    modelGraph['conv5_3'] = tf.nn.conv2d(modelGraph['relu5_2'], filter = vbbWeights(28), strides = [1, 1, 1, 1], padding = 'SAME')\n    modelGraph['relu5_3'] = tf.nn.relu(modelGraph['conv5_3'] + vbbConstants(28))\n    modelGraph['pool5'] = tf.nn.max_pool(modelGraph['relu5_3'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    modelGraph['resh1'] = tf.reshape(modelGraph['pool5'], [-1, 25088])\n    modelGraph['fc6'] = tf.nn.relu_layer(modelGraph['resh1'], tf.reshape(vbbWeights(31), [25088, 4096]), vbbConstants(31))\n    modelGraph['dropout1'] = tf.nn.dropout(modelGraph['fc6'], 0.5)\n    modelGraph['fc7'] = tf.nn.relu_layer(modelGraph['dropout1'], tf.squeeze(vbbWeights(34), [0, 1]), vbbConstants(34))\n    modelGraph['dropout2'] = tf.nn.dropout(modelGraph['fc7'], 0.5)\n    modelGraph['fc8'] = tf.nn.relu_layer(modelGraph['dropout2'], tf.squeeze(vbbWeights(37), [0, 1]), vbbConstants(37))\n\n    return modelGraph\n"
  },
  {
    "path": "tmp/vggverydeep19.py",
    "content": "\"\"\"Load the VGG imagenet model into TensorFlow.\nDownload the model from http://www.robots.ox.ac.uk/~vgg/research/very_deep/\nand point to the file 'imagenet-vgg-verydeep-19.mat'\n\"\"\"\nimport numpy as np\nfrom scipy import io\nimport tensorflow as tf\n\ndef load(filename, images):\n    vgg19 = io.loadmat(filename)\n    vgg19Layers = vgg19['layers']\n    \n    # A function to get the weights of the VGG layers\n    def vbbWeights(layerNumber):\n        W = vgg19Layers[0][layerNumber][0][0][2][0][0]\n        W = tf.constant(W)\n        return W\n      \n    def vbbConstants(layerNumber):\n        b = vgg19Layers[0][layerNumber][0][0][2][0][1].T\n        b = tf.constant(np.reshape(b, (b.size)))\n        return b\n    \n    modelGraph = {}\n    modelGraph['input'] = images\n    modelGraph['conv1_1'] = tf.nn.relu(tf.nn.conv2d(modelGraph['input'], filter = vbbWeights(0), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(0))\n    modelGraph['conv1_2'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv1_1'], filter = vbbWeights(2), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(2))\n    modelGraph['avgpool1'] = tf.nn.avg_pool(modelGraph['conv1_2'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    modelGraph['conv2_1'] = tf.nn.relu(tf.nn.conv2d(modelGraph['avgpool1'], filter = vbbWeights(5), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(5))\n    modelGraph['conv2_2'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv2_1'], filter = vbbWeights(7), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(7))\n    modelGraph['avgpool2'] = tf.nn.avg_pool(modelGraph['conv2_2'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    modelGraph['conv3_1'] = tf.nn.relu(tf.nn.conv2d(modelGraph['avgpool2'], filter = vbbWeights(10), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(10))\n    modelGraph['conv3_2'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv3_1'], filter = vbbWeights(12), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(12))\n    modelGraph['conv3_3'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv3_2'], filter = vbbWeights(14), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(14))\n    modelGraph['conv3_4'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv3_3'], filter = vbbWeights(16), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(16))\n    modelGraph['avgpool3'] = tf.nn.avg_pool(modelGraph['conv3_4'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    modelGraph['conv4_1'] = tf.nn.relu(tf.nn.conv2d(modelGraph['avgpool3'], filter = vbbWeights(19), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(19))\n    modelGraph['conv4_2'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv4_1'], filter = vbbWeights(21), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(21))\n    modelGraph['conv4_3'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv4_2'], filter = vbbWeights(23), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(23))\n    modelGraph['conv4_4'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv4_3'], filter = vbbWeights(25), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(25))\n    modelGraph['avgpool4'] = tf.nn.avg_pool(modelGraph['conv4_4'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    modelGraph['conv5_1'] = tf.nn.relu(tf.nn.conv2d(modelGraph['avgpool4'], filter = vbbWeights(28), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(28))\n    modelGraph['conv5_2'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv5_1'], filter = vbbWeights(30), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(30))\n    modelGraph['conv5_3'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv5_2'], filter = vbbWeights(32), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(32))\n    modelGraph['conv5_4'] = tf.nn.relu(tf.nn.conv2d(modelGraph['conv5_3'], filter = vbbWeights(34), strides = [1, 1, 1, 1], padding = 'SAME') + vbbConstants(34))\n    modelGraph['avgpool5'] = tf.nn.avg_pool(modelGraph['conv5_4'], ksize = [1, 2, 2, 1], strides = [1, 2, 2, 1], padding = 'SAME')\n    \n    return modelGraph\n\n"
  },
  {
    "path": "tmp/visualize.py",
    "content": "\"\"\"Visualize individual feature channels and their combinations to explore the space of patterns learned by the neural network\nBased on http://nbviewer.jupyter.org/github/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb\n\"\"\"\n# MIT License\n# \n# Copyright (c) 2016 David Sandberg\n# \n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to deal\n# in the Software without restriction, including without limitation the rights\n# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n# copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n# \n# The above copyright notice and this permission notice shall be included in all\n# copies or substantial portions of the Software.\n# \n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n# SOFTWARE.\n\nfrom __future__ import absolute_import\nfrom __future__ import division\nfrom __future__ import print_function\n\nimport os\nimport numpy as np\nimport sys\nimport argparse\nimport tensorflow as tf\nimport importlib\nfrom scipy import misc\n\ndef main(args):\n  \n    network = importlib.import_module(args.model_def, 'inference')\n\n    # Start with a gray image with a little noise\n    np.random.seed(seed=args.seed)\n    img_noise = np.random.uniform(size=(args.image_size,args.image_size,3)) + 100.0\n  \n    sess = tf.Session()\n  \n    t_input = tf.placeholder(np.float32, shape=(args.image_size,args.image_size,3), name='input') # define the input tensor\n    image_mean = 117.0\n    t_preprocessed = tf.expand_dims(t_input-image_mean, 0)\n     \n    # Build the inference graph\n    network.inference(t_preprocessed, 1.0, \n            phase_train=True, weight_decay=0.0)\n      \n    # Create a saver for restoring variables\n    saver = tf.train.Saver(tf.global_variables())\n  \n    # Restore the parameters\n    saver.restore(sess, args.model_file)\n  \n    layers = [op.name for op in tf.get_default_graph().get_operations() if op.type=='Conv2D']\n    feature_nums = {layer: int(T(layer).get_shape()[-1]) for layer in layers}\n  \n    print('Number of layers: %d' % len(layers))\n  \n    for layer in sorted(feature_nums.keys()):\n        print('%s%d' % ((layer+': ').ljust(40), feature_nums[layer]))\n  \n    # Picking some internal layer. Note that we use outputs before applying the ReLU nonlinearity\n    # to have non-zero gradients for features with negative initial activations.\n    layer = 'InceptionResnetV1/Repeat_2/block8_3/Conv2d_1x1/Conv2D'\n    #layer = 'incept4b/in4_conv1x1_31/Conv2D'\n    result_dir = '../data/'\n    print('Number of features in layer \"%s\": %d' % (layer, feature_nums[layer]))\n    channels = range(feature_nums[layer])\n    np.random.shuffle(channels)\n    for i in range(32):\n        print('Rendering feature %d' % channels[i])\n        channel = channels[i]\n        img = render_naive(sess, t_input, T(layer)[:,:,:,channel], img_noise)\n        filename = '%s_%03d.png' % (layer.replace('/', '_'), channel)\n        misc.imsave(os.path.join(result_dir, filename), img)\n  \n\ndef T(layer):\n    '''Helper for getting layer output tensor'''\n    return tf.get_default_graph().get_tensor_by_name('%s:0' % layer)\n\ndef visstd(a, s=0.1):\n    '''Normalize the image range for visualization'''\n    return (a-a.mean())/max(a.std(), 1e-4)*s + 0.5\n\ndef render_naive(sess, t_input, t_obj, img0, iter_n=20, step=1.0):\n    t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n    t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n    \n    img = img0.copy()\n    for _ in range(iter_n):\n        g, _ = sess.run([t_grad, t_score], {t_input:img})\n        # normalizing the gradient, so the same step size should work \n        g /= g.std()+1e-8         # for different layers and networks\n        img += g*step\n    return visstd(img)\n\ndef parse_arguments(argv):\n    parser = argparse.ArgumentParser()\n    \n    parser.add_argument('model_file', type=str, \n        help='Directory containing the graph definition and checkpoint files.')\n    parser.add_argument('--model_def', type=str, \n        help='Model definition. Points to a module containing the definition of the inference graph.',\n        default='models.nn4')\n    parser.add_argument('--image_size', type=int,\n        help='Image size (height, width) in pixels.', default=96)\n    parser.add_argument('--seed', type=int,\n        help='Random seed.', default=666)\n    return parser.parse_args(argv)\n\nif __name__ == '__main__':\n    main(parse_arguments(sys.argv[1:]))\n"
  },
  {
    "path": "tmp/visualize_vgg_model.py",
    "content": "import numpy as np\nfrom scipy import misc\nimport tensorflow as tf\nfrom matplotlib import pyplot, image\nimport vggverydeep19\n\npaintingStyleImage = image.imread(\"../data/schoolofathens.jpg\")\npyplot.imshow(paintingStyleImage)\n\ninputImage = image.imread(\"../data/grandcentral.jpg\")\npyplot.imshow(inputImage)\n\noutputWidth = 800\noutputHeight = 600\n\n# Beta constant \nbeta = 5\n# Alpha constant\nalpha = 100\n# Noise ratio\nnoiseRatio = 0.6\n\nnodes = vggverydeep19.load('../data/imagenet-vgg-verydeep-19.mat', (600, 800))\n\n# Mean VGG-19 image\nmeanImage19 = np.array([103.939, 116.779, 123.68]).reshape((1,1,1,3)) #pylint: disable=no-member\n\n\n\n# Squared-error loss of content between the two feature representations\ndef sqErrorLossContent(sess, modelGraph, layer):\n    p = session.run(modelGraph[layer])\n    #pylint: disable=maybe-no-member\n    N = p.shape[3]\n    M = p.shape[1] * p.shape[2]\n    return (1 / (4 * N * M)) * tf.reduce_sum(tf.pow(modelGraph[layer] - sess.run(modelGraph[layer]), 2))\n \n# Squared-error loss of style between the two feature representations\nstyleLayers = [\n    ('conv1_1', 0.2),\n    ('conv2_1', 0.2),\n    ('conv3_1', 0.2),\n    ('conv4_1', 0.2),\n    ('conv5_1', 0.2),\n]\ndef sqErrorLossStyle(sess, modelGraph):\n    def intermediateCalc(x, y):\n        N = x.shape[3]\n        M = x.shape[1] * x.shape[2]\n        A = tf.matmul(tf.transpose(tf.reshape(x, (M, N))), tf.reshape(x, (M, N)))\n        G = tf.matmul(tf.transpose(tf.reshape(y, (M, N))), tf.reshape(y, (M, N)))\n        return (1 / (4 * N**2 * M**2)) * tf.reduce_sum(tf.pow(G - A, 2))\n    E = [intermediateCalc(sess.run(modelGraph[layerName]), modelGraph[layerName]) for layerName, _ in styleLayers]\n    W = [w for _, w in styleLayers]\n    return sum([W[layerNumber] * E[layerNumber] for layerNumber in range(len(styleLayers))])\n\nsession = tf.InteractiveSession()\n \n# Addition of extra dimension to image\ninputImage = np.reshape(inputImage, ((1,) + inputImage.shape))\ninputImage = inputImage - meanImage19\n# Display image\npyplot.imshow(inputImage[0])\n\n# Addition of extra dimension to image\npaintingStyleImage = np.reshape(paintingStyleImage, ((1,) + paintingStyleImage.shape))\npaintingStyleImage = paintingStyleImage - meanImage19\n# Display image\npyplot.imshow(paintingStyleImage[0])\n\nimageNoise = np.random.uniform(-20, 20, (1, outputHeight, outputWidth, 3)).astype('float32')\npyplot.imshow(imageNoise[0])\nmixedImage = imageNoise * noiseRatio + inputImage * (1 - noiseRatio)\npyplot.imshow(inputImage[0])\n\n\nsession.run(tf.global_variables_initializer())\nsession.run(nodes['input'].assign(inputImage))\ncontentLoss = sqErrorLossContent(session, nodes, 'conv4_2')\nsession.run(nodes['input'].assign(paintingStyleImage))\nstyleLoss = sqErrorLossStyle(session, nodes)\ntotalLoss = beta * contentLoss + alpha * styleLoss\n\noptimizer = tf.train.AdamOptimizer(2.0)\ntrainStep = optimizer.minimize(totalLoss)\nsession.run(tf.global_variables_initializer())\nsession.run(nodes['input'].assign(inputImage))\n# Number of iterations to run.\niterations = 2000\nsession.run(tf.global_variables_initializer())\nsession.run(nodes['input'].assign(inputImage))\n \nfor iters in range(iterations):\n    session.run(trainStep)\n    if iters%50 == 0:\n        # Output every 50 iterations for animation       \n        filename = 'output%d.png' % (iters)\n        im = mixedImage + meanImage19\n        im = im[0]\n        im = np.clip(im, 0, 255).astype('uint8')\n        misc.imsave(filename, im)\n \nim = mixedImage + meanImage19\nim = im[0]\nim = np.clip(im, 0, 255).astype('uint8')\nmisc.imsave('finalImage.png', im)\n\n"
  },
  {
    "path": "tmp/visualize_vggface.py",
    "content": "import numpy as np\nimport tensorflow as tf\nimport matplotlib.pyplot as plt\nimport tmp.vggface16\n\ndef main():\n  \n    sess = tf.Session()\n  \n    t_input = tf.placeholder(np.float32, name='input') # define the input tensor\n    image_mean = 117.0\n    t_preprocessed = tf.expand_dims(t_input-image_mean, 0)\n     \n    # Build the inference graph\n    nodes = tmp.vggface16.load('data/vgg_face.mat', t_preprocessed)\n        \n    img_noise = np.random.uniform(size=(224,224,3)) + 117.0\n\n    # Picking some internal layer. Note that we use outputs before applying the ReLU nonlinearity\n    # to have non-zero gradients for features with negative initial activations.\n    layer = 'conv5_3'\n    channel = 140 # picking some feature channel to visualize\n    img = render_naive(sess, t_input, nodes[layer][:,:,:,channel], img_noise)\n    showarray(img)\n\ndef showarray(a):\n    a = np.uint8(np.clip(a, 0, 1)*255)\n    plt.imshow(a)\n    plt.show()\n    \ndef visstd(a, s=0.1):\n    '''Normalize the image range for visualization'''\n    return (a-a.mean())/max(a.std(), 1e-4)*s + 0.5\n\ndef render_naive(sess, t_input, t_obj, img0, iter_n=20, step=1.0):\n    t_score = tf.reduce_mean(t_obj) # defining the optimization objective\n    t_grad = tf.gradients(t_score, t_input)[0] # behold the power of automatic differentiation!\n    \n    img = img0.copy()\n    for _ in range(iter_n):\n        g, _ = sess.run([t_grad, t_score], {t_input:img})\n        # normalizing the gradient, so the same step size should work \n        g /= g.std()+1e-8         # for different layers and networks\n        img += g*step\n    return visstd(img)\n\n  \nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "util/plot_learning_curves.m",
    "content": "% Plots the lerning curves for the specified training runs from data in the\n% file \"lfw_result.txt\" stored in the log directory for the respective\n% model.\n\n% MIT License\n% \n% Copyright (c) 2016 David Sandberg\n% \n% Permission is hereby granted, free of charge, to any person obtaining a copy\n% of this software and associated documentation files (the \"Software\"), to deal\n% in the Software without restriction, including without limitation the rights\n% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n% copies of the Software, and to permit persons to whom the Software is\n% furnished to do so, subject to the following conditions:\n% \n% The above copyright notice and this permission notice shall be included in all\n% copies or substantial portions of the Software.\n% \n% THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n% SOFTWARE.\n\n%%\naddpath('/home/david/git/facenet/util/');\nlog_dirs = { '/home/david/logs/facenet' };\n%%\nres = { ...\n{ '20180402-114759', 'vggface2, wd=5e-4, center crop, fixed image standardization' }, ...\n};\n\n%%\nres = { ...\n{ '20180408-102900', 'casia, wd=5e-4, pnlf=5e-4, fixed image standardization' }, ...\n};\n\n%%\n\ncolors = {'b', 'g', 'r', 'c', 'm', 'y', 'k'};\nmarkers = {'.', 'o', 'x', '+', '*', 's', 'd' };\nlines = {'-', '-.', '--', ':' };\nfontSize = 6;\nlineWidth = 2;\nlineStyles = combineStyles(colors, markers);\nlineStyles2 = combineStyles(colors, {''}, lines);\nlegends = cell(length(res),1);\nlegends_accuracy = cell(length(res),1);\nlegends_valrate = cell(length(res),1);\nvar = cell(length(res),1);\nfor i=1:length(res),\n    for k=1:length(log_dirs)\n        if exist(fullfile(log_dirs{k}, res{i}{1}), 'dir')\n            ld = log_dirs{k};\n        end\n    end\n    filename = fullfile(ld, res{i}{1}, 'stat.h5');\n    \n    var{i} = readlogs(filename,{'loss', 'reg_loss', 'xent_loss', 'lfw_accuracy', ...\n        'lfw_valrate', 'val_loss', 'val_xent_loss', 'val_accuracy', ...\n        'accuracy', 'prelogits_norm', 'learning_rate', 'center_loss', ...\n        'prelogits_hist', 'accuracy'});\n    var{i}.steps = 1:length(var{i}.loss);\n    epoch = find(var{i}.lfw_accuracy,1,'last');\n    var{i}.epochs = 1:epoch;\n    legends{i} = sprintf('%s: %s', res{i}{1}, res{i}{2});\n    start_epoch = max(1,epoch-10);\n    legends_accuracy{i} = sprintf('%s: %s (%.2f%%)', res{i}{1}, res{i}{2}, mean(var{i}.lfw_accuracy(start_epoch:epoch))*100 );\n    legends_valrate{i} = sprintf('%s: %s (%.2f%%)', res{i}{1}, res{i}{2}, mean(var{i}.lfw_valrate(start_epoch:epoch))*100 );\n    \n    arguments_filename = fullfile(ld, res{i}{1}, 'arguments.txt');\n    if exist(arguments_filename)\n        str = fileread(arguments_filename);\n        var{i}.wd = getParameter(str, 'weight_decay', '0.0');\n        var{i}.cl = getParameter(str, 'center_loss_factor', '0.0');\n        var{i}.fixed_std = getParameter(str, 'use_fixed_image_standardization', '0');\n        var{i}.data_dir = getParameter(str, 'data_dir', '');\n        var{i}.lr = getParameter(str, 'learning_rate', '0.1');\n        var{i}.epoch_size = str2double(getParameter(str, 'epoch_size', '1000'));\n        var{i}.batch_size = str2double(getParameter(str, 'batch_size', '90'));\n        var{i}.examples_per_epoch = var{i}.epoch_size*var{i}.batch_size;\n        var{i}.mnipc = getParameter(str, 'filter_min_nrof_images_per_class', '-1');\n        var{i}.val_step = str2num(getParameter(str, 'validate_every_n_epochs', '10'));\n        var{i}.pnlf = getParameter(str, 'prelogits_norm_loss_factor', '-1');\n        var{i}.emb_size = getParameter(str, 'embedding_size', '-1');\n\n        fprintf('%s: wd=%s lr=%s, pnlf=%s, data_dir=%s, emb_size=%s\\n', ...\n            res{i}{1}, var{i}.wd, var{i}.lr, var{i}.pnlf, var{i}.data_dir, var{i}.emb_size);\n    end\nend;\n\ntimestr = datestr(now,'yyyymmdd_HHMMSS');\n\nh = 1; figure(h); close(h); figure(h); hold on; setsize(1.5);\ntitle('LFW accuracy');\nxlabel('Steps');\nylabel('Accuracy');\ngrid on;\nN = 1; flt = ones(1,N)/N;\nfor i=1:length(var),\n    plot(var{i}.epochs*1000, filter(flt, 1, var{i}.lfw_accuracy(var{i}.epochs)), lineStyles2{i}, 'LineWidth', lineWidth);\nend;\nlegend(legends_accuracy,'Location','SouthEast','FontSize',fontSize);\nv=axis;\nv(3:4) = [ 0.95 1.0 ];\naxis(v);\naccuracy_file_name = sprintf('lfw_accuracy_%s',timestr);\n%print(accuracy_file_name,'-dpng')\n\n\nif 0\n    %%\n    %h = 2; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    h = 1; figure(h); hold on;\n    title('LFW validation rate');\n    xlabel('Step');\n    ylabel('VAL @ FAR = 10^{-3}');\n    grid on;\n    for i=1:length(var),\n        plot(var{i}.epochs*1000, var{i}.lfw_valrate(var{i}.epochs), lineStyles{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends_valrate,'Location','SouthEast','FontSize',fontSize);\n    v=axis;\n    v(3:4) = [ 0.5 1.0 ];\n    axis(v);\n    valrate_file_name = sprintf('lfw_valrate_%s',timestr);\n%    print(valrate_file_name,'-dpng')\nend\n\nif 0\n    %% Plot cross-entropy loss\n    h = 3; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    title('Training/validation set cross-entropy loss');\n    xlabel('Step');\n    title('Training/validation set cross-entropy loss');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        var{i}.xent_loss(var{i}.xent_loss==0) = NaN;\n        plot(var{i}.steps, filter(flt, 1, var{i}.xent_loss), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\n\n    % Plot cross-entropy loss on validation set\n    N = 1; flt = ones(1,N)/N;\n    for i=1:length(var),\n        v = var{i}.val_xent_loss;\n        val_steps = (1:length(v))*var{i}.val_step*1000;\n        v(v==0) = NaN;\n        plot(val_steps, filter(flt, 1, v), [ lineStyles2{i} '.' ], 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\n    hold off\n    xent_file_name = sprintf('xent_%s',timestr);\n    %print(xent_file_name,'-dpng')\nend\n\nif 0\n    %% Plot accuracy on training set\n    h = 32; figure(h); clf; hold on; \n    title('Training/validation set accuracy');\n    xlabel('Step');\n    ylabel('Training/validation set accuracy');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        var{i}.accuracy(var{i}.accuracy==0) = NaN;\n        plot(var{i}.steps*1000, filter(flt, 1, var{i}.accuracy), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'SouthEast','FontSize',fontSize);\n\n    grid on;\n    N = 1; flt = ones(1,N)/N;\n    for i=1:length(var),\n        v = var{i}.val_accuracy;\n        val_steps = (1:length(v))*var{i}.val_step*1000;\n        v(v==0) = NaN;\n        plot(val_steps*1000, filter(flt, 1, v), [ lineStyles2{i} '.' ], 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'SouthEast','FontSize',fontSize);\n    hold off\n    acc_file_name = sprintf('accuracy_%s',timestr);\n    %print(acc_file_name,'-dpng')\nend\n\nif 0\n    %% Plot prelogits CDF\n    h = 35; figure(h); clf; hold on; \n    title('Prelogits histogram');\n    xlabel('Epoch');\n    ylabel('Prelogits histogram');\n    grid on;\n    N = 1; flt = ones(1,N)/N;\n    for i=1:length(var),\n        epoch = var{i}.epochs(end);\n        q = cumsum(var{i}.prelogits_hist(:,epoch));\n        q2 = q / q(end);\n        plot(linspace(0,10,1000), q2, lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'SouthEast','FontSize',fontSize);\n    hold off\nend\n\nif 0\n    %% Plot prelogits norm\n    h = 32; figure(h); clf; hold on; \n    title('Prelogits norm');\n    xlabel('Step');\n    ylabel('Prelogits norm');\n    grid on;\n    N = 1; flt = ones(1,N)/N;\n    for i=1:length(var),\n        plot(var{i}.steps, filter(flt, 1, var{i}.prelogits_norm), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\n    hold off\nend\n\nif 0\n    %% Plot learning rate\n    h = 42; figure(h); clf; hold on; \n    title('Learning rate');\n    xlabel('Step');\n    ylabel('Learning rate');\n    grid on;\n    N = 1; flt = ones(1,N)/N;\n    for i=1:length(var),\n        semilogy(var{i}.epochs, filter(flt, 1, var{i}.learning_rate(var{i}.epochs)), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\n    hold off\nend\n\nif 0\n    %% Plot center loss\n    h = 9; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    title('Center loss');\n    xlabel('Epochs');\n    ylabel('Center loss');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        if isempty(var{i}.center_loss)\n            var{i}.center_loss = ones(size(var{i}.steps))*NaN;\n        end;\n        var{i}.center_loss(var{i}.center_loss==0) = NaN;\n        plot(var{i}.steps/var{i}.epoch_size, filter(flt, 1, var{i}.center_loss), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\nend\n\nif 0\n    %% Plot center loss with factor\n    h = 9; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    title('Center loss with factor');\n    xlabel('Epochs');\n    ylabel('Center loss * center loss factor');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        if isempty(var{i}.center_loss)\n            var{i}.center_loss = ones(size(var{i}.steps))*NaN;\n        end;\n        var{i}.center_loss(var{i}.center_loss==0) = NaN;\n        plot(var{i}.steps/var{i}.epoch_size, filter(flt, 1, var{i}.center_loss*str2num(var{i}.cl)), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\nend\n\nif 0\n    %% Plot total loss\n    h = 4; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    title('Total loss');\n    xlabel('Epochs');\n    ylabel('Total loss');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        var{i}.loss(var{i}.loss==0) = NaN;\n        plot(var{i}.steps/var{i}.epoch_size, filter(flt, 1, var{i}.loss), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\nend\n\nif 0\n    %% Plot regularization loss\n    h = 5; figure(h); close(h); figure(h); hold on; setsize(1.5);\n    title('Regularization loss');\n    xlabel('Epochs');\n    ylabel('Regularization loss');\n    grid on;\n    N = 500; flt = ones(1,N)/N;\n    for i=1:length(var),\n        var{i}.reg_loss(var{i}.reg_loss==0) = NaN;\n        plot(var{i}.steps/var{i}.epoch_size, filter(flt, 1, var{i}.reg_loss), lineStyles2{i}, 'LineWidth', lineWidth);\n    end;\n    legend(legends, 'Location', 'NorthEast','FontSize',fontSize);\nend\n"
  }
]