From 3b8bd7f9478275dd1f63f8ba0ad1761ce69ef28c Mon Sep 17 00:00:00 2001 From: ChrisMaunder Date: Thu, 18 Aug 2022 20:56:48 -0400 Subject: [PATCH] V1.5.6.2. Bug fixes, perf improvements, and more CUDA support --- .vscode/tasks.json | 18 +++- .wslconfig | 11 ++ CodeProject.AI.sln | 24 +++-- Installers/Dev/setup_dev_env_linux.sh | 2 +- README.md | 5 +- THIRD-PARTY-NOTICES.md | 1 + .../Server/FrontEnd/BackendProcessRunner.cs | 53 +++++++--- .../FrontEnd/Config/ModuleCollection.cs | 42 ++------ .../FrontEnd/Controllers/LogController.cs | 8 ++ .../FrontEnd/Controllers/StatusController.cs | 5 +- src/API/Server/FrontEnd/Dockerfile | 100 ------------------ src/API/Server/FrontEnd/Frontend.csproj | 2 +- src/API/Server/FrontEnd/Program.cs | 4 +- src/API/Server/FrontEnd/Startup.cs | 11 +- src/API/Server/FrontEnd/appsettings.json | 5 +- src/API/Server/FrontEnd/installconfig.json | 5 - src/API/Server/FrontEnd/version.json | 6 +- src/API/Server/FrontEnd/wwwroot/Index.html | 8 +- .../BackgroundRemover.pyproj | 5 +- .../CustomDetection/detect_adapter.py | 14 +-- .../CustomDetection/models/experimental.py | 10 +- .../CustomDetection/modulesettings.json | 2 + .../CustomDetection/requirements.macos.txt | 9 +- .../ObjectDetectionNet.csproj | 3 +- .../ObjectDetectionNet/ObjectDetector.cs | 18 ++-- .../ObjectDetectionNet/Program.cs | 3 + .../Properties/launchSettings.json | 2 +- .../ObjectDetectionNet/YoloProcessor.cs | 6 +- .../ObjectDetectionNet/install.sh | 2 +- .../modulesettings.docker.json | 4 +- .../ObjectDetectionNet/modulesettings.json | 11 +- .../runtimeconfig.template..json | 5 + .../PortraitFilter/PortraitFilter.csproj | 2 +- .../PortraitFilter/PortraitFilterWorker.cs | 20 ++-- .../Properties/launchSettings.json | 2 +- .../PortraitFilter/modulesettings.docker.json | 4 +- .../PortraitFilter/modulesettings.json | 4 +- .../Yolov5Net.Scorer/Yolov5Net.Scorer.csproj | 6 +- src/AnalysisLayer/SDK/Python/CodeProjectAI.py | 11 +- src/AnalysisLayer/SDK/Python/common.py | 31 +++++- src/AnalysisLayer/SDK/install.bat | 2 +- src/AnalysisLayer/SDK/install.sh | 34 ++++++ .../SentimentAnalysis.csproj | 2 +- .../SentimentAnalysis/modulesettings.json | 8 +- .../Vision/intelligencelayer/detection.py | 6 +- .../Vision/intelligencelayer/face.py | 8 +- .../intelligencelayer/models/experimental.py | 10 +- .../Vision/intelligencelayer/scene.py | 4 +- .../Vision/intelligencelayer/shared.py | 12 +-- .../Vision/modulesettings.docker.json | 5 +- src/AnalysisLayer/Vision/modulesettings.json | 19 ++-- src/AnalysisLayer/Vision/requirements.txt | 18 +++- src/AnalysisLayer/start-analysis.bat | 6 +- src/AnalysisLayer/start-analysis.sh | 8 +- ...Project.AI.API.Server.Backend.Tests.csproj | 29 +++++ 55 files changed, 373 insertions(+), 282 deletions(-) create mode 100644 .wslconfig delete mode 100644 src/API/Server/FrontEnd/Dockerfile delete mode 100644 src/API/Server/FrontEnd/installconfig.json create mode 100644 src/AnalysisLayer/ObjectDetectionNet/runtimeconfig.template..json create mode 100644 tests/QueueServiceTests/CodeProject.AI.API.Server.Backend.Tests.csproj diff --git a/.vscode/tasks.json b/.vscode/tasks.json index b84be114..d9ffdf5f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -88,6 +88,20 @@ "problemMatcher": "$msCompile" }, + { + "label": "build-tests", // Builds ONLY the .NET unit tests + "type": "process", + "group": "build", + "command": "dotnet", + "args": [ + "build", + "${workspaceFolder}/tests/QueueServiceTests", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { "label": "build-all-linux", // Builds all projects that can be built for Linux (ie not any Windows Forms apps) "group": "build", @@ -95,6 +109,7 @@ "dependsOn": [ "build-server", "build-analysisservices", + "build-tests" ] }, @@ -105,7 +120,8 @@ "dependsOn": [ "build-server", "build-analysisservices", - "build-explorer" + "build-explorer", + "build-tests" ] }, diff --git a/.wslconfig b/.wslconfig new file mode 100644 index 00000000..a0c5b4d4 --- /dev/null +++ b/.wslconfig @@ -0,0 +1,11 @@ +# Place this into /users/ + +# Settings apply across all Linux distros running on WSL 2 +[wsl2] + +# Limits VM memory to use no more than 12 GB, this can be set as whole numbers using GB or MB +# The default is 50% of available RAM and 8GB isn't (currently) enough for CodeProject AI Server GPU +memory=12GB + +# Sets amount of swap storage space to 8GB, default is 25% of available RAM +swap=8GB \ No newline at end of file diff --git a/CodeProject.AI.sln b/CodeProject.AI.sln index 0d9e5848..cc8ef245 100644 --- a/CodeProject.AI.sln +++ b/CodeProject.AI.sln @@ -24,6 +24,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AnalysisLayer", "AnalysisLa EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Installers", "Installers", "{D885EE64-C1BD-44D6-84D8-1E46806298D9}" + ProjectSection(SolutionItems) = preProject + Installers\install_CUDnn.bat = Installers\install_CUDnn.bat + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Javascript", "Javascript", "{3A860CDD-94B9-4002-BA08-87E8822DDE50}" ProjectSection(SolutionItems) = preProject @@ -64,7 +67,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "assets", "assets", "{CB26AB EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{460DB5C8-46F3-4407-A2DF-D9063D14493A}" ProjectSection(SolutionItems) = preProject - commands.json = commands.json src\endtimer.bat = src\endtimer.bat src\kill_dotnet.bat = src\kill_dotnet.bat src\kill_dotnet.sh = src\kill_dotnet.sh @@ -193,7 +195,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Objects", "Objects", "{4ED5 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ObjectDetectionNet", "src\AnalysisLayer\ObjectDetectionNet\ObjectDetectionNet.csproj", "{25D75AFE-BEC9-43BF-BE44-B9068FF8E395}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.API.Server.Backend.Tests", "tests\QueueServiceTests\CodeProject.SenseAI.API.Server.Backend.Tests.csproj", "{F94FBD1C-02FB-4169-8C26-2D52234D4311}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.AI.API.Server.Backend.Tests", "tests\QueueServiceTests\CodeProject.AI.API.Server.Backend.Tests.csproj", "{031F17E0-BE84-42AF-B9FE-4F928CB03D1B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -299,14 +301,14 @@ Global {25D75AFE-BEC9-43BF-BE44-B9068FF8E395}.Release|Any CPU.Build.0 = Release|Any CPU {25D75AFE-BEC9-43BF-BE44-B9068FF8E395}.Release|x86.ActiveCfg = Release|Any CPU {25D75AFE-BEC9-43BF-BE44-B9068FF8E395}.Release|x86.Build.0 = Release|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.ActiveCfg = Debug|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Debug|x86.Build.0 = Debug|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|Any CPU.Build.0 = Release|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.ActiveCfg = Release|Any CPU - {F94FBD1C-02FB-4169-8C26-2D52234D4311}.Release|x86.Build.0 = Release|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Debug|x86.ActiveCfg = Debug|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Debug|x86.Build.0 = Debug|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Release|Any CPU.Build.0 = Release|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Release|x86.ActiveCfg = Release|Any CPU + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -346,7 +348,7 @@ Global {C2EFFA0A-E8EA-4AFE-8599-FC28CB7864FB} = {B10B59B5-9F63-41C2-BFBB-6C7311DC4E99} {4ED567B5-C28D-48BB-AEDC-864E2B2C7204} = {B10B59B5-9F63-41C2-BFBB-6C7311DC4E99} {25D75AFE-BEC9-43BF-BE44-B9068FF8E395} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893} - {F94FBD1C-02FB-4169-8C26-2D52234D4311} = {D982BD8C-2257-413B-8513-8043AB3035F3} + {031F17E0-BE84-42AF-B9FE-4F928CB03D1B} = {D982BD8C-2257-413B-8513-8043AB3035F3} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {83740BD9-AEEF-49C7-A722-D7703D3A38CB} diff --git a/Installers/Dev/setup_dev_env_linux.sh b/Installers/Dev/setup_dev_env_linux.sh index 6fc4e8f8..9a5e6604 100644 --- a/Installers/Dev/setup_dev_env_linux.sh +++ b/Installers/Dev/setup_dev_env_linux.sh @@ -56,7 +56,7 @@ useColor="true" enableGPU="false" # are we ready to support CUDA enabled GPUs? -ssupportCUDA="false" +supportCUDA="false" # verbosity can be: quiet | info | loud verbosity="quiet" diff --git a/README.md b/README.md index 4fdbf0c0..ee165009 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ transfer, and is easy to use. + # Why 1. AI programming is something every single developer should be aware of. We wanted a fun project we could use to help teach developers and get them involved in AI. We'll be using CodeProject.AI as a focus for articles and exploration to make it fun and painless to learn AI programming. @@ -90,7 +91,7 @@ It can detect stuff! CodeProject.AI can currently -- Detect objects in images +- Detect objects in images, including using custom models - Detect faces in images - Detect the type of scene represented in an image - Recognise faces that have been registered with the service @@ -112,13 +113,11 @@ We will be constantly expanding the feature list. #### Supported Development Environments - This current release works in Visual Studio 2019+ on Windows 10+, and Visual Studio Code on Windows 10+. Ubuntu and macOS (both Intel and Apple Silicon). The current release supports CPU on each platform, as well as nVidia CUDA GPUs on Windows. Future releases will expand GPU support to Docker and other cards. - ## How to Guides - [Installing CodeProject.AI on your machine](https://www.codeproject.com/ai/docs/why/install_on_windows.html). For those who have CodeProject.AI integrated with Home Assist or Blue Iris diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index ffaa61ce..397f3a29 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -352,6 +352,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + ### Swashbuckle.AspNetCore ##### Generate beautiful API documentation https://github.com/domaindrivendev/Swashbuckle.AspNetCore diff --git a/src/API/Server/FrontEnd/BackendProcessRunner.cs b/src/API/Server/FrontEnd/BackendProcessRunner.cs index f0853c7b..d25e36ec 100644 --- a/src/API/Server/FrontEnd/BackendProcessRunner.cs +++ b/src/API/Server/FrontEnd/BackendProcessRunner.cs @@ -265,7 +265,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) loggerIsValid = false; } - bool launchAnalysisServices = _config.GetValue("LaunchAnalysisServices", true); + bool launchAnalysisServices = _config.GetValue("LaunchAnalysisServices", true); + int launchAnalysisServicesDelaySecs = _config.GetValue("LaunchAnalysisServicesDelaySecs", 3); // Setup routes. Do this first so they are active during debug without launching services. foreach (var entry in _modules!) @@ -310,7 +311,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) // Let's make sure the front end is up and running before we start the backend // analysis services - await Task.Delay(TimeSpan.FromSeconds(3), stoppingToken); + await Task.Delay(TimeSpan.FromSeconds(launchAnalysisServicesDelaySecs), stoppingToken); if (loggerIsValid) { @@ -337,7 +338,13 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) continue; if (status.Status == ProcessStatusType.NotEnabled) - _logger.LogWarning($"Not starting {module.Name} (Not set as enabled)"); + { + // _logger.LogWarning($"Not starting {module.Name} (Not set as enabled)"); + } + else + { + _logger.LogWarning($"Attempting to start {module.Name}, Runtime: {module.Runtime}, FilePath: {module.FilePath}"); + } if (status.Status == ProcessStatusType.Enabled && !string.IsNullOrEmpty(module.FilePath)) { @@ -348,11 +355,11 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) if (!string.IsNullOrWhiteSpace(routeInfo.Queue)) _queueServices.EnsureQueueExists(routeInfo.Queue); - ProcessStartInfo procStartInfo = CreateProcessStartInfo(module, moduleId); - - // Start the process try { + // Start the process + ProcessStartInfo procStartInfo = CreateProcessStartInfo(module, moduleId); + if (loggerIsValid) _logger.LogTrace($"Starting {ShrinkPath(procStartInfo.FileName, 50)} {ShrinkPath(procStartInfo.Arguments, 50)}"); @@ -404,7 +411,13 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) if (string.IsNullOrEmpty(error)) error = "No error provided"; - if (error != "info: Microsoft.Hosting.Lifetime[0]") + if (error.Contains("LoadLibrary failed with error 126") && + error.Contains("onnxruntime_providers_cuda.dll")) + { + error = "Attempted to load ONNX runtime CUDA provider. No luck, moving on..."; + _logger.LogInformation(filename + error); + } + else if (error != "info: Microsoft.Hosting.Lifetime[0]") { // TOTAL HACK. ONNX/Tensorflow output is WAY too verbose for an error if (error.Contains("I tensorflow/cc/saved_model/reader.cc:") || @@ -415,6 +428,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } }; + status.Status = ProcessStatusType.Starting; if (!process.Start()) { process = null; @@ -423,6 +437,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) if (process is not null) { + status.Started = DateTime.UtcNow; process.BeginOutputReadLine(); process.BeginErrorReadLine(); @@ -430,8 +445,12 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) _logger.LogInformation($"Started {module.Name} backend"); _runningProcesses.Add(process); - status.Status = ProcessStatusType.Started; - status.Started = DateTime.UtcNow; + + int postStartPauseSecs = 5; // module.PostStartPauseSecs ?? 5; + + // Trying to reduce startup CPU and Memory for Docker + await Task.Delay(TimeSpan.FromSeconds(postStartPauseSecs)); + status.Status = ProcessStatusType.Started; } else { @@ -446,6 +465,8 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) if (loggerIsValid) { _logger.LogError(ex, $"Error trying to start { module.Name} ({module.FilePath})"); + _logger.LogError(ex.Message); + _logger.LogError(ex.StackTrace); } #if DEBUG _logger.LogError($" *** Did you setup the Development environment?"); @@ -485,8 +506,16 @@ private ProcessStartInfo CreateProcessStartInfo(ModuleConfig module, string modu } // Setup the process we're going to launch +#if Windows + // Windows paths can have spaces so need quotes + var executableName = $"\"{filePath}\""; +#else + // the I'm assuming the directories don't have spaces in Linux and MacOS + // because the Process.Start is choking on the quotes + var executableName = filePath; +#endif ProcessStartInfo? procStartInfo = (command == "execute" || command == "launcher") - ? new ProcessStartInfo($"\"{filePath}\"") + ? new ProcessStartInfo(executableName) { UseShellExecute = false, WorkingDirectory = workingDirectory, @@ -563,8 +592,8 @@ private bool IsEnabled(ModuleConfig module) return _frontendOptions.PYTHON_PATH?.Replace(PythonRuntimeMarker, launcher); } - if (runtime == "dotnet") - return "dotnet"; + if (runtime == "dotnet" || runtime == "execute" || runtime == "launcher") + return runtime; return null; } diff --git a/src/API/Server/FrontEnd/Config/ModuleCollection.cs b/src/API/Server/FrontEnd/Config/ModuleCollection.cs index 7d8264d0..0d1e86a6 100644 --- a/src/API/Server/FrontEnd/Config/ModuleCollection.cs +++ b/src/API/Server/FrontEnd/Config/ModuleCollection.cs @@ -53,6 +53,14 @@ public class ModuleConfig /// public string? Command { get; set; } + /* + /// + /// Gets or sets the number of seconds this module should pause after starting to ensure + /// any resources that require startup (eg GPUs) are fully activated before moving on. + /// + public int? PostStartPauseSecs { get; set; } + */ + /// /// Gets or sets the path to the startup file relative to the module directory. /// @@ -96,40 +104,6 @@ public class ModuleConfig public string[] Platforms { get; set; } = Array.Empty(); /* - /// - /// Gets or sets the time this module was started. - /// - // TODO: Move the status info to another class that references or includes - // the module coniguration, if needed. - public DateTime? Started { get; set; } = null; - - /// - /// Gets or sets the latest time a request from this module was spotted by the queue manager. - /// - // TODO: Move the status info to another class that references or includes - // the module coniguration, if needed. - public DateTime? LastSeen { get; set; } = null; - - /// - /// Gets a value indicating whether this process is currently active - /// - // TODO: Move the status info to another class that references or includes - // the module coniguration, if needed. - public bool Running - { - get - { - return LastSeen != null && (DateTime.UtcNow - LastSeen!) < TimeSpan.FromSeconds(65); - } - } - - /// - /// Gets or sets the number of requests processed - /// - // TODO: Move the status info to another class that references or includes - // the module coniguration, if needed. - public int? Processed { get; set; } = 0; - /// /// Gets or sets the name of the hardware acceleration provider. /// diff --git a/src/API/Server/FrontEnd/Controllers/LogController.cs b/src/API/Server/FrontEnd/Controllers/LogController.cs index aa2a8ab7..f21aa8bd 100644 --- a/src/API/Server/FrontEnd/Controllers/LogController.cs +++ b/src/API/Server/FrontEnd/Controllers/LogController.cs @@ -51,6 +51,14 @@ public ResponseBase AddLog([FromForm] string? entry, msg += "[[" + category + "]]"; if (!string.IsNullOrWhiteSpace(label)) msg += "{{" + label + "}}"; + + if (entry.Contains("LoadLibrary failed with error 126") && + entry.Contains("onnxruntime_providers_cuda.dll")) + { + entry = "Attempted to load ONNX runtime CUDA provider. No luck, moving on..."; + log_level = LogLevel.Information; + } + msg += entry; switch (log_level) diff --git a/src/API/Server/FrontEnd/Controllers/StatusController.cs b/src/API/Server/FrontEnd/Controllers/StatusController.cs index 9c7d14f8..6ec85115 100644 --- a/src/API/Server/FrontEnd/Controllers/StatusController.cs +++ b/src/API/Server/FrontEnd/Controllers/StatusController.cs @@ -163,7 +163,10 @@ public ResponseBase ListAnalysisStatus() // List them out and return the status var response = new AnalysisServicesStatusResponse { - statuses = backend.ProcessStatuses.Values.ToList() + statuses = backend.ProcessStatuses + .Values + .Where(module => module.Status != ProcessStatusType.NotEnabled) + .ToList() }; return response; diff --git a/src/API/Server/FrontEnd/Dockerfile b/src/API/Server/FrontEnd/Dockerfile deleted file mode 100644 index 6f8ebaaa..00000000 --- a/src/API/Server/FrontEnd/Dockerfile +++ /dev/null @@ -1,100 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM codeproject/ai-base:focal AS base - -WORKDIR /app -EXPOSE 5000 -ENV ASPNETCORE_URLS=http://+:5000 - -FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build -WORKDIR /src -COPY ["src/API/Server/FrontEnd/Frontend.csproj", "src/API/Server/FrontEnd/"] -COPY ["src/API/Server/Backend/Backend.csproj", "src/API/Server/Backend/"] -COPY ["src/API/Common/Common.csproj", "src/API/Common/"] -COPY ["src/AnalysisLayer/ObjectDetectionNet/ObjectDetectionNet.csproj", "src/AnalysisLayer/ObjectDetectionNet/"] -COPY ["src/AnalysisLayer/PortraitFilter/PortraitFilter.csproj", "src/AnalysisLayer/PortraitFilter/"] -#COPY ["src/AnalysisLayer/SentimentAnalysis/SentimentAnalysis.csproj", "src/AnalysisLayer/SentimentAnalysis/"] -COPY ["src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/Yolov5Net.Scorer.csproj", "src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/"] -Copy ["src/AnalysisLayer/SDK/NET/CodeProject.AI.AnalysisLayer.SDK/CodeProject.AI.AnalysisLayer.SDK.csproj", "src/AnalysisLayer/SDK/NET/CodeProject.AI.AnalysisLayer.SDK/" ] - -RUN dotnet restore "src/API/Server/FrontEnd/Frontend.csproj" -COPY . . - -WORKDIR "/src/src/API/Server/FrontEnd" -RUN dotnet build "Frontend.csproj" -c Release -r linux-x64 --self-contained -o /app/build/server - -WORKDIR "/src/src/AnalysisLayer/ObjectDetectionNet" -RUN dotnet build "ObjectDetectionNet.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/ObjectDetectionNet - -WORKDIR "/src/src/AnalysisLayer/PortraitFilter" -RUN dotnet build "PortraitFilter.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/PortraitFilter - -#WORKDIR "/src/src/AnalysisLayer/SentimentAnalysis" -#RUN dotnet build "SentimentAnalysis.csproj" -c Release -r linux-x64 --self-contained -o /app/build/AnalysisLayer/SentimentAnalysis - -FROM build AS publish - -WORKDIR "/src/src/API/Server/FrontEnd" -RUN dotnet publish "Frontend.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/server - -WORKDIR "/src/src/AnalysisLayer/ObjectDetectionNet" -RUN dotnet publish "ObjectDetectionNet.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/ObjectDetectionNet - -WORKDIR "/src/src/AnalysisLayer/PortraitFilter" -RUN dotnet publish "PortraitFilter.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/PortraitFilter - -#WORKDIR "/src/src/AnalysisLayer/SentimentAnalysis" -#RUN dotnet publish "SentimentAnalysis.csproj" -c Release -r linux-x64 --self-contained -o /app/publish/AnalysisLayer/SentimentAnalysis - -# zipping up the test images and moving to the server wwwroot directory so it can be downloaded from server. -RUN apt-get update -y && apt-get upgrade -y -RUN apt-get install -y zip - -WORKDIR "/src/demos/TestData" -RUN zip -r testdata.zip . -RUN mv testdata.zip /app/publish/server/wwwroot - -WORKDIR /src -COPY ["src/AnalysisLayer/BackgroundRemover/", "/app/publish/AnalysisLayer/BackgroundRemover"] -#COPY ["src/AnalysisLayer/TextSummary/", "/app/publish/AnalysisLayer/TextSummary"] -COPY ["src/AnalysisLayer/Vision/", "/app/publish/AnalysisLayer/Vision"] -COPY ["src/AnalysisLayer/CustomDetection/", "/app/publish/AnalysisLayer/CustomDetection"] -COPY ["src/AnalysisLayer/SDK/Python", "/app/publish/AnalysisLayer/SDK/Python"] -COPY ["demos/TestData", "/app/publish/demos/TestData"] - -FROM base AS final -#These libraries are needed for System.Drawing to work on Linux in NET 6. - -#libfontconfig1 is required for SkiaSharp -RUN apt-get install -y libfontconfig1 - -#libgdplus is required for System.Drawing -RUN apt-get install -y libgdiplus - -EXPOSE 5000 -ENV ASPNETCORE_URLS=http://+:5000 - -# the simple log format is easier on my brain than json -ENV LOGGING__CONSOLE__FORMATTERNAME=simple - -WORKDIR /app -COPY --from=publish /app/publish . -RUN add-apt-repository ppa:deadsnakes/ppa -y -RUN apt update -y - -#needed for opencv-python -RUN apt-get install ffmpeg libsm6 libxext6 -y - -RUN apt-get install python3.9 -y -RUN python3.8 -m pip install --upgrade pip -RUN python3.9 -m pip install --upgrade pip - -# CM: Added --no-cache-dir here to reduce the size of the image -RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/Vision/requirements.txt -RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt -#RUN python3.8 -m pip --no-cache-dir install -r /app/AnalysisLayer/TextSummary/requirements.txt -RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/BackgroundRemover/requirements.txt -RUN python3.9 -m pip --no-cache-dir install -r /app/AnalysisLayer/SDK/Python/requirements.txt - -WORKDIR /app/server -ENTRYPOINT ["dotnet", "CodeProject.AI.Server.dll"] \ No newline at end of file diff --git a/src/API/Server/FrontEnd/Frontend.csproj b/src/API/Server/FrontEnd/Frontend.csproj index 330f6993..14466e23 100644 --- a/src/API/Server/FrontEnd/Frontend.csproj +++ b/src/API/Server/FrontEnd/Frontend.csproj @@ -45,7 +45,7 @@ disable enable CodeProject.AI.Server - 1.5.6.0 + 1.5.6.2 CodeProject.AI.API.Server.Frontend 14515168-17dd-49db-9023-0749bb408a37 Linux diff --git a/src/API/Server/FrontEnd/Program.cs b/src/API/Server/FrontEnd/Program.cs index e3c12da1..40fe913d 100644 --- a/src/API/Server/FrontEnd/Program.cs +++ b/src/API/Server/FrontEnd/Program.cs @@ -413,6 +413,4 @@ public static void OpenBrowser(string url) } } } -} - - +} \ No newline at end of file diff --git a/src/API/Server/FrontEnd/Startup.cs b/src/API/Server/FrontEnd/Startup.cs index 2cf59e8d..986479e8 100644 --- a/src/API/Server/FrontEnd/Startup.cs +++ b/src/API/Server/FrontEnd/Startup.cs @@ -277,11 +277,11 @@ public void PassThroughLegacyCommandLineParams() // Using CUDA? if (pair.Key.Equals("CUDA_MODE", StringComparison.InvariantCultureIgnoreCase)) { - keyValues["Modules:FaceProcessing:EnvironmentVariables:CUDA_MODE"] = pair.Value; - keyValues["Modules:VisionObjectDetection:EnvironmentVariables:CUDA_MODE"] = pair.Value; - keyValues["Modules:SceneClassification:EnvironmentVariables:CUDA_MODE"] = pair.Value; + keyValues["Modules:FaceProcessing:EnvironmentVariables:USE_CUDA"] = pair.Value; + keyValues["Modules:VisionObjectDetection:EnvironmentVariables:USE_CUDA"] = pair.Value; + keyValues["Modules:SceneClassification:EnvironmentVariables:USE_CUDA"] = pair.Value; - keyValues["Modules:ObjectDetection:EnvironmentVariables:CUDA_MODE"] = pair.Value; + keyValues["Modules:ObjectDetection:EnvironmentVariables:USE_CUDA"] = pair.Value; keyValues["Modules:CustomObjectDetection:EnvironmentVariables:USE_CUDA"] = pair.Value; } @@ -295,7 +295,8 @@ public void PassThroughLegacyCommandLineParams() } // Custom Model Directories. Deepstack compatibility and thge docs are ambiguous - if (pair.Key.Equals("MODELSTORE-DETECTION", StringComparison.InvariantCultureIgnoreCase)) + if (pair.Key.Equals("MODELSTORE-DETECTION", StringComparison.InvariantCultureIgnoreCase) || + pair.Key.Equals("MODELSTORE_DETECTION", StringComparison.InvariantCultureIgnoreCase)) keyValues["Modules:CustomObjectDetection:EnvironmentVariables:MODELS_DIR"] = pair.Value; // Temp Directories diff --git a/src/API/Server/FrontEnd/appsettings.json b/src/API/Server/FrontEnd/appsettings.json index 31ec5805..472a4f7c 100644 --- a/src/API/Server/FrontEnd/appsettings.json +++ b/src/API/Server/FrontEnd/appsettings.json @@ -8,7 +8,7 @@ "AIServer": { "LogLevels": { "Debug": "Yellow", - "Trace": "Gray", + "Trace": "Gray", "Information": "White", "Warning": "Cyan", "Error": "Red", @@ -29,6 +29,9 @@ // for debugging the modules separately) "LaunchAnalysisServices": true, + // The delay between starting the server and starting the background services in seconds. + "LaunchAnalysisServicesDelaySecs": 3, + // Request queue settings. // TODO: Rename to ModuleQueue "QueueProcessingOptions": { diff --git a/src/API/Server/FrontEnd/installconfig.json b/src/API/Server/FrontEnd/installconfig.json deleted file mode 100644 index e1e6413a..00000000 --- a/src/API/Server/FrontEnd/installconfig.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "install": { - "Id": "021f5e97-6d5f-4c25-8f06-d14fba8fa4c1" - } -} \ No newline at end of file diff --git a/src/API/Server/FrontEnd/version.json b/src/API/Server/FrontEnd/version.json index d7163cd3..5f552b2e 100644 --- a/src/API/Server/FrontEnd/version.json +++ b/src/API/Server/FrontEnd/version.json @@ -4,11 +4,11 @@ "Major": 1, "Minor": 5, "Patch": 6, - "Build": 0, + "Build": 2, "PreRelease": "Beta", "SecurityUpdate": false, - "File": "CodeProject.AI.Server-1.5.6.0.zip", - "ReleaseNotes": "nVidia GPU support! Plus: Complete rework of the Python SDK for modules, revamped dev installer, plus new module 'SuperResolution'." + "File": "CodeProject.AI.Server-1.5.6.2.zip", + "ReleaseNotes": "Performance improvements, Docker GPU, and bug fixes, particularly around Face detection." } } } \ No newline at end of file diff --git a/src/API/Server/FrontEnd/wwwroot/Index.html b/src/API/Server/FrontEnd/wwwroot/Index.html index f66348bd..279d0627 100644 --- a/src/API/Server/FrontEnd/wwwroot/Index.html +++ b/src/API/Server/FrontEnd/wwwroot/Index.html @@ -330,7 +330,8 @@ // TODO: We should suppress the scroll into view if the user has // scrolled up. If we detect a scroll up, set "autoscroll" to false // and if they then scroll to the bottom, turn autoscroll back on - logs.scrollIntoView(false); + + logs.scroll({ top: logs.scrollHeight, behaviour: 'smooth' }); } } }) @@ -464,9 +465,8 @@ -
-
+
+
diff --git a/src/AnalysisLayer/BackgroundRemover/BackgroundRemover.pyproj b/src/AnalysisLayer/BackgroundRemover/BackgroundRemover.pyproj index 7b8176fc..7489d11d 100644 --- a/src/AnalysisLayer/BackgroundRemover/BackgroundRemover.pyproj +++ b/src/AnalysisLayer/BackgroundRemover/BackgroundRemover.pyproj @@ -65,9 +65,12 @@ + + venv diff --git a/src/AnalysisLayer/CustomDetection/detect_adapter.py b/src/AnalysisLayer/CustomDetection/detect_adapter.py index 8d2a7c36..5b830507 100644 --- a/src/AnalysisLayer/CustomDetection/detect_adapter.py +++ b/src/AnalysisLayer/CustomDetection/detect_adapter.py @@ -77,13 +77,13 @@ def custom_detect_callback(module_runner: CodeProjectAIRunner, data: AIRequestDa if model_name == "general": model_name = "ipcam-general" - module_runner.log(LogMethod.Info | LogMethod.Cloud | LogMethod.Server, - { - "filename": "detect_adapter.py", - "loglevel": "information", - "method": "custom_detect_callback", - "message": f"Detecting using {model_name}" - }) + #module_runner.log(LogMethod.Info | LogMethod.Cloud | LogMethod.Server, + # { + # "filename": "detect_adapter.py", + # "loglevel": "information", + # "method": "custom_detect_callback", + # "message": f"Detecting using {model_name}" + # }) response = do_detection(module_runner, model_name, img, threshold) diff --git a/src/AnalysisLayer/CustomDetection/models/experimental.py b/src/AnalysisLayer/CustomDetection/models/experimental.py index 2fea1de6..b2f05c5c 100644 --- a/src/AnalysisLayer/CustomDetection/models/experimental.py +++ b/src/AnalysisLayer/CustomDetection/models/experimental.py @@ -84,7 +84,15 @@ def attempt_load(weights, device=None, inplace=True, fuse=True): # Compatibility updates for m in model.modules(): t = type(m) - if t in (nn.Hardswish, nn.LeakyReLU, nn.ReLU, nn.ReLU6, nn.SiLU, Detect, Model): + + # This works around an issue for SiLU not being present + try: + if t is nn.SiLU: + m.inplace = inplace # torch 1.7.0 compatibility + except: + pass + + if t in (nn.Hardswish, nn.LeakyReLU, nn.ReLU, nn.ReLU6, Detect, Model): # nn.SiLU removed m.inplace = inplace # torch 1.7.0 compatibility if t is Detect and not isinstance(m.anchor_grid, list): delattr(m, 'anchor_grid') diff --git a/src/AnalysisLayer/CustomDetection/modulesettings.json b/src/AnalysisLayer/CustomDetection/modulesettings.json index efd57b3e..36f98a66 100644 --- a/src/AnalysisLayer/CustomDetection/modulesettings.json +++ b/src/AnalysisLayer/CustomDetection/modulesettings.json @@ -13,6 +13,8 @@ "EnvironmentVariables": { "CPAI_PORT": 5000, + "YOLOv5_VERBOSE": "false", + "MODEL_SIZE": "Medium", // small, medium, large, x-large "RESOLUTION": "Medium", // low, medium, high "USE_CUDA": "True", diff --git a/src/AnalysisLayer/CustomDetection/requirements.macos.txt b/src/AnalysisLayer/CustomDetection/requirements.macos.txt index 65c16d98..3939399e 100644 --- a/src/AnalysisLayer/CustomDetection/requirements.macos.txt +++ b/src/AnalysisLayer/CustomDetection/requirements.macos.txt @@ -7,15 +7,12 @@ Pillow # Installing Pillow, a Python Image Library SciPy # Installing SciPy, a library for mathematics, science, and engineering PyYAML # Installing PyYAML, a library for reading configuration files -## General libraries -#ONNXRuntime # Installing ONNX runtime, the scoring engine for ONNX models - ## Specific versions that match the models we're using. -Torch==1.6.0 # Installing Torch, for Tensor computation and Deep neural networks -TorchVision==0.7.0 # Installing TorchVision, for Computer Vision based AI +Torch==1.10.2 # Installing Torch, for Tensor computation and Deep neural networks +TorchVision==0.11.3 # Installing TorchVision, for Computer Vision based AI ## These to be removed (not needed for inference) #matlabplotlib seaborn -# last line left blank \ No newline at end of file +## last line empty. \ No newline at end of file diff --git a/src/AnalysisLayer/ObjectDetectionNet/ObjectDetectionNet.csproj b/src/AnalysisLayer/ObjectDetectionNet/ObjectDetectionNet.csproj index 016dce17..2a54cfde 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/ObjectDetectionNet.csproj +++ b/src/AnalysisLayer/ObjectDetectionNet/ObjectDetectionNet.csproj @@ -46,7 +46,7 @@ disable CodeProject.AI.Analysis.Yolo ObjectDetectionNet - 1.5.6.0 + 1.5.6.2 dotnet-CodeProject.AI.AnalysisLayer.Yolo-384BE45C-AAED-42BA-9DDB-EF37356B630F Linux ..\..\.. @@ -88,7 +88,6 @@ - diff --git a/src/AnalysisLayer/ObjectDetectionNet/ObjectDetector.cs b/src/AnalysisLayer/ObjectDetectionNet/ObjectDetector.cs index 77c23f14..9782fce8 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/ObjectDetector.cs +++ b/src/AnalysisLayer/ObjectDetectionNet/ObjectDetector.cs @@ -106,13 +106,18 @@ private SessionOptions GetHardwareInfo() { var sessionOpts = new SessionOptions(); - bool useGPU = (Environment.GetEnvironmentVariable("CUDA_MODE") ?? "False").ToLower() == "true"; - + bool useGPU = (Environment.GetEnvironmentVariable("USE_CUDA") ?? "false").ToLower() == "true" + || (Environment.GetEnvironmentVariable("USE_GPU") ?? "false").ToLower() == "true"; if (useGPU) { - ///* -- work in progress - var onnxRuntimeEnv = OrtEnv.Instance(); - var providers = onnxRuntimeEnv.GetAvailableProviders(); + string[]? providers = null; + try + { + providers = OrtEnv.Instance().GetAvailableProviders(); + } + catch + { + } // Enable CUDA ------------------- if (providers?.Any(p => p.StartsWith("CUDA", StringComparison.OrdinalIgnoreCase)) ?? false) @@ -168,9 +173,6 @@ private SessionOptions GetHardwareInfo() } } - // ------------------------------------------------ - //*/ - sessionOpts.AppendExecutionProvider_CPU(); return sessionOpts; } diff --git a/src/AnalysisLayer/ObjectDetectionNet/Program.cs b/src/AnalysisLayer/ObjectDetectionNet/Program.cs index bd7c508e..403c28b6 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/Program.cs +++ b/src/AnalysisLayer/ObjectDetectionNet/Program.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; +using System; using System.Threading.Tasks; namespace CodeProject.AI.Analysis.Yolo @@ -9,6 +10,8 @@ public class Program { public static async Task Main(string[] args) { + // Fix suggested from https://forum.stimulsoft.com/viewtopic.php?t=60022 + AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true); await CreateHostBuilder(args).Build().RunAsync(); } diff --git a/src/AnalysisLayer/ObjectDetectionNet/Properties/launchSettings.json b/src/AnalysisLayer/ObjectDetectionNet/Properties/launchSettings.json index 9013c380..04012220 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/Properties/launchSettings.json +++ b/src/AnalysisLayer/ObjectDetectionNet/Properties/launchSettings.json @@ -3,7 +3,7 @@ "ObjectDetectionNet": { "commandName": "Project", "environmentVariables": { - "CUDA_MODE": "False", + "USE_CUDA": "False", "DOTNET_ENVIRONMENT": "Development" }, "dotnetRunMessages": "true" diff --git a/src/AnalysisLayer/ObjectDetectionNet/YoloProcessor.cs b/src/AnalysisLayer/ObjectDetectionNet/YoloProcessor.cs index adf80216..178af949 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/YoloProcessor.cs +++ b/src/AnalysisLayer/ObjectDetectionNet/YoloProcessor.cs @@ -22,7 +22,7 @@ namespace CodeProject.AI.Analysis.Yolo /// and send back analysis requests and responses from and to the server backend. /// While intended for development and tests, this also demonstrates how a backend service can /// be created with the .NET Core framework. - /// TODO: Derive this from CommandQueueWorker + /// REVIEW: [Matthew] Derive this from CommandQueueWorker /// public class YoloProcessor : BackgroundService { @@ -113,9 +113,9 @@ private async Task ProcessQueue(CancellationToken token) request = await _codeprojectAI.GetRequest(_queueName, _moduleId, token, ExecutionProvider); } - catch (Exception ex) + catch (Exception /*ex*/) { - _logger.LogError(ex, "Yolo Exception"); + // _logger.LogError(ex, "Yolo Exception"); continue; } diff --git a/src/AnalysisLayer/ObjectDetectionNet/install.sh b/src/AnalysisLayer/ObjectDetectionNet/install.sh index cce33caa..f8b41077 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/install.sh +++ b/src/AnalysisLayer/ObjectDetectionNet/install.sh @@ -3,7 +3,7 @@ # .NET YOLO Object Detection -# Download the models and store in /models +# Download the models and store in /assets getFromServer "yolonet-models.zip" "assets" "Downloading YOLO ONNX models..." diff --git a/src/AnalysisLayer/ObjectDetectionNet/modulesettings.docker.json b/src/AnalysisLayer/ObjectDetectionNet/modulesettings.docker.json index 7c5e840e..c90ba20e 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/modulesettings.docker.json +++ b/src/AnalysisLayer/ObjectDetectionNet/modulesettings.docker.json @@ -1,8 +1,8 @@ { "Modules": { "ObjectDetection": { - "FilePath": "ObjectDetectionNet\\ObjectDetectionNet.dll", - "Runtime": "dotnet" + "FilePath": "ObjectDetectionNet/ObjectDetectionNet", + "Runtime": "execute" } } } diff --git a/src/AnalysisLayer/ObjectDetectionNet/modulesettings.json b/src/AnalysisLayer/ObjectDetectionNet/modulesettings.json index 493e263c..0021745a 100644 --- a/src/AnalysisLayer/ObjectDetectionNet/modulesettings.json +++ b/src/AnalysisLayer/ObjectDetectionNet/modulesettings.json @@ -4,18 +4,17 @@ "Modules": { "ObjectDetection": { - "Activate": true, - "Name": "CodeProject.AI Object Detection", + "Activate": false, + "Name": "Object Detection (.NET)", "Description": "Detects multiple objects of 80 types in an image.", "FilePath": "ObjectDetectionNet\\ObjectDetectionNet.exe", "Runtime": "execute", - "Platforms": [ "windows", "linux", "docker" ], + "Platforms": [ "windows"], "EnableFlags": [ "VISION-DETECTION" ], "EnvironmentVariables": { - "VISION-DETECTION": true, - - "CUDA_MODE": "True", + "USE_CUDA": "True", + // "USE_GPU": "True", - Alternative flag to USE_CUDA. Either works. "MODE": "MEDIUM", "CPAI_PORT": 5000 }, diff --git a/src/AnalysisLayer/ObjectDetectionNet/runtimeconfig.template..json b/src/AnalysisLayer/ObjectDetectionNet/runtimeconfig.template..json new file mode 100644 index 00000000..6906ea9e --- /dev/null +++ b/src/AnalysisLayer/ObjectDetectionNet/runtimeconfig.template..json @@ -0,0 +1,5 @@ +{ + "configProperties": { + "System.Drawing.EnableUnixSupport": true + } +} diff --git a/src/AnalysisLayer/PortraitFilter/PortraitFilter.csproj b/src/AnalysisLayer/PortraitFilter/PortraitFilter.csproj index a0295354..2ceacbc8 100644 --- a/src/AnalysisLayer/PortraitFilter/PortraitFilter.csproj +++ b/src/AnalysisLayer/PortraitFilter/PortraitFilter.csproj @@ -47,7 +47,7 @@ enable CodeProject.AI.AnalysisLayer.PortraitFilter PortraitFilter - 1.5.6.0 + 1.5.6.2 Linux ..\..\.. favicon.ico diff --git a/src/AnalysisLayer/PortraitFilter/PortraitFilterWorker.cs b/src/AnalysisLayer/PortraitFilter/PortraitFilterWorker.cs index a4083322..ef139612 100644 --- a/src/AnalysisLayer/PortraitFilter/PortraitFilterWorker.cs +++ b/src/AnalysisLayer/PortraitFilter/PortraitFilterWorker.cs @@ -17,7 +17,7 @@ class PortraitResponse : BackendSuccessResponse } /// - /// TODO: Derive this from CommandQueueWorker + /// REVIEW: [Matthew] Derive this from CommandQueueWorker /// public class PortraitFilterWorker : BackgroundService { @@ -111,13 +111,18 @@ private SessionOptions GetHardwareInfo() { var sessionOpts = new SessionOptions(); - bool useGPU = (Environment.GetEnvironmentVariable("CUDA_MODE") ?? "False").ToLower() == "true"; - + bool useGPU = (Environment.GetEnvironmentVariable("USE_CUDA") ?? "false").ToLower() == "true" + || (Environment.GetEnvironmentVariable("USE_GPU") ?? "false").ToLower() == "true"; if (useGPU) { - ///* -- work in progress - var onnxRuntimeEnv = OrtEnv.Instance(); - var providers = onnxRuntimeEnv.GetAvailableProviders(); + string[]? providers = null; + try + { + providers = OrtEnv.Instance().GetAvailableProviders(); + } + catch + { + } // Enable CUDA ------------------- if (providers?.Any(p => p.StartsWith("CUDA", StringComparison.OrdinalIgnoreCase)) ?? false) @@ -171,9 +176,6 @@ private SessionOptions GetHardwareInfo() } } - // ------------------------------------------------ - //*/ - sessionOpts.AppendExecutionProvider_CPU(); return sessionOpts; } diff --git a/src/AnalysisLayer/PortraitFilter/Properties/launchSettings.json b/src/AnalysisLayer/PortraitFilter/Properties/launchSettings.json index a1a03551..7abdd7b9 100644 --- a/src/AnalysisLayer/PortraitFilter/Properties/launchSettings.json +++ b/src/AnalysisLayer/PortraitFilter/Properties/launchSettings.json @@ -3,7 +3,7 @@ "PortraitFilter": { "commandName": "Project", "environmentVariables": { - "CUDA_MODE": "TRUE", + "USE_CUDA": "TRUE", "DOTNET_ENVIRONMENT": "Development" }, "dotnetRunMessages": true diff --git a/src/AnalysisLayer/PortraitFilter/modulesettings.docker.json b/src/AnalysisLayer/PortraitFilter/modulesettings.docker.json index 6adb52af..febfbeb7 100644 --- a/src/AnalysisLayer/PortraitFilter/modulesettings.docker.json +++ b/src/AnalysisLayer/PortraitFilter/modulesettings.docker.json @@ -1,8 +1,8 @@ { "Modules": { "PortraitFilter": { - "FilePath": "PortraitFilter/PortraitFilter.dll", - "Runtime": "dotnet" + "FilePath": "PortraitFilter/PortraitFilter", + "Runtime": "execute" } } } diff --git a/src/AnalysisLayer/PortraitFilter/modulesettings.json b/src/AnalysisLayer/PortraitFilter/modulesettings.json index caf6e61b..7b6fbde9 100644 --- a/src/AnalysisLayer/PortraitFilter/modulesettings.json +++ b/src/AnalysisLayer/PortraitFilter/modulesettings.json @@ -11,7 +11,9 @@ "Platforms": [ "windows", "linux", "docker", "macos" ], // No "macos-arm" because of Gdip intitialiser issue. Move to Maui graphics "EnvironmentVariables": { - "CPAI_PORT": 5000 + "CPAI_PORT": 5000, + "USE_GPU": true + // "USE_CUDA": "True", - Alternative flag to USE_GPU. Either works. }, "RouteMaps": [ diff --git a/src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/Yolov5Net.Scorer.csproj b/src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/Yolov5Net.Scorer.csproj index f887ff70..77941be3 100644 --- a/src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/Yolov5Net.Scorer.csproj +++ b/src/AnalysisLayer/SDK/ModelRunners/Yolov5Net.Scorer/Yolov5Net.Scorer.csproj @@ -31,9 +31,9 @@ - - - + + +