CV之FR:DIY脚本通过人脸图像得到人脸特征向量并输出多张人脸图片之两两图片之间的距离

CV之FR:DIY脚本通过人脸图像得到人脸特征向量并输出多张人脸图片之两两图片之间的距离


输出结果

设计思路

实现代码

from scipy import misc
import tensorflow as tf
import numpy as np
import sys
import os
import argparse

……

计算过程

prewhitened参数是 [[[ 0.12834621  0.69292342  0.78113861]
  [ 0.12834621  0.69292342  0.78113861]
  [ 0.12834621  0.67528038  0.78113861]
  ...
  [-1.77710188 -1.77710188 -1.61831454]
  [-1.63595757 -1.65360061 -1.44188416]
  [-1.33602593 -1.35366897 -1.12430948]]

 [[ 0.25184747  0.74585253  0.93992595]
  [ 0.25184747  0.74585253  0.93992595]
  [ 0.28713355  0.74585253  0.93992595]
  ...
  [-1.77710188 -1.79474492 -1.65360061]
  [-1.75945884 -1.79474492 -1.56538542]
  [-1.63595757 -1.67124365 -1.40659808]]

 [[ 0.28713355  0.78113861  0.97521202]
  [ 0.32241962  0.79878165  0.99285506]
  [ 0.3577057   0.81642468  1.0104981 ]
  ...
  [-1.77710188 -1.79474492 -1.65360061]
  [-1.77710188 -1.81238795 -1.6006715 ]
  [-1.79474492 -1.81238795 -1.6006715 ]]

 ...

 [[-0.66559049 -0.41858796  0.07541709]
  [-0.55973227 -0.31272974  0.16363228]
  [-0.5773753  -0.33037278  0.18127532]
  ...
  [-0.10101328  0.16363228  0.76349557]
  [-0.13629936  0.14598925  0.74585253]
  [-0.25980062  0.05777406  0.65763734]]

 [[-0.82437783 -0.5773753  -0.10101328]
  [-0.66559049 -0.41858796  0.05777406]
  [-0.59501834 -0.34801581  0.16363228]
  ...
  [-0.13629936  0.09306013  0.71056646]
  [-0.1539424   0.11070317  0.72820949]
  [-0.1539424   0.18127532  0.76349557]]

 [[-0.96552214 -0.71851961 -0.24215759]
  [-0.77144872 -0.52444619 -0.04808417]
  [-0.64794746 -0.40094493  0.11070317]
  ...
  [-0.18922847  0.05777406  0.67528038]
  [-0.22451455  0.04013102  0.65763734]
  [-0.1539424   0.18127532  0.76349557]]]
prewhitened参数是 [[[-0.41843267  0.01911131  0.37196935]
  [-0.41843267  0.00499698  0.35785503]
  [-0.39020402  0.01911131  0.35785503]
  ...
  [-0.39020402  0.04733995  0.32962638]
  [-0.43254699  0.00499698  0.30139774]
  [-0.44666131 -0.00911734  0.28728342]]

 [[-0.40431834  0.00499698  0.3437407 ]
  [-0.39020402  0.01911131  0.35785503]
  [-0.36197538  0.01911131  0.3437407 ]
  ...
  [-0.41843267  0.01911131  0.30139774]
  [-0.44666131 -0.00911734  0.28728342]
  [-0.44666131 -0.00911734  0.28728342]]

 [[-0.40431834  0.00499698  0.32962638]
  [-0.41843267 -0.02323166  0.30139774]
  [-0.33374674  0.04733995  0.37196935]
  ...
  [-0.41843267  0.01911131  0.30139774]
  [-0.44666131 -0.00911734  0.28728342]
  [-0.46077563 -0.02323166  0.2731691 ]]

 ...

 [[-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  ...
  [-1.60403568 -1.44877815 -1.19472036]
  [-1.64637865 -1.47700679 -1.25117764]
  [-1.67460729 -1.50523543 -1.27940629]]

 [[-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  ...
  [-1.60403568 -1.44877815 -1.19472036]
  [-1.61815001 -1.44877815 -1.222949  ]
  [-1.66049297 -1.49112111 -1.26529196]]

 [[-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  [-1.67460729 -1.67460729 -1.67460729]
  ...
  [-1.60403568 -1.44877815 -1.19472036]
  [-1.58992136 -1.4205495  -1.19472036]
  [-1.64637865 -1.47700679 -1.25117764]]]
prewhitened参数是 [[[-0.68576058 -0.65851282 -0.6721367 ]
  [-1.21709198 -1.18984422 -1.2034681 ]
  [-0.94461434 -0.91736658 -0.93099046]
  ...
  [-1.5849368  -1.5031935  -1.5849368 ]
  [-1.14897257 -1.06722928 -1.18984422]
  [-1.0536054  -0.95823822 -1.09447704]]

 [[-1.08085316 -1.06722928 -1.08085316]
  [-1.36695468 -1.3533308  -1.36695468]
  [-1.5031935  -1.48956962 -1.5031935 ]
  ...
  [-1.39420245 -1.33970692 -1.39420245]
  [-1.42145021 -1.3533308  -1.44869798]
  [-1.38057857 -1.28521139 -1.40782633]]

 [[-0.98548599 -0.98548599 -1.01273375]
  [-1.06722928 -1.06722928 -1.09447704]
  [-1.25796363 -1.25796363 -1.28521139]
  ...
  [-1.18984422 -1.18984422 -1.21709198]
  [-1.02635763 -1.02635763 -1.06722928]
  [-1.31245916 -1.29883527 -1.36695468]]

 ...

 [[ 1.2215829   1.24883066  1.23520678]
  [ 1.23520678  1.26245454  1.24883066]
  [ 1.23520678  1.26245454  1.24883066]
  ...
  [ 0.43139774  0.44502162  0.49951715]
  [ 0.41777386  0.43139774  0.48589327]
  [ 0.43139774  0.44502162  0.49951715]]

 [[ 1.23520678  1.26245454  1.24883066]
  [ 1.2215829   1.24883066  1.23520678]
  [ 1.20795901  1.23520678  1.2215829 ]
  ...
  [ 0.48589327  0.49951715  0.55401268]
  [ 0.47226939  0.48589327  0.5403888 ]
  [ 0.47226939  0.48589327  0.5403888 ]]

 [[ 1.19433513  1.2215829   1.20795901]
  [ 1.16708737  1.19433513  1.18071125]
  [ 1.15346349  1.18071125  1.16708737]
  ...
  [ 0.67662762  0.6902515   0.74474703]
  [ 0.70387538  0.71749926  0.77199479]
  [ 0.73112314  0.74474703  0.79924255]]]
prewhitened参数是 [[[-1.35183598 -1.45036667 -1.43805033]
  [-1.32720331 -1.38878499 -1.38878499]
  [-1.35183598 -1.425734   -1.425734  ]
  ...
  [ 1.43165578  1.41933944  1.46860478]
  [ 1.44397211  1.41933944  1.46860478]
  [ 1.45628845  1.40702311  1.45628845]]

 [[-1.52426468 -1.56121368 -1.54889735]
  [-1.56121368 -1.59816269 -1.58584635]
  [-1.51194834 -1.54889735 -1.53658101]
  ...
  [ 1.40702311  1.38239044  1.43165578]
  [ 1.41933944  1.39470677  1.44397211]
  [ 1.43165578  1.39470677  1.45628845]]

 [[-1.57353002 -1.59816269 -1.58584635]
  [-1.57353002 -1.59816269 -1.58584635]
  [-1.52426468 -1.54889735 -1.53658101]
  ...
  [ 1.41933944  1.39470677  1.45628845]
  [ 1.40702311  1.3700741   1.44397211]
  [ 1.44397211  1.41933944  1.46860478]]

 ...

 [[ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  ...
  [-0.71138655 -0.77296823 -0.69907022]
  [-0.77296823 -0.8345499  -0.76065189]
  [-0.8345499  -0.89613158 -0.82223357]]

 [[ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  ...
  [-0.88381524 -0.94539692 -0.87149891]
  [-0.95771326 -1.01929493 -0.94539692]
  [-0.36652917 -0.42811084 -0.35421283]]

 [[ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  [ 1.48092112  1.48092112  1.48092112]
  ...
  [-0.8345499  -0.92076425 -0.8345499 ]
  [-0.48969252 -0.57590686 -0.48969252]
  [-0.00935544 -0.09556979 -0.00935544]]]

images参数 [[[[ 0.12834621  0.69292342  0.78113861]
   [ 0.12834621  0.69292342  0.78113861]
   [ 0.12834621  0.67528038  0.78113861]
   ...
   [-1.77710188 -1.77710188 -1.61831454]
   [-1.63595757 -1.65360061 -1.44188416]
   [-1.33602593 -1.35366897 -1.12430948]]

  [[ 0.25184747  0.74585253  0.93992595]
   [ 0.25184747  0.74585253  0.93992595]
   [ 0.28713355  0.74585253  0.93992595]
   ...
   [-1.77710188 -1.79474492 -1.65360061]
   [-1.75945884 -1.79474492 -1.56538542]
   [-1.63595757 -1.67124365 -1.40659808]]

  [[ 0.28713355  0.78113861  0.97521202]
   [ 0.32241962  0.79878165  0.99285506]
   [ 0.3577057   0.81642468  1.0104981 ]
   ...
   [-1.77710188 -1.79474492 -1.65360061]
   [-1.77710188 -1.81238795 -1.6006715 ]
   [-1.79474492 -1.81238795 -1.6006715 ]]

  ...

  [[-0.66559049 -0.41858796  0.07541709]
   [-0.55973227 -0.31272974  0.16363228]
   [-0.5773753  -0.33037278  0.18127532]
   ...
   [-0.10101328  0.16363228  0.76349557]
   [-0.13629936  0.14598925  0.74585253]
   [-0.25980062  0.05777406  0.65763734]]

  [[-0.82437783 -0.5773753  -0.10101328]
   [-0.66559049 -0.41858796  0.05777406]
   [-0.59501834 -0.34801581  0.16363228]
   ...
   [-0.13629936  0.09306013  0.71056646]
   [-0.1539424   0.11070317  0.72820949]
   [-0.1539424   0.18127532  0.76349557]]

  [[-0.96552214 -0.71851961 -0.24215759]
   [-0.77144872 -0.52444619 -0.04808417]
   [-0.64794746 -0.40094493  0.11070317]
   ...
   [-0.18922847  0.05777406  0.67528038]
   [-0.22451455  0.04013102  0.65763734]
   [-0.1539424   0.18127532  0.76349557]]]

 [[[-0.41843267  0.01911131  0.37196935]
   [-0.41843267  0.00499698  0.35785503]
   [-0.39020402  0.01911131  0.35785503]
   ...
   [-0.39020402  0.04733995  0.32962638]
   [-0.43254699  0.00499698  0.30139774]
   [-0.44666131 -0.00911734  0.28728342]]

  [[-0.40431834  0.00499698  0.3437407 ]
   [-0.39020402  0.01911131  0.35785503]
   [-0.36197538  0.01911131  0.3437407 ]
   ...
   [-0.41843267  0.01911131  0.30139774]
   [-0.44666131 -0.00911734  0.28728342]
   [-0.44666131 -0.00911734  0.28728342]]

  [[-0.40431834  0.00499698  0.32962638]
   [-0.41843267 -0.02323166  0.30139774]
   [-0.33374674  0.04733995  0.37196935]
   ...
   [-0.41843267  0.01911131  0.30139774]
   [-0.44666131 -0.00911734  0.28728342]
   [-0.46077563 -0.02323166  0.2731691 ]]

  ...

  [[-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   ...
   [-1.60403568 -1.44877815 -1.19472036]
   [-1.64637865 -1.47700679 -1.25117764]
   [-1.67460729 -1.50523543 -1.27940629]]

  [[-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   ...
   [-1.60403568 -1.44877815 -1.19472036]
   [-1.61815001 -1.44877815 -1.222949  ]
   [-1.66049297 -1.49112111 -1.26529196]]

  [[-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   [-1.67460729 -1.67460729 -1.67460729]
   ...
   [-1.60403568 -1.44877815 -1.19472036]
   [-1.58992136 -1.4205495  -1.19472036]
   [-1.64637865 -1.47700679 -1.25117764]]]

 [[[-0.68576058 -0.65851282 -0.6721367 ]
   [-1.21709198 -1.18984422 -1.2034681 ]
   [-0.94461434 -0.91736658 -0.93099046]
   ...
   [-1.5849368  -1.5031935  -1.5849368 ]
   [-1.14897257 -1.06722928 -1.18984422]
   [-1.0536054  -0.95823822 -1.09447704]]

  [[-1.08085316 -1.06722928 -1.08085316]
   [-1.36695468 -1.3533308  -1.36695468]
   [-1.5031935  -1.48956962 -1.5031935 ]
   ...
   [-1.39420245 -1.33970692 -1.39420245]
   [-1.42145021 -1.3533308  -1.44869798]
   [-1.38057857 -1.28521139 -1.40782633]]

  [[-0.98548599 -0.98548599 -1.01273375]
   [-1.06722928 -1.06722928 -1.09447704]
   [-1.25796363 -1.25796363 -1.28521139]
   ...
   [-1.18984422 -1.18984422 -1.21709198]
   [-1.02635763 -1.02635763 -1.06722928]
   [-1.31245916 -1.29883527 -1.36695468]]

  ...

  [[ 1.2215829   1.24883066  1.23520678]
   [ 1.23520678  1.26245454  1.24883066]
   [ 1.23520678  1.26245454  1.24883066]
   ...
   [ 0.43139774  0.44502162  0.49951715]
   [ 0.41777386  0.43139774  0.48589327]
   [ 0.43139774  0.44502162  0.49951715]]

  [[ 1.23520678  1.26245454  1.24883066]
   [ 1.2215829   1.24883066  1.23520678]
   [ 1.20795901  1.23520678  1.2215829 ]
   ...
   [ 0.48589327  0.49951715  0.55401268]
   [ 0.47226939  0.48589327  0.5403888 ]
   [ 0.47226939  0.48589327  0.5403888 ]]

  [[ 1.19433513  1.2215829   1.20795901]
   [ 1.16708737  1.19433513  1.18071125]
   [ 1.15346349  1.18071125  1.16708737]
   ...
   [ 0.67662762  0.6902515   0.74474703]
   [ 0.70387538  0.71749926  0.77199479]
   [ 0.73112314  0.74474703  0.79924255]]]

 [[[-1.35183598 -1.45036667 -1.43805033]
   [-1.32720331 -1.38878499 -1.38878499]
   [-1.35183598 -1.425734   -1.425734  ]
   ...
   [ 1.43165578  1.41933944  1.46860478]
   [ 1.44397211  1.41933944  1.46860478]
   [ 1.45628845  1.40702311  1.45628845]]

  [[-1.52426468 -1.56121368 -1.54889735]
   [-1.56121368 -1.59816269 -1.58584635]
   [-1.51194834 -1.54889735 -1.53658101]
   ...
   [ 1.40702311  1.38239044  1.43165578]
   [ 1.41933944  1.39470677  1.44397211]
   [ 1.43165578  1.39470677  1.45628845]]

  [[-1.57353002 -1.59816269 -1.58584635]
   [-1.57353002 -1.59816269 -1.58584635]
   [-1.52426468 -1.54889735 -1.53658101]
   ...
   [ 1.41933944  1.39470677  1.45628845]
   [ 1.40702311  1.3700741   1.44397211]
   [ 1.44397211  1.41933944  1.46860478]]

  ...

  [[ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   ...
   [-0.71138655 -0.77296823 -0.69907022]
   [-0.77296823 -0.8345499  -0.76065189]
   [-0.8345499  -0.89613158 -0.82223357]]

  [[ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   ...
   [-0.88381524 -0.94539692 -0.87149891]
   [-0.95771326 -1.01929493 -0.94539692]
   [-0.36652917 -0.42811084 -0.35421283]]

  [[ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   [ 1.48092112  1.48092112  1.48092112]
   ...
   [-0.8345499  -0.92076425 -0.8345499 ]
   [-0.48969252 -0.57590686 -0.48969252]
   [-0.00935544 -0.09556979 -0.00935544]]]]
(4, 160, 160, 3)
(0)

相关推荐