Skip to content

Commit

Permalink
Age/Gender/Emotion classification does not work on Linux/OSX (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
takuya-takeuchi authored Jul 25, 2022
1 parent e2b9fe2 commit e7f29f4
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 26 deletions.
77 changes: 77 additions & 0 deletions nuget/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.DEFAULT_GOAL := help

help: ## print this message
@echo "Example operations by makefile."
@echo ""
@echo "Usage: make SUB_COMMAND argument_name=argument_value"
@echo ""
@echo "Command list:"
@echo ""
@printf "\033[36m%-40s\033[0m %-50s %s\n" "[Sub command]" "[Description]" "[Example]"
@grep -E '^[/a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | perl -pe 's%^([/a-zA-Z0-9_-]+):.*?(##)%$$1 $$2%' | awk -F " *?## *?" '{printf "\033[36m%-40s\033[0m %-50s %s\n", $$1, $$2, $$3}'

run-build-centos7-cpu-x64-desktop: ## run build container for centos7 cpu x64 on desktop
@pwsh RunBuildContainer.ps1 cpu 64 desktop centos 7 "/x64"

run-build-centos7-mkl-x64-desktop: ## run build container for centos7 mkl x64 on desktop
@pwsh RunBuildContainer.ps1 mkl 64 desktop centos 7 "/x64"

run-build-ubuntu16-cpu-x64-desktop: ## run build container for ubuntu16 cpu x64 on desktop
@pwsh RunBuildContainer.ps1 cpu 64 desktop ubuntu 16 "/x64"

run-build-ubuntu16-mkl-x64-desktop: ## run build container for ubuntu16 mkl x64 on desktop
@pwsh RunBuildContainer.ps1 mkl 64 desktop ubuntu 16 "/x64"

run-test-centos7-cpu-x64-desktop: ## run build container for centos7 cpu x64 on desktop
@pwsh RunTestContainer.ps1 cpu 64 desktop centos 7 "/x64"

run-test-centos7-mkl-x64-desktop: ## run build container for centos7 mkl x64 on desktop
@pwsh RunTestContainer.ps1 mkl 64 desktop centos 7 "/x64"

run-test-centos7-cu92-x64-desktop: ## run build container for centos7 cuda-92 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "92"

run-test-centos7-cu100-x64-desktop: ## run build container for centos7 cuda-100 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "100"

run-test-centos7-cu101-x64-desktop: ## run build container for centos7 cuda-101 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "101"

run-test-centos7-cu102-x64-desktop: ## run build container for centos7 cuda-102 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "102"

run-test-centos7-cu110-x64-desktop: ## run build container for centos7 cuda-110 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "110"

run-test-centos7-cu111-x64-desktop: ## run build container for centos7 cuda-111 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "111"

run-test-centos7-cu112-x64-desktop: ## run build container for centos7 cuda-112 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop centos 7 "112"

run-test-centos7-cpu-x64-desktop: ## run build container for centos7 cpu x64 on desktop
@pwsh RunTestContainer.ps1 cpu 64 desktop ubuntu 16 "/x64"

run-test-ubuntu16-mkl-x64-desktop: ## run build container for ubuntu16 mkl x64 on desktop
@pwsh RunTestContainer.ps1 mkl 64 desktop ubuntu 16 "/x64"

run-test-ubuntu16-cu92-x64-desktop: ## run build container for ubuntu16 cuda-92 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "92"

run-test-ubuntu16-cu100-x64-desktop: ## run build container for ubuntu16 cuda-100 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "100"

run-test-ubuntu16-cu101-x64-desktop: ## run build container for ubuntu16 cuda-101 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "101"

run-test-ubuntu16-cu102-x64-desktop: ## run build container for ubuntu16 cuda-102 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "102"

run-test-ubuntu16-cu110-x64-desktop: ## run build container for ubuntu16 cuda-110 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "110"

run-test-ubuntu16-cu111-x64-desktop: ## run build container for ubuntu16 cuda-111 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "111"

run-test-ubuntu16-cu112-x64-desktop: ## run build container for ubuntu16 cuda-112 x64 on desktop
@pwsh RunTestContainer.ps1 cuda 64 desktop ubuntu 16 "112"
113 changes: 113 additions & 0 deletions nuget/RunTestContainer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
#***************************************
#Arguments
#%1: Target (cpu/cuda/mkl/arm)
#%2: Architecture (32/64)
#%3: Platform (desktop,android/ios/uwp)
#%4: Optional Argument
# if Target is cuda, CUDA version if Target is cuda [90/91/92/100/101/102/110/111]
# if Target is mkl and Windows, IntelMKL directory path
#***************************************
Param
(
[Parameter(
Mandatory=$True,
Position = 1
)][string]
$Target,

[Parameter(
Mandatory=$True,
Position = 2
)][int]
$Architecture,

[Parameter(
Mandatory=$True,
Position = 3
)][string]
$Platform,

[Parameter(
Mandatory=$True,
Position = 4
)][string]
$Distribution,

[Parameter(
Mandatory=$True,
Position = 5
)][string]
$DistributionVersion,

[Parameter(
Mandatory=$False,
Position = 6
)][string]
$Option
)

$ScriptPath = $PSScriptRoot
$FaceRecognitionDotNetRoot = Split-Path $ScriptPath -Parent
$BuildUtilsPath = Join-Path $FaceRecognitionDotNetRoot "nuget" | `
Join-Path -ChildPath "BuildUtils.ps1"
import-module $BuildUtilsPath -function *
$Config = [Config]::new($FaceRecognitionDotNetRoot, "Release", $Target, $Architecture, $Platform, $Option)

$DataSetRoot = $env:DataSetDir
if (!(Test-Path($DataSetRoot)))
{
Write-Host "${DataSetRoot} is missing. You can specify DataSetDir environmental variable" -ForegroundColor Yellow
$DataSetRoot = $FaceRecognitionDotNetRoot
}

if ($Target -ne "cuda")
{
$postfix = $Option
$cuda = 0
$dockername = "facerecognition/test/$Distribution/$DistributionVersion/$Target" + $postfix
}
else
{
$cudaVersion = ($Option / 10).ToString("0.0")
$cuda = 1
$dockername = "facerecognition/test/$Distribution/$DistributionVersion/$Target/$cudaVersion"
}

if ($cuda -ne 0)
{
$dockerAPIVersion = docker version --format '{{.Server.APIVersion}}'
Write-Host "Docker API Version: $dockerAPIVersion" -ForegroundColor Yellow
if ($dockerAPIVersion -ge 1.40)
{
docker run --gpus all --rm `
--entrypoint="/bin/bash" `
-v "$($FaceRecognitionDotNetRoot):/opt/data/FaceRecognitionDotNet" `
-v "$($DataSetRoot):/opt/data/Dataset" `
-e "LOCAL_UID=$(id -u $env:USER)" `
-e "LOCAL_GID=$(id -g $env:USER)" `
-w /opt/data/FaceRecognitionDotNet `
-it "$dockername"
}
else
{
docker run --runtime=nvidia --rm `
--entrypoint="/bin/bash" `
-v "$($FaceRecognitionDotNetRoot):/opt/data/FaceRecognitionDotNet" `
-v "$($DataSetRoot):/opt/data/Dataset" `
-e "LOCAL_UID=$(id -u $env:USER)" `
-e "LOCAL_GID=$(id -g $env:USER)" `
-w /opt/data/FaceRecognitionDotNet `
-it "$dockername"
}
}
else
{
docker run --rm `
--entrypoint="/bin/bash" `
-v "$($FaceRecognitionDotNetRoot):/opt/data/FaceRecognitionDotNet" `
-v "$($DataSetRoot):/opt/data/Dataset" `
-e "LOCAL_UID=$(id -u $env:USER)" `
-e "LOCAL_GID=$(id -g $env:USER)" `
-w /opt/data/FaceRecognitionDotNet `
-it "$dockername"
}
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CPU.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet" version="19.21.0.20210302" />
<dependency id="DlibDotNet" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet" version="19.21.0.20210302" />
<dependency id="DlibDotNet" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA100.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA100" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA100" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA100" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA100" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA101.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA101" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA101" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA101" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA101" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA102.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA102" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA102" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA102" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA102" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA110.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA110" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA110" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA110" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA110" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA111.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA111" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA111" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA111" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA111" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA112.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA112" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA112" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA112" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA112" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.CUDA92.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.CUDA92" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA92" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.CUDA92" version="19.21.0.20210302" />
<dependency id="DlibDotNet.CUDA92" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions nuget/nuspec/FaceRecognitionDotNet.MKL.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ This library is ported from https://github.com/ageitgey/face_recognition by C#.<

<dependencies>
<group targetFramework="net461">
<dependency id="DlibDotNet.MKL" version="19.21.0.20210302" />
<dependency id="DlibDotNet.MKL" version="19.21.0.20220724" />
</group>
<group targetFramework="netstandard2.0">
<dependency id="System.Drawing.Common" version="5.0.1" />
<dependency id="DlibDotNet.MKL" version="19.21.0.20210302" />
<dependency id="DlibDotNet.MKL" version="19.21.0.20220724" />
</group>
</dependencies>
<frameworkAssemblies>
Expand Down
4 changes: 2 additions & 2 deletions src/AgeClassification/dlib/dnn/loss/multiclass_log/age/Age.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "defines.h"
#include "DlibDotNet.Native.Dnn/dlib/dnn/loss/multiclass_log/template.h"

typedef unsigned long age_out_type;
typedef unsigned long age_train_label_type;
typedef uint32_t age_out_type;
typedef uint32_t age_train_label_type;

MAKE_LOSSMULTICLASSLOG_FUNC(age_train_type, matrix_element_type::RgbPixel, dlib::rgb_pixel, matrix_element_type::UInt32, age_train_label_type, 200)

Expand Down
2 changes: 1 addition & 1 deletion src/DlibDotNet
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "defines.h"
#include "DlibDotNet.Native.Dnn/dlib/dnn/loss/multiclass_log/template.h"

typedef unsigned long emotion_out_type;
typedef unsigned long emotion_train_label_type;
typedef uint32_t emotion_out_type;
typedef uint32_t emotion_train_label_type;

MAKE_LOSSMULTICLASSLOG_FUNC(emotion_train_type, matrix_element_type::Double, double, matrix_element_type::UInt32, emotion_train_label_type, 200)
MAKE_LOSSMULTICLASSLOG_FUNC(emotion_train_type2, matrix_element_type::RgbPixel, dlib::rgb_pixel, matrix_element_type::UInt32, emotion_train_label_type, 201)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "defines.h"
#include "DlibDotNet.Native.Dnn/dlib/dnn/loss/multiclass_log/template.h"

typedef unsigned long gender_out_type;
typedef unsigned long gender_train_label_type;
typedef uint32_t gender_out_type;
typedef uint32_t gender_train_label_type;

MAKE_LOSSMULTICLASSLOG_FUNC(gender_train_type, matrix_element_type::RgbPixel, dlib::rgb_pixel, matrix_element_type::UInt32, gender_train_label_type, 100)

Expand Down
2 changes: 1 addition & 1 deletion tools/GenderTraining/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ python tools\gender-hist.py UTKFaceDataset

````
cd <GenderTraining_dir>
dotnet run -c Release -- -d=UTKFaceDataset -b=400 -e=600 -v=20
dotnet run -c Release -- train -d=UTKFaceDataset -b=400 -e=600 -v=20
Epoch: 600
Learning Rate: 0.001
Min Learning Rate: 1E-05
Expand Down

0 comments on commit e7f29f4

Please sign in to comment.