9.6 TODO azface Pipelines

  • To see how many faces in a photo (for example, ~/.mlhub/azface/photo/identification/identification1.jpg)

$ ml detect azface ~/.mlhub/azface/photo/identification/identification1.jpg | wc -l
4
  • To tally the number of males and females in the photo:
$ ml detect azface ~/.mlhub/azface/photo/identification/identification1.jpg | 
  cut -d ',' -f 3 | 
  sort | 
  uniq -c
2 female
2 male
  • To find the youngest face in a photo:
$ ml detect azface ~/.mlhub/azface/photo/identification/identification1.jpg |
  sort -t ',' -k 2 -n |
  head -1 |
  cut -d ',' -f 1 |
  xargs printf "-draw \'polygon %s,%s %s,%s %s,%s %s,%s\' " |
  awk '{print "~/.mlhub/azface/photo/identification/identification1.jpg -fill none -stroke red -strokewidth 5 " $0 "result.png"}' |
  xargs -I@ bash -c 'convert @'
$ xdg-open result.png

  • To see how many faces in a photo (~/.mlhub/azface/photo/identification/identification1.jpg)

similar to that in another photo (~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg):

$ ml similar azface ~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg ~/.mlhub/azface/photo/identification/identification1.jpg | 
  awk -F ',' '$1 != "" && $2 != "" {print $0}' | 
  wc -l
1
  • To mark the faces similar between the photos ~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg and ~/.mlhub/azface/photo/identification/identification1.jpg, put the following script into a file called result.sh:
TARGET=$1
CANDIDATE=$2

ml similar azface ${TARGET} ${CANDIDATE} > result.txt

for line in "$(cat result.txt | awk -F ',' '$1 != "" && $2 != "" {print $0}')"; do
  echo "${line}" |
    awk -F ',' '{print $1}' |
    xargs printf "-draw \'polygon %s,%s %s,%s %s,%s %s,%s\' " |
    awk -v TARGET="${TARGET}" '{print TARGET " -fill none -stroke red -strokewidth 5 " $0 "result1.png"}' |
    xargs -I@ bash -c 'convert @'
  echo "${line}" |
    awk -F ',' '{print $2}' |
    xargs printf "-draw \'polygon %s,%s %s,%s %s,%s %s,%s\' " |
    awk -v CANDIDATE="${CANDIDATE}" '{print CANDIDATE " -fill none -stroke red -strokewidth 5 " $0 "result2.png"}' |
    xargs -I@ bash -c 'convert @'
  montage -background '#336699' -geometry +4+4 result1.png result2.png result.png
  xdg-open result.png
done

then run the following command:

$ bash result.sh ~/.mlhub/azface/photo/PersonGroup/Family1-Dad-Bill/Family1-Dad1.jpg ~/.mlhub/azface/photo/identification/identification1.jpg

  • To count the number of faces in a crowd (for example, http://www.allwhitebackground.com/images/3/3818.jpg)

$ ml detect azface  http://www.allwhitebackground.com/images/3/3818.jpg | wc -l
35
  • Males and Females:
$ ml detect azface  http://www.allwhitebackground.com/images/3/3818.jpg | 
  cut -d ',' -f 3 | 
  sort | 
  uniq -c
     20 female
     15 male
  • Bounding boxes:
$ wget http://www.allwhitebackground.com/images/3/3818.jpg

$ ml detect azface  3818.jpg | 
  cut -d ',' -f 1 | 
  xargs printf "-draw \'polygon %s,%s %s,%s %s,%s %s,%s\' " |
  awk '{print "3818.jpg -fill none -stroke red -strokewidth 5 " $0 "3818bb.png"}' |
  xargs -I@ bash -c 'convert @'

$ eog result.png 



Your donation will support ongoing development and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.