Commit 897fcf63dc228ef1d6b99f3d8912307526c772d7
1 parent
2d7872c1
more progress on face_recognition.tex
Showing
1 changed file
with
55 additions
and
21 deletions
share/openbr/likely/face_recognition.tex
| 1 | 1 | \documentclass{article} |
| 2 | +\usepackage{listings} | |
| 2 | 3 | \usepackage{verbatim} |
| 3 | 4 | |
| 4 | -\newenvironment{likely} | |
| 5 | -{ \verbatim } | |
| 6 | -{ \endverbatim } | |
| 5 | +\lstnewenvironment{likely}{ | |
| 6 | + \lstset{ | |
| 7 | + basicstyle=\ttfamily, | |
| 8 | + showstringspaces=false | |
| 9 | + }}{} | |
| 7 | 10 | |
| 8 | 11 | \title{Face Recognition in Likely} |
| 9 | 12 | \author{Joshua C. Klontz} |
| ... | ... | @@ -12,10 +15,30 @@ |
| 12 | 15 | \maketitle |
| 13 | 16 | |
| 14 | 17 | \begin{abstract} |
| 15 | -This document represents a long-term effort to port the OpenBR face recognition algorithm to Likely\footnote{www.liblikely.org}. | |
| 18 | +This document represents a long-term effort to port the OpenBR face recognition algorithm to \emph{Likely}\footnote{www.liblikely.org}. | |
| 16 | 19 | As Likely is a literate programming language, this document is both the source code \emph{and} the documentation. |
| 17 | 20 | \end{abstract} |
| 18 | 21 | |
| 22 | +\section{Compilation} | |
| 23 | +This document is a valid \LaTeX\ file that can be rendered for reading by humans. | |
| 24 | + | |
| 25 | +\begin{verbatim} | |
| 26 | +$ pdflatex face_recognition.tex | |
| 27 | +\end{verbatim} | |
| 28 | + | |
| 29 | +It is also a valid Likely file that can be trained/compiled for reading by machines. | |
| 30 | + | |
| 31 | +\begin{verbatim} | |
| 32 | +$ likely -p 'data := (read "path/to/training/data.lm" matrix \ | |
| 33 | +f32XT) ]' face_recognition.tex face_recognition.o | |
| 34 | +\end{verbatim} | |
| 35 | + | |
| 36 | +Note that the \emph{face\_recognition.o} native object file output exposes its functionality through a C-compatible signature. | |
| 37 | + | |
| 38 | +\begin{verbatim} | |
| 39 | +likely_mat face_recognition(likely_const_mat src); | |
| 40 | +\end{verbatim} | |
| 41 | + | |
| 19 | 42 | \section{Introduction} |
| 20 | 43 | We start our journey constructing the face recognition algorithm with an identity function. |
| 21 | 44 | |
| ... | ... | @@ -25,34 +48,33 @@ face-recognition := |
| 25 | 48 | src |
| 26 | 49 | \end{likely} |
| 27 | 50 | |
| 28 | -Throughout the remainder of this document we will append additional steps to the \texttt{face-recognition} function, building up the entire algorithm one transformation at a time. | |
| 51 | +Throughout the remainder of this document we will append additional steps to this function, building up the entire algorithm one transformation at a time. | |
| 29 | 52 | |
| 30 | -Note that the remainder of this document assumes that the global variable \texttt{data} is defined, and contains the appropriate training samples. | |
| 53 | +Note that the remainder of this document assumes that the global variable \emph{data} is defined, and contains the appropriate training samples. | |
| 31 | 54 | |
| 32 | 55 | \begin{likely} |
| 33 | -"Num Training Samples:" | |
| 56 | +"Number of training samples:" | |
| 34 | 57 | data.frames |
| 35 | 58 | \end{likely} |
| 36 | 59 | |
| 37 | 60 | \section{...} |
| 38 | -This section serves as a placeholder for the unwritten sections. | |
| 39 | -There are a lot of sections that haven't been written yet, including face detection, registration and representation. | |
| 61 | +This section serves as a placeholder for the unwritten algorithm steps. | |
| 62 | +There are a lot of sections that haven't been written yet, including face detection, registration and representation! | |
| 40 | 63 | In fact, only the final section of the algorithm has been written. |
| 41 | 64 | |
| 42 | 65 | \section{Quantization} |
| 43 | -The goal of quantization is to re-scale and cast feature vector dimensions into 8-bit unsigned integers. | |
| 66 | +The goal of quantization is to rescale and cast feature vector dimensions into 8-bit unsigned integers. | |
| 44 | 67 | The resulting feature vectors are smaller in size and faster to compare, with generally negligible loss in representation accuracy. |
| 45 | - | |
| 46 | -The training data is used to determine the scaling parameters. | |
| 68 | +Training data is required to determine the scaling parameters. | |
| 47 | 69 | |
| 48 | 70 | \begin{likely} |
| 49 | -lo := [ data.min-element ] | |
| 50 | -hi := [ data.max-element ] | |
| 51 | -scale := [ (/ 255 (- hi lo)) ] | |
| 52 | - | |
| 53 | 71 | train-quantize := |
| 54 | - () :-> | |
| 72 | + (training-samples) :-> | |
| 55 | 73 | { |
| 74 | + lo := [ training-samples.min-element ] | |
| 75 | + hi := [ training-samples.max-element ] | |
| 76 | + scale := [ (/ 255 (- hi lo)) ] | |
| 77 | + | |
| 56 | 78 | src :-> |
| 57 | 79 | { |
| 58 | 80 | dst := (imitate-size src (imitate-dimensions u8 src.type)) |
| ... | ... | @@ -60,17 +82,29 @@ train-quantize := |
| 60 | 82 | dst :<- src.(- lo).(* scale) |
| 61 | 83 | } |
| 62 | 84 | } |
| 85 | + | |
| 86 | +quantize := (train-quantize data) | |
| 63 | 87 | \end{likely} |
| 64 | 88 | |
| 65 | -Now we can re-define \texttt{face-recognition} to include quantization. | |
| 89 | +Now we can re-define \texttt{face-recognition} to append quantization. | |
| 66 | 90 | |
| 67 | 91 | \begin{likely} |
| 68 | 92 | face-recognition := |
| 69 | -{ | |
| 70 | - quantize := (train-quantize) | |
| 71 | 93 | src :-> |
| 72 | 94 | src.face-recognition.quantize |
| 73 | -} | |
| 95 | +\end{likely} | |
| 96 | + | |
| 97 | +And project the training data. | |
| 98 | + | |
| 99 | +\begin{likely} | |
| 100 | +data := data.quantize | |
| 101 | +\end{likely} | |
| 102 | + | |
| 103 | +And report some statistics. | |
| 104 | + | |
| 105 | +\begin{likely} | |
| 106 | +"Quantized feature vector dimensionality:" | |
| 107 | +data.columns | |
| 74 | 108 | \end{likely} |
| 75 | 109 | |
| 76 | 110 | \section{Entry Point} | ... | ... |