diff --git a/README.md b/README.md index 3a67f381..f181e7c6 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,12 @@ Dlib wrapper written in C++ and C# for Windows, MacOS and Linux |DlibDotNet for CUDA 10.2|Windows|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA102.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA102)| ||Linux|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA102.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA102)| ||OSX|-|-|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA102.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA102)| +|DlibDotNet for CUDA 11.0|Windows|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA110.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA110)| +||Linux|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA110.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA110)| +||OSX|-|-|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA110.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA110)| +|DlibDotNet for CUDA 11.1|Windows|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA111.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA111)| +||Linux|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA111.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA111)| +||OSX|-|-|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.CUDA111.svg)](https://www.nuget.org/packages/DlibDotNet.CUDA111)| |DlibDotNet for Intel MKL|Windows|✓|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.MKL.svg)](https://www.nuget.org/packages/DlibDotNet.MKL)| ||Linux|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.MKL.svg)](https://www.nuget.org/packages/DlibDotNet.MKL)| ||OSX|-|✓|-|-|[![NuGet version](https://img.shields.io/nuget/v/DlibDotNet.MKL.svg)](https://www.nuget.org/packages/DlibDotNet.MKL)| diff --git a/docker/base/centos/7/cuda/11.0/Dockerfile b/docker/base/centos/7/cuda/11.0/Dockerfile new file mode 100644 index 00000000..40595c3b --- /dev/null +++ b/docker/base/centos/7/cuda/11.0/Dockerfile @@ -0,0 +1,12 @@ +FROM nvidia/cuda:11.0-cudnn8-devel-centos7 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN yum update -y && yum install -y \ + ca-certificates +RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum update -y && yum install -y \ + libX11-devel \ + lapack-devel \ + openblas-devel \ + && yum clean all \ No newline at end of file diff --git a/docker/base/centos/7/cuda/11.1/Dockerfile b/docker/base/centos/7/cuda/11.1/Dockerfile new file mode 100644 index 00000000..06a2e64c --- /dev/null +++ b/docker/base/centos/7/cuda/11.1/Dockerfile @@ -0,0 +1,12 @@ +FROM nvidia/cuda:11.1-cudnn8-devel-centos7 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN yum update -y && yum install -y \ + ca-certificates +RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum update -y && yum install -y \ + libX11-devel \ + lapack-devel \ + openblas-devel \ + && yum clean all \ No newline at end of file diff --git a/docker/base/ubuntu/16/cuda/11.0/Dockerfile b/docker/base/ubuntu/16/cuda/11.0/Dockerfile new file mode 100644 index 00000000..cc034038 --- /dev/null +++ b/docker/base/ubuntu/16/cuda/11.0/Dockerfile @@ -0,0 +1,9 @@ +FROM nvidia/cuda:11.0-cudnn8-devel-ubuntu16.04 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN apt-get update && apt-get install -y \ + libopenblas-dev \ + liblapack-dev \ + libx11-6 \ + && apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/docker/base/ubuntu/16/cuda/11.1/Dockerfile b/docker/base/ubuntu/16/cuda/11.1/Dockerfile new file mode 100644 index 00000000..0ef6f9ae --- /dev/null +++ b/docker/base/ubuntu/16/cuda/11.1/Dockerfile @@ -0,0 +1,9 @@ +FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu16.04 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN apt-get update && apt-get install -y \ + libopenblas-dev \ + liblapack-dev \ + libx11-6 \ + && apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/docker/devel/centos/7/cuda/11.0/Dockerfile b/docker/devel/centos/7/cuda/11.0/Dockerfile new file mode 100644 index 00000000..69d6de0d --- /dev/null +++ b/docker/devel/centos/7/cuda/11.0/Dockerfile @@ -0,0 +1,47 @@ +FROM nvidia/cuda:11.0-cudnn8-devel-centos7 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN yum update -y && yum install -y \ + ca-certificates +RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum update -y && yum install -y \ + libX11-devel \ + lapack-devel \ + openblas-devel \ + cmake3 +RUN yum groupinstall -y "Development Tools" + +# set compiler +ENV CMAKE_C_COMPILER=/usr/bin/gcc +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +# set env to build by using CUDA +ENV CUDA_PATH /usr/local/cuda +ENV PATH $CUDA_PATH/bin:$PATH +ENV CPATH $CUDA_PATH/include:$CPATH +ENV LD_LIBRARY_PATH $CUDA_PATH/lib64:$LD_LIBRARY_PATH +ENV NCCL_ROOT /usr/local/nccl +ENV CPATH $NCCL_ROOT/include:$CPATH +ENV LD_LIBRARY_PATH $NCCL_ROOT/lib/:$LD_LIBRARY_PATH +ENV LIBRARY_PATH $NCCL_ROOT/lib/:$LIBRARY_PATH + +# Register Microsoft key and feed +RUN yum update -y && yum install -y \ + curl +RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo +RUN yum update -y && yum install -y \ + powershell \ + && yum clean all + +# user cmake 3 instead of cmake 2 +RUN alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \ + --slave /usr/local/bin/ctest ctest /usr/bin/ctest \ + --slave /usr/local/bin/cpack cpack /usr/bin/cpack \ + --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \ + --family cmake +RUN alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \ + --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \ + --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \ + --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \ + --family cmake \ No newline at end of file diff --git a/docker/devel/centos/7/cuda/11.1/Dockerfile b/docker/devel/centos/7/cuda/11.1/Dockerfile new file mode 100644 index 00000000..70526a8b --- /dev/null +++ b/docker/devel/centos/7/cuda/11.1/Dockerfile @@ -0,0 +1,47 @@ +FROM nvidia/cuda:11.1-cudnn8-devel-centos7 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN yum update -y && yum install -y \ + ca-certificates +RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum update -y && yum install -y \ + libX11-devel \ + lapack-devel \ + openblas-devel \ + cmake3 +RUN yum groupinstall -y "Development Tools" + +# set compiler +ENV CMAKE_C_COMPILER=/usr/bin/gcc +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +# set env to build by using CUDA +ENV CUDA_PATH /usr/local/cuda +ENV PATH $CUDA_PATH/bin:$PATH +ENV CPATH $CUDA_PATH/include:$CPATH +ENV LD_LIBRARY_PATH $CUDA_PATH/lib64:$LD_LIBRARY_PATH +ENV NCCL_ROOT /usr/local/nccl +ENV CPATH $NCCL_ROOT/include:$CPATH +ENV LD_LIBRARY_PATH $NCCL_ROOT/lib/:$LD_LIBRARY_PATH +ENV LIBRARY_PATH $NCCL_ROOT/lib/:$LIBRARY_PATH + +# Register Microsoft key and feed +RUN yum update -y && yum install -y \ + curl +RUN curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo +RUN yum update -y && yum install -y \ + powershell \ + && yum clean all + +# user cmake 3 instead of cmake 2 +RUN alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake 10 \ + --slave /usr/local/bin/ctest ctest /usr/bin/ctest \ + --slave /usr/local/bin/cpack cpack /usr/bin/cpack \ + --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake \ + --family cmake +RUN alternatives --install /usr/local/bin/cmake cmake /usr/bin/cmake3 20 \ + --slave /usr/local/bin/ctest ctest /usr/bin/ctest3 \ + --slave /usr/local/bin/cpack cpack /usr/bin/cpack3 \ + --slave /usr/local/bin/ccmake ccmake /usr/bin/ccmake3 \ + --family cmake \ No newline at end of file diff --git a/docker/devel/ubuntu/16/cuda/11.0/Dockerfile b/docker/devel/ubuntu/16/cuda/11.0/Dockerfile new file mode 100644 index 00000000..ce2a1a4b --- /dev/null +++ b/docker/devel/ubuntu/16/cuda/11.0/Dockerfile @@ -0,0 +1,35 @@ +FROM nvidia/cuda:11.0-cudnn8-devel-ubuntu16.04 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN apt-get update && apt-get install -y \ + build-essential \ + libopenblas-dev \ + liblapack-dev \ + libx11-dev \ + cmake \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# set compiler +ENV CMAKE_C_COMPILER=/usr/bin/gcc +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +# set env to build by using CUDA +ENV CUDA_PATH /usr/local/cuda +ENV PATH $CUDA_PATH/bin:$PATH +ENV CPATH $CUDA_PATH/include:$CPATH +ENV LD_LIBRARY_PATH $CUDA_PATH/lib64:$LD_LIBRARY_PATH +ENV NCCL_ROOT /usr/local/nccl +ENV CPATH $NCCL_ROOT/include:$CPATH +ENV LD_LIBRARY_PATH $NCCL_ROOT/lib/:$LD_LIBRARY_PATH +ENV LIBRARY_PATH $NCCL_ROOT/lib/:$LIBRARY_PATH + +# Register Microsoft key and feed +RUN apt-get update && apt-get install -y \ + wget \ + apt-transport-https +RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb +RUN dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb +RUN apt-get update && apt-get install -y \ + powershell \ + && apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/docker/devel/ubuntu/16/cuda/11.1/Dockerfile b/docker/devel/ubuntu/16/cuda/11.1/Dockerfile new file mode 100644 index 00000000..235d7b47 --- /dev/null +++ b/docker/devel/ubuntu/16/cuda/11.1/Dockerfile @@ -0,0 +1,35 @@ +FROM nvidia/cuda:11.1-cudnn8-devel-ubuntu16.04 +LABEL maintainer "Takuya Takeuchi " + +# install package to build +RUN apt-get update && apt-get install -y \ + build-essential \ + libopenblas-dev \ + liblapack-dev \ + libx11-dev \ + cmake \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# set compiler +ENV CMAKE_C_COMPILER=/usr/bin/gcc +ENV CMAKE_CXX_COMPILER=/usr/bin/g++ + +# set env to build by using CUDA +ENV CUDA_PATH /usr/local/cuda +ENV PATH $CUDA_PATH/bin:$PATH +ENV CPATH $CUDA_PATH/include:$CPATH +ENV LD_LIBRARY_PATH $CUDA_PATH/lib64:$LD_LIBRARY_PATH +ENV NCCL_ROOT /usr/local/nccl +ENV CPATH $NCCL_ROOT/include:$CPATH +ENV LD_LIBRARY_PATH $NCCL_ROOT/lib/:$LD_LIBRARY_PATH +ENV LIBRARY_PATH $NCCL_ROOT/lib/:$LIBRARY_PATH + +# Register Microsoft key and feed +RUN apt-get update && apt-get install -y \ + wget \ + apt-transport-https +RUN wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb +RUN dpkg -i packages-microsoft-prod.deb && rm packages-microsoft-prod.deb +RUN apt-get update && apt-get install -y \ + powershell \ + && apt-get clean && rm -rf /var/lib/apt/lists/* \ No newline at end of file diff --git a/nuget/BuildCentOS7.ps1 b/nuget/BuildCentOS7.ps1 index c5c5ca73..e7dbf4fa 100644 --- a/nuget/BuildCentOS7.ps1 +++ b/nuget/BuildCentOS7.ps1 @@ -36,6 +36,8 @@ $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 100 } $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 101 } $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 102 } +$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 110 } +$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 111 } #$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "arm"; Architecture = 64; Postfix = "64"; RID = "$OperatingSystem-arm64"; CUDA = 0 } #$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "arm"; Architecture = 32; Postfix = ""; RID = "$OperatingSystem-arm"; CUDA = 0 } diff --git a/nuget/BuildUbuntu16.ps1 b/nuget/BuildUbuntu16.ps1 index 5782e10d..ab5622a4 100644 --- a/nuget/BuildUbuntu16.ps1 +++ b/nuget/BuildUbuntu16.ps1 @@ -36,6 +36,8 @@ $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 100 } $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 101 } $BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 102 } +$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 110 } +$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "cuda"; Architecture = 64; Postfix = ""; RID = "$OperatingSystem-x64"; CUDA = 111 } #$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "arm"; Architecture = 64; Postfix = "64"; RID = "$OperatingSystem-arm64"; CUDA = 0 } #$BuildTargets += New-Object PSObject -Property @{ Platform = "desktop"; Target = "arm"; Architecture = 32; Postfix = ""; RID = "$OperatingSystem-arm"; CUDA = 0 } diff --git a/nuget/BuildUtils.ps1 b/nuget/BuildUtils.ps1 index 369ada46..8f9a3674 100644 --- a/nuget/BuildUtils.ps1 +++ b/nuget/BuildUtils.ps1 @@ -36,7 +36,9 @@ class Config 92, 100, 101, - 102 + 102, + 110, + 111 ) $CudaVersionHash = @@ -46,7 +48,9 @@ class Config 92 = "CUDA_PATH_V9_2"; 100 = "CUDA_PATH_V10_0"; 101 = "CUDA_PATH_V10_1"; - 102 = "CUDA_PATH_V10_2" + 102 = "CUDA_PATH_V10_2"; + 110 = "CUDA_PATH_V11_0"; + 111 = "CUDA_PATH_V11_1"; } $VisualStudio = "Visual Studio 15 2017" @@ -93,7 +97,7 @@ class Config # %4: Architecture (32/64) # %5: Platform (desktop/android/ios/uwp) # %6: Optional Argument - # if Target is cuda, CUDA version if Target is cuda [90/91/92/100/101/102] + # if Target is cuda, CUDA version if Target is cuda [90/91/92/100/101/102/110] # if Target is mkl and Windows, IntelMKL directory path #*************************************** Config( [string]$Root, @@ -128,7 +132,7 @@ class Config if ($this.PlatformArray.Contains($Platform) -eq $False) { $candidate = $this.PlatformArray -join "/" - Write-Host "Error: Specify Architecture [${candidate}]" -ForegroundColor Red + Write-Host "Error: Specify Platform [${candidate}]" -ForegroundColor Red exit -1 } @@ -416,6 +420,8 @@ class Config { # CUDA_PATH_V10_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0 # CUDA_PATH_V10_1=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1 + # CUDA_PATH_V10_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2 + # CUDA_PATH_V11_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0 # CUDA_PATH_V9_0=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0 # CUDA_PATH_V9_1=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1 # CUDA_PATH_V9_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2 diff --git a/nuget/BuildWindows.ps1 b/nuget/BuildWindows.ps1 index b1efa009..25d7a3aa 100644 --- a/nuget/BuildWindows.ps1 +++ b/nuget/BuildWindows.ps1 @@ -38,6 +38,8 @@ $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; RID = "$OperatingSystem-x64"; CUDA = 100 } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; RID = "$OperatingSystem-x64"; CUDA = 101 } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; RID = "$OperatingSystem-x64"; CUDA = 102 } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; RID = "$OperatingSystem-x64"; CUDA = 110 } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; RID = "$OperatingSystem-x64"; CUDA = 111 } foreach ($BuildTarget in $BuildTargets) { diff --git a/nuget/CreateAllPackage.bat b/nuget/CreateAllPackage.bat index 8f0cc14c..09566494 100644 --- a/nuget/CreateAllPackage.bat +++ b/nuget/CreateAllPackage.bat @@ -6,6 +6,8 @@ pwsh CreatePackage.ps1 CUDA-92 pwsh CreatePackage.ps1 CUDA-100 pwsh CreatePackage.ps1 CUDA-101 pwsh CreatePackage.ps1 CUDA-102 +pwsh CreatePackage.ps1 CUDA-110 +pwsh CreatePackage.ps1 CUDA-111 pwsh CreatePackage.ps1 MKL pwsh CreatePackage.ps1 UWP diff --git a/nuget/Publish.bat b/nuget/Publish.bat index 2278388d..d68ef79e 100644 --- a/nuget/Publish.bat +++ b/nuget/Publish.bat @@ -1,4 +1,6 @@ dotnet nuget push DlibDotNet.MKL.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json +dotnet nuget push DlibDotNet.CUDA111.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json +dotnet nuget push DlibDotNet.CUDA110.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json dotnet nuget push DlibDotNet.CUDA102.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json dotnet nuget push DlibDotNet.CUDA101.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json dotnet nuget push DlibDotNet.CUDA100.%1.nupkg -k %2 -s https://api.nuget.org/v3/index.json diff --git a/nuget/TestPackage.ps1 b/nuget/TestPackage.ps1 index 7f516e53..ed415d12 100644 --- a/nuget/TestPackage.ps1 +++ b/nuget/TestPackage.ps1 @@ -96,8 +96,7 @@ function RunTest($BuildTargets) # Copy Dependencies $OutDir = Join-Path $TargetDir bin | ` Join-Path -ChildPath Release | ` - Join-Path -ChildPath netcoreapp2.0 | ` - Join-Path -ChildPath $RuntimeIdentifier + Join-Path -ChildPath netcoreapp2.0 if (!(Test-Path "$OutDir")) { New-Item "$OutDir" -ItemType Directory > $null } @@ -108,7 +107,8 @@ function RunTest($BuildTargets) { foreach($Dependency in $BuildTarget.Dependencies) { - Copy-Item "$Dependency" "$OutDir" + $FileName = [System.IO.Path]::GetFileName("$Dependency") + New-Item -Value "$Dependency" -Path "$OutDir" -Name "$FileName" -ItemType SymbolicLink > $null } } } @@ -213,6 +213,34 @@ $tmp102.Add("$env:CUDA_PATH_V10_2\bin\cudnn64_7.dll") $tmp102.Add("$env:CUDA_PATH_V10_2\bin\curand64_10.dll") $tmp102.Add("$env:CUDA_PATH_V10_2\bin\cusolver64_10.dll") +# For DlibDotNet.CUDA110 +$tmp110 = New-Object 'System.Collections.Generic.List[string]' +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cublas64_11.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cublasLt64_11.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_adv_infer64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_adv_train64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_cnn_infer64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_cnn_train64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_ops_infer64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn_ops_train64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cudnn64_8.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\curand64_10.dll") +$tmp110.Add("$env:CUDA_PATH_V11_0\bin\cusolver64_10.dll") + +# For DlibDotNet.CUDA111 +$tmp111 = New-Object 'System.Collections.Generic.List[string]' +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cublas64_11.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cublasLt64_11.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_adv_infer64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_adv_train64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_cnn_infer64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_cnn_train64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_ops_infer64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn_ops_train64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cudnn64_8.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\curand64_10.dll") +$tmp111.Add("$env:CUDA_PATH_V11_1\bin\cusolver64_11.dll") + $BuildTargets = @() $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet"; Dependencies = $null } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x86"; Architecture = 32; Package = "DlibDotNet"; Dependencies = $null } @@ -222,6 +250,8 @@ $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Archite $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.CUDA100"; Dependencies = $tmp100 } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.CUDA101"; Dependencies = $tmp101 } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.CUDA102"; Dependencies = $tmp102 } +$BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.CUDA110"; Dependencies = $tmp110 } +$BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.CUDA111"; Dependencies = $tmp111 } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x64"; Architecture = 64; Package = "DlibDotNet.MKL"; Dependencies = $null } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "x86"; Architecture = 32; Package = "DlibDotNet.MKL"; Dependencies = $null } $BuildTargets += New-Object PSObject -Property @{PlatformTarget = "arm"; Architecture = 32; Package = "DlibDotNet.ARM"; Dependencies = $null } diff --git a/nuget/TestPackageCentOS7.ps1 b/nuget/TestPackageCentOS7.ps1 index 16cbaf8f..3b7fde1e 100644 --- a/nuget/TestPackageCentOS7.ps1 +++ b/nuget/TestPackageCentOS7.ps1 @@ -37,6 +37,8 @@ $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 100; Package = "DlibDotNet.CUDA100"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 101; Package = "DlibDotNet.CUDA101"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 102; Package = "DlibDotNet.CUDA102"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 110; Package = "DlibDotNet.CUDA110"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 111; Package = "DlibDotNet.CUDA111"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } foreach($BuildTarget in $BuildTargets) { @@ -75,7 +77,7 @@ foreach($BuildTarget in $BuildTargets) Write-Host "Docker API Version: $dockerAPIVersion" -ForegroundColor Yellow if ($dockerAPIVersion -ge 1.40) { - Write-Host "Start docker run --gpus all --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --gpus all --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --gpus all --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` @@ -84,7 +86,7 @@ foreach($BuildTarget in $BuildTargets) } else { - Write-Host "Start docker run --runtime=nvidia --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --runtime=nvidia --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --runtime=nvidia --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` @@ -94,7 +96,7 @@ foreach($BuildTarget in $BuildTargets) } else { - Write-Host "Start docker run --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` diff --git a/nuget/TestPackageUbuntu16.ps1 b/nuget/TestPackageUbuntu16.ps1 index 12a46db6..f9cd4ab1 100644 --- a/nuget/TestPackageUbuntu16.ps1 +++ b/nuget/TestPackageUbuntu16.ps1 @@ -37,6 +37,8 @@ $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 100; Package = "DlibDotNet.CUDA100"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 101; Package = "DlibDotNet.CUDA101"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 102; Package = "DlibDotNet.CUDA102"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 110; Package = "DlibDotNet.CUDA110"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Target = "cuda"; Architecture = 64; CUDA = 111; Package = "DlibDotNet.CUDA111"; PlatformTarget="x64"; Postfix = ""; RID = "$RidOperatingSystem-x64"; } foreach($BuildTarget in $BuildTargets) { @@ -75,7 +77,7 @@ foreach($BuildTarget in $BuildTargets) Write-Host "Docker API Version: $dockerAPIVersion" -ForegroundColor Yellow if ($dockerAPIVersion -ge 1.40) { - Write-Host "Start docker run --gpus all --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --gpus all --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --gpus all --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` @@ -84,7 +86,7 @@ foreach($BuildTarget in $BuildTargets) } else { - Write-Host "Start docker run --runtime=nvidia --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --runtime=nvidia --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --runtime=nvidia --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` @@ -94,7 +96,7 @@ foreach($BuildTarget in $BuildTargets) } else { - Write-Host "Start docker run --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $OperatingSystem $OperatingSystemVersion" -ForegroundColor Green + Write-Host "Start docker run --rm -v ""$($DlibDotNetRoot):/opt/data/DlibDotNet"" -e LOCAL_UID=$(id -u $env:USER) -e LOCAL_GID=$(id -g $env:USER) -t ""$dockername"" $Version $package $platformTarget $rid" -ForegroundColor Green docker run --rm ` -v "$($DlibDotNetRoot):/opt/data/DlibDotNet" ` -e "LOCAL_UID=$(id -u $env:USER)" ` diff --git a/nuget/TestPackageUniversalWindowsPlatform.ps1 b/nuget/TestPackageUniversalWindowsPlatform.ps1 index 5a416565..e564ff3f 100644 --- a/nuget/TestPackageUniversalWindowsPlatform.ps1 +++ b/nuget/TestPackageUniversalWindowsPlatform.ps1 @@ -21,9 +21,15 @@ Param([Parameter( $CertificateKeyFile, [Parameter( - Mandatory=$False, + Mandatory=$True, Position = 4 )][string] + $CertificatePassword, + + [Parameter( + Mandatory=$False, + Position = 5 + )][string] $NotCountAsFailTests ) @@ -38,7 +44,7 @@ $NugetPath = Join-Path $DlibDotNetRoot "nuget" $OperatingSystem="windows" $OperatingSystemVersion="10" $TargetTestProject = "DlibDotNet.UWP.Tests.csproj" -$MSBuildDir = "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64" +$MSBuildDir = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\amd64" $AppcertDir = "C:\Program Files (x86)\Windows Kits\10\App Certification Kit" $BuildTargets = @() $BuildTargets += New-Object PSObject -Property @{ Target = "cpu"; Architecture = "x64"; CUDA = 0; Package = "DlibDotNet.UWP" } @@ -117,6 +123,7 @@ function Build([string]$Architecture, [string]$OutputDir, [string]$Thumbprint, [ $command += " /p:AppxBundlePlatforms=""${Architecture}""" $command += " /p:AppxPackageSigningEnabled=true" $command += " /p:PackageCertificateThumbprint=${Thumbprint}" + $command += " /p:PackageCertificatePassword=${CertificatePassword}" $command += " /p:PackageCertificateKeyFile=""${CertificateKeyFile}""" Invoke-Expression "cmd.exe /c $command" diff --git a/nuget/TestPackageWindows.ps1 b/nuget/TestPackageWindows.ps1 index dd0be31c..176214e2 100644 --- a/nuget/TestPackageWindows.ps1 +++ b/nuget/TestPackageWindows.ps1 @@ -25,6 +25,8 @@ $BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA92"; $BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA100"; PlatformTarget="x64"; RID = "$OperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA101"; PlatformTarget="x64"; RID = "$OperatingSystem-x64"; } $BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA102"; PlatformTarget="x64"; RID = "$OperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA110"; PlatformTarget="x64"; RID = "$OperatingSystem-x64"; } +$BuildTargets += New-Object PSObject -Property @{Package = "DlibDotNet.CUDA111"; PlatformTarget="x64"; RID = "$OperatingSystem-x64"; } foreach($BuildTarget in $BuildTargets) { diff --git a/nuget/artifacts/cuda-110/runtimes/centos-x64/lib/.keepfolder b/nuget/artifacts/cuda-110/runtimes/centos-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/centos-x64/native/.keepfolder b/nuget/artifacts/cuda-110/runtimes/centos-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/linux-x64/lib/.keepfolder b/nuget/artifacts/cuda-110/runtimes/linux-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/linux-x64/native/.keepfolder b/nuget/artifacts/cuda-110/runtimes/linux-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/osx-x64/lib/.keepfolder b/nuget/artifacts/cuda-110/runtimes/osx-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/osx-x64/native/.keepfolder b/nuget/artifacts/cuda-110/runtimes/osx-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/win-x64/lib/.keepfolder b/nuget/artifacts/cuda-110/runtimes/win-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-110/runtimes/win-x64/native/.keepfolder b/nuget/artifacts/cuda-110/runtimes/win-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/centos-x64/lib/.keepfolder b/nuget/artifacts/cuda-111/runtimes/centos-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/centos-x64/native/.keepfolder b/nuget/artifacts/cuda-111/runtimes/centos-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/linux-x64/lib/.keepfolder b/nuget/artifacts/cuda-111/runtimes/linux-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/linux-x64/native/.keepfolder b/nuget/artifacts/cuda-111/runtimes/linux-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/osx-x64/lib/.keepfolder b/nuget/artifacts/cuda-111/runtimes/osx-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/osx-x64/native/.keepfolder b/nuget/artifacts/cuda-111/runtimes/osx-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/win-x64/lib/.keepfolder b/nuget/artifacts/cuda-111/runtimes/win-x64/lib/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/artifacts/cuda-111/runtimes/win-x64/native/.keepfolder b/nuget/artifacts/cuda-111/runtimes/win-x64/native/.keepfolder new file mode 100644 index 00000000..e69de29b diff --git a/nuget/nuspec/DlibDotNet.CPU.nuspec b/nuget/nuspec/DlibDotNet.CPU.nuspec index d774c142..cb23ba7f 100644 --- a/nuget/nuspec/DlibDotNet.CPU.nuspec +++ b/nuget/nuspec/DlibDotNet.CPU.nuspec @@ -2,7 +2,7 @@ DlibDotNet - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.CUDA-100.nuspec b/nuget/nuspec/DlibDotNet.CUDA-100.nuspec index 33ca8456..9c8eeefb 100644 --- a/nuget/nuspec/DlibDotNet.CUDA-100.nuspec +++ b/nuget/nuspec/DlibDotNet.CUDA-100.nuspec @@ -2,7 +2,7 @@ DlibDotNet.CUDA100 - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for CUDA 10.0 Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.CUDA-101.nuspec b/nuget/nuspec/DlibDotNet.CUDA-101.nuspec index 51fb454d..dab97f7b 100644 --- a/nuget/nuspec/DlibDotNet.CUDA-101.nuspec +++ b/nuget/nuspec/DlibDotNet.CUDA-101.nuspec @@ -2,7 +2,7 @@ DlibDotNet.CUDA101 - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for CUDA 10.1 Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.CUDA-102.nuspec b/nuget/nuspec/DlibDotNet.CUDA-102.nuspec index 1119ddc3..3363aa61 100644 --- a/nuget/nuspec/DlibDotNet.CUDA-102.nuspec +++ b/nuget/nuspec/DlibDotNet.CUDA-102.nuspec @@ -2,7 +2,7 @@ DlibDotNet.CUDA102 - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for CUDA 10.2 Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.CUDA-110.nuspec b/nuget/nuspec/DlibDotNet.CUDA-110.nuspec new file mode 100644 index 00000000..a5fce010 --- /dev/null +++ b/nuget/nuspec/DlibDotNet.CUDA-110.nuspec @@ -0,0 +1,53 @@ + + + + DlibDotNet.CUDA110 + 19.21.0.20201122 + DlibDotNet for CUDA 11.0 + Takuya Takeuchi + Takuya Takeuchi + true + LICENSE.txt + https://github.com/takuya-takeuchi/DlibDotNet + https://github.com/takuya-takeuchi/DlibDotNet/blob/master/nuget/ml128.png?raw=true + Dlib wrapper library written in C++ and C# for Windows, MacOS and Linux + +Requirements: Visual C++ 2017 Redistributable Package and cudnn 8 + + © Takuya Takeuchi 2017-2020 + dlib .net machinelearning + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nuget/nuspec/DlibDotNet.CUDA-111.nuspec b/nuget/nuspec/DlibDotNet.CUDA-111.nuspec new file mode 100644 index 00000000..35123eb0 --- /dev/null +++ b/nuget/nuspec/DlibDotNet.CUDA-111.nuspec @@ -0,0 +1,53 @@ + + + + DlibDotNet.CUDA111 + 19.21.0.20201122 + DlibDotNet for CUDA 11.1 + Takuya Takeuchi + Takuya Takeuchi + true + LICENSE.txt + https://github.com/takuya-takeuchi/DlibDotNet + https://github.com/takuya-takeuchi/DlibDotNet/blob/master/nuget/ml128.png?raw=true + Dlib wrapper library written in C++ and C# for Windows, MacOS and Linux + +Requirements: Visual C++ 2017 Redistributable Package and cudnn 8 + + © Takuya Takeuchi 2017-2020 + dlib .net machinelearning + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nuget/nuspec/DlibDotNet.CUDA-92.nuspec b/nuget/nuspec/DlibDotNet.CUDA-92.nuspec index e2e38631..73c80b9f 100644 --- a/nuget/nuspec/DlibDotNet.CUDA-92.nuspec +++ b/nuget/nuspec/DlibDotNet.CUDA-92.nuspec @@ -2,7 +2,7 @@ DlibDotNet.CUDA92 - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for CUDA 9.2 Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.MKL.nuspec b/nuget/nuspec/DlibDotNet.MKL.nuspec index 0c1a3495..960a5c25 100644 --- a/nuget/nuspec/DlibDotNet.MKL.nuspec +++ b/nuget/nuspec/DlibDotNet.MKL.nuspec @@ -2,7 +2,7 @@ DlibDotNet.MKL - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for MKL Takuya Takeuchi Takuya Takeuchi diff --git a/nuget/nuspec/DlibDotNet.UWP.nuspec b/nuget/nuspec/DlibDotNet.UWP.nuspec index 57dda5f0..bf9aa8f1 100644 --- a/nuget/nuspec/DlibDotNet.UWP.nuspec +++ b/nuget/nuspec/DlibDotNet.UWP.nuspec @@ -2,7 +2,7 @@ DlibDotNet.UWP - 19.20.0.20200725 + 19.21.0.20201122 DlibDotNet for UWP Takuya Takeuchi Takuya Takeuchi diff --git a/src/DlibDotNet.Native.Dnn/Build.ps1 b/src/DlibDotNet.Native.Dnn/Build.ps1 index da43feb4..66eb4aac 100644 --- a/src/DlibDotNet.Native.Dnn/Build.ps1 +++ b/src/DlibDotNet.Native.Dnn/Build.ps1 @@ -5,7 +5,7 @@ #%3: Architecture (32/64) #%4: Platform (desktop,android/ios/uwp) #%5: Optional Argument -# if Target is cuda, CUDA version if Target is cuda [90/91/92/100/101] +# 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 diff --git a/src/DlibDotNet.Native.Dnn/CMakeLists.txt b/src/DlibDotNet.Native.Dnn/CMakeLists.txt index 15fc4b51..394c3432 100644 --- a/src/DlibDotNet.Native.Dnn/CMakeLists.txt +++ b/src/DlibDotNet.Native.Dnn/CMakeLists.txt @@ -4,7 +4,8 @@ cmake_policy(SET CMP0054 NEW) set(PROJ_NAME DlibDotNetNativeDnn) -project(${PROJ_NAME} VERSION 19.18.0) +# It means that CMakeLists.txt version rather than library version +project(${PROJ_NAME} VERSION 1.0.0) # OS info message("-------------------------------------------------------") @@ -22,9 +23,9 @@ message("-------------------------------------------------------") # Version info set(VERSION_MAJOR 19) -set(VERSION_MINOR 20) +set(VERSION_MINOR 21) set(VERSION_PATCH 0) -set(VERSION_DATE 20200725) +set(VERSION_DATE 20201122) # Only GCC requires -fPIC if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") diff --git a/src/DlibDotNet.Native/Build.ps1 b/src/DlibDotNet.Native/Build.ps1 index da43feb4..66eb4aac 100644 --- a/src/DlibDotNet.Native/Build.ps1 +++ b/src/DlibDotNet.Native/Build.ps1 @@ -5,7 +5,7 @@ #%3: Architecture (32/64) #%4: Platform (desktop,android/ios/uwp) #%5: Optional Argument -# if Target is cuda, CUDA version if Target is cuda [90/91/92/100/101] +# 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 diff --git a/src/DlibDotNet.Native/CMakeLists.txt b/src/DlibDotNet.Native/CMakeLists.txt index 0dc0ca09..ab66843c 100644 --- a/src/DlibDotNet.Native/CMakeLists.txt +++ b/src/DlibDotNet.Native/CMakeLists.txt @@ -4,7 +4,8 @@ cmake_policy(SET CMP0054 NEW) set(PROJ_NAME DlibDotNetNative) -project(${PROJ_NAME} VERSION 19.18.0) +# It means that CMakeLists.txt version rather than library version +project(${PROJ_NAME} VERSION 1.0.0) # OS info message("-------------------------------------------------------") @@ -22,9 +23,9 @@ message("-------------------------------------------------------") # Version info set(VERSION_MAJOR 19) -set(VERSION_MINOR 20) +set(VERSION_MINOR 21) set(VERSION_PATCH 0) -set(VERSION_DATE 20200725) +set(VERSION_DATE 20201122) # libjpeg-dev, libpng-dev set(DLIB_JPEG_SUPPORT True) diff --git a/src/DlibDotNet.Native/dlib/image_loader/load_png.h b/src/DlibDotNet.Native/dlib/image_loader/load_png.h index 038d3b2a..b8902729 100644 --- a/src/DlibDotNet.Native/dlib/image_loader/load_png.h +++ b/src/DlibDotNet.Native/dlib/image_loader/load_png.h @@ -14,12 +14,15 @@ using namespace std; #define load_png_template(__TYPE__, error, type, ...) \ dlib::load_png(*((array2d<__TYPE__>*)image), std::string(file_name, file_name_length)); +#define load_png_from_buffer_template(__TYPE__, error, type, ...) \ +dlib::load_png(*((array2d<__TYPE__>*)image), image_buffer, image_buffer_length); + #pragma endregion template DLLEXPORT int load_png(array2d_type type, void* image, const char* file_name, - const int file_name_length, + const uint32_t file_name_length, std::string** error_message) { int error = ERR_OK; @@ -42,4 +45,30 @@ DLLEXPORT int load_png(array2d_type type, return error; } +DLLEXPORT int load_png_from_buffer(array2d_type type, + void* image, + const uint8_t* image_buffer, + const uint32_t image_buffer_length, + std::string** error_message) +{ + int error = ERR_OK; + + try + { + array2d_template(type, + error, + load_png_from_buffer_template, + image, + image_buffer, + image_buffer_length); + } + catch(dlib::image_load_error& e) + { + error = ERR_GENERAL_IMAGE_LOAD; + *error_message = new std::string(e.what()); + } + + return error; +} + #endif \ No newline at end of file diff --git a/src/DlibDotNet/Dlib.cs b/src/DlibDotNet/Dlib.cs index 37e8bce0..3e6e6c10 100644 --- a/src/DlibDotNet/Dlib.cs +++ b/src/DlibDotNet/Dlib.cs @@ -440,12 +440,42 @@ public static Array2D LoadPng(string path) var array2DType = image.ImageType.ToNativeArray2DType(); var ret = NativeMethods.load_png(array2DType, image.NativePtr, str, str.Length, out var errorMessage); - switch (ret) - { - case NativeMethods.ErrorType.Array2DTypeTypeNotSupport: - throw new ArgumentException($"{image.ImageType} is not supported."); - case NativeMethods.ErrorType.GeneralFileImageLoad: - throw new ImageLoadException(path, StringHelper.FromStdString(errorMessage)); + switch (ret) + { + case NativeMethods.ErrorType.Array2DTypeTypeNotSupport: + throw new ArgumentException($"{image.ImageType} is not supported."); + case NativeMethods.ErrorType.GeneralFileImageLoad: + throw new ImageLoadException(path, StringHelper.FromStdString(errorMessage)); + } + + return image; + } + + /// + /// This function loads PNG (Portable Network Graphics) file into an . + /// + /// The type of element in the image. + /// A byte array that contains png image data from which to create the . + /// The this method creates. + /// The specified type of image is not supported. + /// is null. + /// Failed to load image on dlib. + public static Array2D LoadPng(byte[] png) + where T : struct + { + if (png == null) + throw new ArgumentNullException(nameof(png)); + + var image = new Array2D(); + + var array2DType = image.ImageType.ToNativeArray2DType(); + var ret = NativeMethods.load_png_from_buffer(array2DType, image.NativePtr, png, png.Length, out var errorMessage); + switch (ret) + { + case NativeMethods.ErrorType.Array2DTypeTypeNotSupport: + throw new ArgumentException($"{image.ImageType} is not supported."); + case NativeMethods.ErrorType.GeneralFileImageLoad: + throw new ImageLoadException(StringHelper.FromStdString(errorMessage)); } return image; @@ -453,6 +483,24 @@ public static Array2D LoadPng(string path) #region LoadImageData + public static Array2D LoadImageData(IntPtr data, uint rows, uint columns, uint steps) + where T : struct + { + if (data == IntPtr.Zero) + throw new ArgumentException(nameof(data)); + + if (!Array2D.TryParse(out var type)) + throw new NotSupportedException(); + + var srcType = type.ToNativeArray2DType(); + var dstType = type.ToNativeArray2DType(); + var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); + if (ret == IntPtr.Zero) + throw new ArgumentException($"Can not import from pointer to {dstType}."); + + return new Array2D(ret, type); + } + public static Array2D LoadImageData(byte[] data, uint rows, uint columns, uint steps) where T : struct { @@ -471,6 +519,34 @@ public static Array2D LoadImageData(byte[] data, uint rows, uint columns, return new Array2D(ret, type); } + public static Array2D LoadImageData(byte[] data, uint rows, uint columns, uint steps) + { + if (data == null) + throw new ArgumentNullException(nameof(data)); + + var srcType = ImageTypes.UInt8.ToNativeArray2DType(); + var dstType = ImageTypes.UInt8.ToNativeArray2DType(); + var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); + if (ret == IntPtr.Zero) + throw new ArgumentException($"Can not import from {ImageTypes.UInt8} to {dstType}."); + + return new Array2D(ret, ImageTypes.UInt8); + } + + //public static Array2D LoadImageData(sbyte[] data, uint rows, uint columns, uint steps) + //{ + // if (data == null) + // throw new ArgumentNullException(nameof(data)); + + // var srcType = ImageTypes.Int8.ToNativeArray2DType(); + // var dstType = ImageTypes.Int8.ToNativeArray2DType(); + // var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); + // if (ret == IntPtr.Zero) + // throw new ArgumentException($"Can not import from {ImageTypes.Int8} to {dstType}."); + + // return new Array2D(ret, ImageTypes.Int8); + //} + public static Array2D LoadImageData(ImagePixelFormat format, byte[] data, uint rows, uint columns, uint steps) where T : struct { @@ -490,184 +566,144 @@ public static Array2D LoadImageData(ImagePixelFormat format, byte[] data, return new Array2D(ret, type); } - public static Array2D LoadImageData(ushort[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(ushort[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.UInt16.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.UInt16.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.UInt16} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.UInt16); } - public static Array2D LoadImageData(short[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(short[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.Int16.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.Int16.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.Int16} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.Int16); } - public static Array2D LoadImageData(int[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(int[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.Int32.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.Int32.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.Int32} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.Int32); } - public static Array2D LoadImageData(float[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(float[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.Float.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.Float.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.Float} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.Float); } - public static Array2D LoadImageData(double[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(double[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.Double.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.Double.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.Double} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.Double); } - public static Array2D LoadImageData(RgbPixel[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(RgbPixel[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.RgbPixel.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.RgbPixel.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.RgbPixel} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.RgbPixel); } - public static Array2D LoadImageData(BgrPixel[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(BgrPixel[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.BgrPixel.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.BgrPixel.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.BgrPixel} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.BgrPixel); } - public static Array2D LoadImageData(RgbAlphaPixel[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(RgbAlphaPixel[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.RgbAlphaPixel.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.RgbAlphaPixel.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.RgbAlphaPixel} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.RgbAlphaPixel); } - public static Array2D LoadImageData(HsiPixel[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(HsiPixel[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.HsiPixel.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.HsiPixel.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.HsiPixel} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.HsiPixel); } - public static Array2D LoadImageData(LabPixel[] data, uint rows, uint columns, uint steps) - where T : struct + public static Array2D LoadImageData(LabPixel[] data, uint rows, uint columns, uint steps) { if (data == null) throw new ArgumentNullException(nameof(data)); - if (!Array2D.TryParse(out var type)) - throw new NotSupportedException(); - var srcType = ImageTypes.LabPixel.ToNativeArray2DType(); - var dstType = type.ToNativeArray2DType(); + var dstType = ImageTypes.LabPixel.ToNativeArray2DType(); var ret = NativeMethods.extensions_load_image_data(dstType, srcType, data, rows, columns, steps); if (ret == IntPtr.Zero) throw new ArgumentException($"Can not import from {ImageTypes.LabPixel} to {dstType}."); - return new Array2D(ret, type); + return new Array2D(ret, ImageTypes.LabPixel); } #endregion diff --git a/src/DlibDotNet/ImageLoadException.cs b/src/DlibDotNet/ImageLoadException.cs index 422fa05b..376df250 100644 --- a/src/DlibDotNet/ImageLoadException.cs +++ b/src/DlibDotNet/ImageLoadException.cs @@ -11,6 +11,11 @@ public sealed class ImageLoadException : Exception #region Constructors + internal ImageLoadException(string message) : + base(message) + { + } + internal ImageLoadException(string filepath, string message): base(message) { diff --git a/src/DlibDotNet/PInvoke/Dlib.cs b/src/DlibDotNet/PInvoke/Dlib.cs index 79d10a68..ef7bde23 100644 --- a/src/DlibDotNet/PInvoke/Dlib.cs +++ b/src/DlibDotNet/PInvoke/Dlib.cs @@ -595,7 +595,10 @@ public static extern ErrorType object_detector_scan_fhog_pyramid_serialize(byte[ #region extensions - #region extensions_load_image_data + #region extensions_load_image_data + + [DllImport(NativeLibrary, CallingConvention = CallingConvention)] + public static extern IntPtr extensions_load_image_data(Array2DType dst_type, Array2DType src_type, IntPtr data, uint rows, uint columns, uint steps); [DllImport(NativeLibrary, CallingConvention = CallingConvention)] public static extern IntPtr extensions_load_image_data(Array2DType dst_type, Array2DType src_type, byte[] data, uint rows, uint columns, uint steps); diff --git a/src/DlibDotNet/PInvoke/ImageLoader/LoadPng.cs b/src/DlibDotNet/PInvoke/ImageLoader/LoadPng.cs index 410bf902..e94d54a5 100644 --- a/src/DlibDotNet/PInvoke/ImageLoader/LoadPng.cs +++ b/src/DlibDotNet/PInvoke/ImageLoader/LoadPng.cs @@ -11,6 +11,9 @@ internal sealed partial class NativeMethods [DllImport(NativeLibrary, CallingConvention = CallingConvention)] public static extern ErrorType load_png(Array2DType type, IntPtr array, byte[] path, int pathLength, out IntPtr error_message); + [DllImport(NativeLibrary, CallingConvention = CallingConvention)] + public static extern ErrorType load_png_from_buffer(Array2DType type, IntPtr array, byte[] image, int imageLength, out IntPtr error_message); + } } \ No newline at end of file diff --git a/test/DlibDotNet.Tests/DlibTest.cs b/test/DlibDotNet.Tests/DlibTest.cs index 14ecbf9d..60b0a05e 100644 --- a/test/DlibDotNet.Tests/DlibTest.cs +++ b/test/DlibDotNet.Tests/DlibTest.cs @@ -803,6 +803,86 @@ public void LoadPng() } } + [Fact] + public void LoadPngFromBuffer() + { + const int cols = LoadTargetWidth; + const int rows = LoadTargetHeight; + var path = this.GetDataFile($"{LoadTarget}.png"); + + var tests = new[] + { + new { Type = ImageTypes.BgrPixel, ExpectResult = true}, + new { Type = ImageTypes.RgbPixel, ExpectResult = true}, + new { Type = ImageTypes.RgbAlphaPixel, ExpectResult = true}, + new { Type = ImageTypes.UInt8, ExpectResult = true}, + new { Type = ImageTypes.UInt16, ExpectResult = true}, + new { Type = ImageTypes.UInt32, ExpectResult = true}, + new { Type = ImageTypes.Int8, ExpectResult = true}, + new { Type = ImageTypes.Int16, ExpectResult = true}, + new { Type = ImageTypes.Int32, ExpectResult = true}, + new { Type = ImageTypes.HsiPixel, ExpectResult = true}, + new { Type = ImageTypes.LabPixel, ExpectResult = true}, + new { Type = ImageTypes.Float, ExpectResult = true}, + new { Type = ImageTypes.Double, ExpectResult = true} + }; + + var png = File.ReadAllBytes(path.FullName); + foreach (var test in tests) + { + TwoDimensionObjectBase image; + switch (test.Type) + { + case ImageTypes.BgrPixel: + image = Dlib.LoadPng(png); + break; + case ImageTypes.RgbPixel: + image = Dlib.LoadPng(png); + break; + case ImageTypes.RgbAlphaPixel: + image = Dlib.LoadPng(png); + break; + case ImageTypes.UInt8: + image = Dlib.LoadPng(png); + break; + case ImageTypes.UInt16: + image = Dlib.LoadPng(png); + break; + case ImageTypes.UInt32: + image = Dlib.LoadPng(png); + break; + case ImageTypes.Int8: + image = Dlib.LoadPng(png); + break; + case ImageTypes.Int16: + image = Dlib.LoadPng(png); + break; + case ImageTypes.Int32: + image = Dlib.LoadPng(png); + break; + case ImageTypes.HsiPixel: + image = Dlib.LoadPng(png); + break; + case ImageTypes.LabPixel: + image = Dlib.LoadPng(png); + break; + case ImageTypes.Float: + image = Dlib.LoadPng(png); + break; + case ImageTypes.Double: + image = Dlib.LoadPng(png); + break; + default: + throw new ArgumentOutOfRangeException(); + } + + Assert.True(image.Columns == cols, $"Failed to load {test.Type}."); + Assert.True(image.Rows == rows, $"Failed to load {test.Type}."); + + this.DisposeAndCheckDisposedState(image); + } + } + #endregion #region SaveBmp @@ -2392,7 +2472,7 @@ public void LoadImageData() switch (test.Type) { case ImageTypes.UInt8: - image = Dlib.LoadImageData(data, 512, 512, 512); + image = Dlib.LoadImageData(data, 512, 512, 512); if (this.CanGuiDebug) { @@ -2437,6 +2517,268 @@ public void LoadImageData2() const int rows = 512; const int steps = 512; + var tests = new[] + { + new { Type = ImageTypes.UInt8, ExpectResult = true}, + new { Type = ImageTypes.UInt16, ExpectResult = true}, + //new { Type = ImageTypes.Int8, ExpectResult = true}, + new { Type = ImageTypes.Int16, ExpectResult = true}, + new { Type = ImageTypes.Int32, ExpectResult = true}, + new { Type = ImageTypes.HsiPixel, ExpectResult = true}, + new { Type = ImageTypes.LabPixel, ExpectResult = true}, + new { Type = ImageTypes.BgrPixel, ExpectResult = true}, + new { Type = ImageTypes.RgbPixel, ExpectResult = true}, + new { Type = ImageTypes.RgbAlphaPixel, ExpectResult = true}, + new { Type = ImageTypes.Float, ExpectResult = true}, + new { Type = ImageTypes.Double, ExpectResult = true} + }; + + var random = new Random(0); + + foreach (var test in tests) + { + TwoDimensionObjectBase image; + using (var win = new ImageWindow()) + { + switch (test.Type) + { + case ImageTypes.UInt8: + { + var data = new byte[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = (byte)random.Next(0, 255); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + //case ImageTypes.Int8: + // { + // var data = new sbyte[rows * cols]; + // for (var r = 0; r < rows; r++) + // for (var c = 0; c < cols; c++) + // data[steps * r + c] = (sbyte)random.Next(sbyte.MinValue, sbyte.MaxValue); + + // image = Dlib.LoadImageData(data, rows, cols, steps); + + // if (this.CanGuiDebug) + // { + // win.SetImage((Array2D)image); + // win.WaitUntilClosed(); + // } + // } + // break; + case ImageTypes.UInt16: + { + var data = new ushort[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = (ushort)random.Next(0, 255); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.Int16: + { + var data = new short[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = (short)random.Next(0, 255); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.Int32: + { + var data = new int[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = random.Next(0, 255); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.Float: + { + var data = new float[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = (float)random.NextDouble(); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.Double: + { + var data = new double[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = random.NextDouble(); + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.HsiPixel: + { + var data = new HsiPixel[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = new HsiPixel + { + H = (byte)random.Next(0, 255), + S = (byte)random.Next(0, 255), + I = (byte)random.Next(0, 255) + }; + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.LabPixel: + { + var data = new LabPixel[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = new LabPixel + { + L = (byte)random.Next(0, 255), + A = (byte)random.Next(0, 255), + B = (byte)random.Next(0, 255) + }; + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.BgrPixel: + { + var data = new BgrPixel[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = new BgrPixel + { + Red = (byte)random.Next(0, 255), + Green = (byte)random.Next(0, 255), + Blue = (byte)random.Next(0, 255) + }; + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.RgbPixel: + { + var data = new RgbPixel[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = new RgbPixel + { + Red = (byte)random.Next(0, 255), + Green = (byte)random.Next(0, 255), + Blue = (byte)random.Next(0, 255) + }; + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + case ImageTypes.RgbAlphaPixel: + { + var data = new RgbAlphaPixel[rows * cols]; + for (var r = 0; r < rows; r++) + for (var c = 0; c < cols; c++) + data[steps * r + c] = new RgbAlphaPixel + { + Red = (byte)random.Next(0, 255), + Green = (byte)random.Next(0, 255), + Blue = (byte)random.Next(0, 255), + Alpha = (byte)random.Next(0, 255) + }; + + image = Dlib.LoadImageData(data, rows, cols, steps); + + if (this.CanGuiDebug) + { + win.SetImage((Array2D)image); + win.WaitUntilClosed(); + } + } + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + Assert.True(image.Columns == cols, $"Failed to load {test.Type}."); + Assert.True(image.Rows == rows, $"Failed to load {test.Type}."); + + this.DisposeAndCheckDisposedState(image); + } + } + + [Fact] + public unsafe void LoadImageDataPointer() + { + const int cols = 512; + const int rows = 512; + const int steps = 512; + var tests = new[] { new { Type = ImageTypes.UInt8, ExpectResult = true}, @@ -2468,7 +2810,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = (byte)random.Next(0, 255); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (byte* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2484,7 +2827,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = (ushort)random.Next(0, 255); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (ushort* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2500,7 +2844,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = (short)random.Next(0, 255); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (short* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2516,7 +2861,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = random.Next(0, 255); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (int* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2532,7 +2878,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = (float)random.NextDouble(); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (float* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2548,7 +2895,8 @@ public void LoadImageData2() for (var c = 0; c < cols; c++) data[steps * r + c] = random.NextDouble(); - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (double* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2569,7 +2917,8 @@ public void LoadImageData2() I = (byte)random.Next(0, 255) }; - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (HsiPixel* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2590,7 +2939,8 @@ public void LoadImageData2() B = (byte)random.Next(0, 255) }; - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (LabPixel* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2611,7 +2961,8 @@ public void LoadImageData2() Blue = (byte)random.Next(0, 255) }; - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (BgrPixel* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2632,7 +2983,8 @@ public void LoadImageData2() Blue = (byte)random.Next(0, 255) }; - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (RgbPixel* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { @@ -2654,7 +3006,8 @@ public void LoadImageData2() Alpha = (byte)random.Next(0, 255) }; - image = Dlib.LoadImageData(data, rows, cols, steps); + fixed (RgbAlphaPixel* p = &data[0]) + image = Dlib.LoadImageData((IntPtr)p, rows, cols, steps); if (this.CanGuiDebug) { diff --git a/test/DlibDotNet.UWP.Tests/DlibDotNet.UWP.Tests.csproj b/test/DlibDotNet.UWP.Tests/DlibDotNet.UWP.Tests.csproj index e1ac08ca..f6bcd6f3 100644 --- a/test/DlibDotNet.UWP.Tests/DlibDotNet.UWP.Tests.csproj +++ b/test/DlibDotNet.UWP.Tests/DlibDotNet.UWP.Tests.csproj @@ -11,7 +11,7 @@ DlibDotNet.UWP.Tests ja-JP UAP - 10.0.17134.0 + 10.0.18362.0 10.0.17134.0 14 512 @@ -139,10 +139,10 @@ - 19.17.0.20190730-pre + 19.21.0.20201122 - 6.2.8 + 6.2.11