diff --git a/.gitignore b/.gitignore index 59f72a3b..ae91a170 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,24 @@ ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore +/demos/Python/detected + +/install/downloads/models +/install/downloads/assets +/install/downloads/python37 +/install/cached_downloads +/install/downloads/python_packages_cpu +/install/downloads/python_packages_gpu + +/src/CodeProject.SenseAI.config +/src/set_environment.bat +/src/Start_SenseAI_Win.bat + +/src/AnalysisLayer/DeepStack/venv +/src/AnalysisLayer/DeepStack/datastore +/src/AnalysisLayer/DeepStack/tempstore +/src/AnalysisLayer/DeepStack/assets + # User-specific files *.rsuser *.suo @@ -358,17 +376,4 @@ MigrationBackup/ .ionide/ # Fody - auto-generated XML schema -FodyWeavers.xsd -/install/downloads/models -/install/downloads/venv/venv -/src/AnalysisLayer/DeepStack/env -/demos/Python/detected -/src/AnalysisLayer/DeepStack/intelligencelayer/env -/src/AnalysisLayer/DeepStack/intelligencelayer/env3.7 -/install/downloads/python37/Python37 -/install/downloads/python_packages_cpu/windows_packages_cpu -/src/AnalysisLayer/DeepStack/intelligencelayer/venv -/install/downloads/assets -/install/downloads_saved/venv -/src/AnalysisLayer/DeepStack/intelligencelayer/data -/src/AnalysisLayer/DeepStack/venv +FodyWeavers.xsd \ No newline at end of file diff --git a/CodeProject.SenseAI.sln b/CodeProject.SenseAI.sln index 594a3bdf..cb4871a8 100644 --- a/CodeProject.SenseAI.sln +++ b/CodeProject.SenseAI.sln @@ -16,20 +16,20 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{3BF27572-9D3A-497C-8375-29110EBBD3D1}" ProjectSection(SolutionItems) = preProject README.md = README.md + docs\Welcome.html = docs\Welcome.html EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AnalysisLayer", "AnalysisLayer", "{156BFEDA-D477-43B2-92DA-FCC9BAF1F893}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "install", "install", "{D885EE64-C1BD-44D6-84D8-1E46806298D9}" ProjectSection(SolutionItems) = preProject - install\build_download.bat = install\build_download.bat - install\windows_install.bat = install\windows_install.bat - install\windows_start.bat = install\windows_start.bat - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{027671E2-C9F9-425A-98E5-4E7801686642}" - ProjectSection(SolutionItems) = preProject - install\scripts\download.ps1 = install\scripts\download.ps1 + install\create_installer_win.bat = install\create_installer_win.bat + install\load_environment.bat = install\load_environment.bat + install\save_environment.bat = install\save_environment.bat + install\set_environment.sh = install\set_environment.sh + install\setup_dev_env_win.bat = install\setup_dev_env_win.bat + install\Setup_SenseAI_Win.bat = install\Setup_SenseAI_Win.bat + install\Start_SenseAI_Win.bat = install\Start_SenseAI_Win.bat EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "downloads", "downloads", "{7250A438-7B43-4FED-BB2B-9FB1FB2F69AF}" @@ -45,17 +45,49 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET", ".NET", "{1912618E-7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TestData", "TestData", "{B10B59B5-9F63-41C2-BFBB-6C7311DC4E99}" ProjectSection(SolutionItems) = preProject + demos\TestData\adele.jpg = demos\TestData\adele.jpg demos\TestData\adele1.jpg = demos\TestData\adele1.jpg demos\TestData\adele2.jpg = demos\TestData\adele2.jpg + demos\TestData\blank.png = demos\TestData\blank.png demos\TestData\bradley.jpg = demos\TestData\bradley.jpg + demos\TestData\cruise.jpg = demos\TestData\cruise.jpg demos\TestData\detection.jpg = demos\TestData\detection.jpg + demos\TestData\elba.jpg = demos\TestData\elba.jpg + demos\TestData\face.jpg = demos\TestData\face.jpg demos\TestData\face_detection.jpg = demos\TestData\face_detection.jpg + demos\TestData\family.jpg = demos\TestData\family.jpg + demos\TestData\image0.jpg = demos\TestData\image0.jpg + demos\TestData\image0_person.jpg = demos\TestData\image0_person.jpg + demos\TestData\image0_truck.jpg = demos\TestData\image0_truck.jpg + demos\TestData\image1.jpg = demos\TestData\image1.jpg + demos\TestData\image1_car.jpg = demos\TestData\image1_car.jpg + demos\TestData\image1_truck.jpg = demos\TestData\image1_truck.jpg + demos\TestData\image2.jpg = demos\TestData\image2.jpg + demos\TestData\image2_boat.jpg = demos\TestData\image2_boat.jpg + demos\TestData\image2_person.jpg = demos\TestData\image2_person.jpg + demos\TestData\image3.jpg = demos\TestData\image3.jpg + demos\TestData\image3_traffic light.jpg = demos\TestData\image3_traffic light.jpg + demos\TestData\image4_bus.jpg = demos\TestData\image4_bus.jpg + demos\TestData\image5_person.jpg = demos\TestData\image5_person.jpg + demos\TestData\image6_person.jpg = demos\TestData\image6_person.jpg + demos\TestData\image7_bus.jpg = demos\TestData\image7_bus.jpg demos\TestData\mask.pt = demos\TestData\mask.pt + demos\TestData\Matterhorn.jpg = demos\TestData\Matterhorn.jpg + demos\TestData\night.jpg = demos\TestData\night.jpg + demos\TestData\perri.jpg = demos\TestData\perri.jpg + demos\TestData\road.jpg = demos\TestData\road.jpg demos\TestData\RobertDowneyJr1.jpg = demos\TestData\RobertDowneyJr1.jpg demos\TestData\RobertDowneyJr2.jpg = demos\TestData\RobertDowneyJr2.jpg demos\TestData\RobertDowneyJr3.jpg = demos\TestData\RobertDowneyJr3.jpg demos\TestData\RobertDowneyJr4.jpg = demos\TestData\RobertDowneyJr4.jpg + demos\TestData\RocketRacoon.PNG = demos\TestData\RocketRacoon.PNG demos\TestData\scene.jpg = demos\TestData\scene.jpg + demos\TestData\test-image.jpg = demos\TestData\test-image.jpg + demos\TestData\test-image2.jpg = demos\TestData\test-image2.jpg + demos\TestData\test-image3.jpg = demos\TestData\test-image3.jpg + demos\TestData\test-image3.png = demos\TestData\test-image3.png + demos\TestData\test-image5.jpg = demos\TestData\test-image5.jpg + demos\TestData\test-image8.jpg = demos\TestData\test-image8.jpg EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.Playground", "demos\dotNet\CodeProject.SenseAI.Playground\CodeProject.SenseAI.Playground.csproj", "{C33D90E7-7570-46FB-9EB9-ED6B40A93A9B}" @@ -70,13 +102,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Backend", "src\API\Server\B EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.API.Server.Backend.Tests", "tests\QueueServiceTests\CodeProject.SenseAI.API.Server.Backend.Tests.csproj", "{F9430C77-589D-4C56-8458-2DF7E344C0FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.Analysis.Yolo", "src\AnalysisLayer\CodeProject.SenseAI.Backend.Yolo\CodeProject.SenseAI.Analysis.Yolo.csproj", "{ED911007-D9E3-4F99-9611-FBCA889419C2}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Images", "Images", "{8C92DCAE-EDE7-4DEC-A5CB-BB2388905064}" ProjectSection(SolutionItems) = preProject docs\images\Choose-launch.png = docs\images\Choose-launch.png + docs\images\Mulitple-Project-Toolbar.png = docs\images\Mulitple-Project-Toolbar.png + docs\images\Set-Startup_Projects.png = docs\images\Set-Startup_Projects.png EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeProject.SenseAI.Analysis.Yolo", "src\AnalysisLayer\CodeProject.AI.Backend.Yolo\CodeProject.SenseAI.Analysis.Yolo.csproj", "{15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -107,10 +141,10 @@ Global {F9430C77-589D-4C56-8458-2DF7E344C0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {F9430C77-589D-4C56-8458-2DF7E344C0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {F9430C77-589D-4C56-8458-2DF7E344C0FC}.Release|Any CPU.Build.0 = Release|Any CPU - {ED911007-D9E3-4F99-9611-FBCA889419C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED911007-D9E3-4F99-9611-FBCA889419C2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED911007-D9E3-4F99-9611-FBCA889419C2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED911007-D9E3-4F99-9611-FBCA889419C2}.Release|Any CPU.Build.0 = Release|Any CPU + {15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -119,7 +153,6 @@ Global {25750BF1-1502-4F65-8D69-CEA8C87D6446} = {7F18EB64-C857-49C4-9380-70D3CCE6242B} {2379A486-0D28-4CAD-BB13-E77FBA538E0D} = {A8B76501-496A-4011-9C37-8308A1EBDFA7} {156BFEDA-D477-43B2-92DA-FCC9BAF1F893} = {A8B76501-496A-4011-9C37-8308A1EBDFA7} - {027671E2-C9F9-425A-98E5-4E7801686642} = {D885EE64-C1BD-44D6-84D8-1E46806298D9} {7250A438-7B43-4FED-BB2B-9FB1FB2F69AF} = {D885EE64-C1BD-44D6-84D8-1E46806298D9} {E5D27495-EE4F-4AAF-8749-A6BA848111E2} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893} {3A860CDD-94B9-4002-BA08-87E8822DDE50} = {7F18EB64-C857-49C4-9380-70D3CCE6242B} @@ -131,8 +164,8 @@ Global {A0CF3BEE-8EE3-4B23-BEB8-9D258C0510A3} = {93A23681-E9E8-4381-9EB5-8D178A0EE785} {C93C22D7-4EB2-4EC0-A7F0-FBCFB9F6F72D} = {93A23681-E9E8-4381-9EB5-8D178A0EE785} {F9430C77-589D-4C56-8458-2DF7E344C0FC} = {D982BD8C-2257-413B-8513-8043AB3035F3} - {ED911007-D9E3-4F99-9611-FBCA889419C2} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893} {8C92DCAE-EDE7-4DEC-A5CB-BB2388905064} = {3BF27572-9D3A-497C-8375-29110EBBD3D1} + {15D6CB19-A4FF-43EC-8483-A4F3AF6EBEBA} = {156BFEDA-D477-43B2-92DA-FCC9BAF1F893} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {83740BD9-AEEF-49C7-A722-D7703D3A38CB} diff --git a/README.md b/README.md index 11ae4c0f..cf860e68 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/codeproject/CodeProject.SenseAI) [![made-with-python](https://img.shields.io/badge/Made%20with-Python-orange)](https://www.python.org/) [![GitHub license](https://img.shields.io/badge/license-SSPL-green)](https://github.com/codeproject/CodeProject.SenseAI/blob/main/LICENSE) [![Open Source Love svg2](https://badges.frapsoft.com/os/v2/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) + # CodeProject SenseAI Server Standalone, self-hosted, fast, free and Open Source Artificial Intelligence microserver for any platform, any language. @@ -56,9 +58,9 @@ This is an Alpha release and so support is constrained solely to Windows 10+ usi To **install CodeProject.SenseAI** as a standalone service ready for integration with applications such as HomeAssist or BlueIris, download the [installation package](https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/CodeProject.SenseAI.Package.zip). -Unzip the download and double click the windows_start.bat script. This will start the API server and the backend analysis services. Rerun that script whenever you want to launch the service. +Unzip the download and double click the Start_SenseAI_Win.bat script. This will start the API server and the backend analysis services. Rerun that script whenever you want to launch the service. -To **explore CodeProject.SenseAI** open the /demos/dotNET/CodeProject.SenseAI.Playground folder and double click on the CodeProject.SenseAI.Playground.exe application. The server will, of course, need to be running for this test application to function. Sample images can be found in the TestData folder under the demos folder +To **explore CodeProject.SenseAI** open the /demos/Javascript/ folder and double click on the Vision.html page. The server will, of course, need to be running for this test application to function. Sample images can be found in the TestData folder under the demos folder ### Setting up the development environment @@ -78,11 +80,13 @@ You'll need the following extensions To build and run: 1. Clone the [CodeProject.SenseAI repository](https://github.com/codeproject/CodeProject.SenseAI.git) from GitHub -2. Open the main application folder in VSCode -3. Click the "Run and Debug" button on the left hand tab bar (the arrow) -4. From the dropdown at the top of the window, select CodeProject.SenseAI Playground +2. run /install/setup_dev_env_win.bat. This will download required assets, setup the Python + virtual environment and set environment variables. +3. Open the main application folder in VSCode +4. Click the "Run and Debug" button on the left hand tab bar (the arrow) +5. From the dropdown at the top of the window, select CodeProject.SenseAI Playground ![Choosing a launch profile](docs/images/Choose-launch.png "Choosing a launch profile") -5. CLick the green arrow next to the dropdown +6. CLick the green arrow next to the dropdown The Demo application (CodeProject.SenseAI Playground) should launch after the code has built and the Python backed fully installed. @@ -91,10 +95,20 @@ The Demo application (CodeProject.SenseAI Playground) should launch after the co 1. Clone the [CodeProject.SenseAI repository](https://github.com/codeproject/CodeProject.SenseAI.git) from GitHub 2. Ensure you have the Python workflow enabled in Visual Studio. While not critical, it does help with debugging. -3. Open the solution in Visual Studio and build the entire solution -4. In Solution Explorer, open demos / .NET and right-click on CodeProject.SenseAI.Playground and choose Debug -> Start new instance. -5. In Solution Explorer, open src / API and right-click on FrontEnd and choose Debug -> Start new instance. **Matthew: what's the better way of doing this?** -6. In Solution Explorer, open src / AnalysisLayer. Right click on DeepStack and choose Open Folder in File Explorer. Double click on the start.bat script +3. run /install/setup_dev_env_win.bat. This will download required assets, setup the Python virtual environment and set environment variables. **This will take several minutes, so please be patient.** +4. Open the solution in Visual Studio and build the entire solution +5. To run the Server and the demo application in DEBUG you can either + 1. Start both the projects in debug mode by + 1. In Solution Explorer, open demos / .NET and right-click on CodeProject.SenseAI.Playground and choose Debug -> Start new instance. + 2. In Solution Explorer, open src / API / Server and right-click on FrontEnd and choose Debug -> Start new instance. + 2. Configure Visual Studio to start multiple projects by + 1. In Solution Explorer, right-click on the solution and select **Set Startup Projects...** and configure Multiple startup projects as shown below. + ![Set Startup Projects](docs/images/Set-Startup_Projects.png) + 3. Now when you start with or without debugging, both the Server and demo projects with start. Also, this will be shown on the toolbar as shown below. + ![Mutliple Project Toolbar](docs/images/Mulitple-Project-Toolbar.png) + +6. In Solution Explorer, open src / AnalysisLayer. Right click on DeepStack and choose Open Folder in File Explorer. Double click on the start.bat script. This script will ensure that the Python virtual environment is enabled and environment variables set. + At this point the Playground application should be indicting it has a connection to the API server, and the servwe should be dispatching requests to the backend Analysis layer. diff --git a/demos/Javascript/Vision.html b/demos/Javascript/Vision.html index 8e2eafe8..97f1fb80 100644 --- a/demos/Javascript/Vision.html +++ b/demos/Javascript/Vision.html @@ -4,42 +4,130 @@ CodeProject SenseAI Demos + + - - + + + + +
+ + + +

The CodeProject SenseAI Playground

-
- - - + +
+
+ +
+ Port: + +
+ +
+ Object Detection +
+ + +
+
+ + + + +
+
+ +
+ Face Comparison +
+
+
+ + +
+
+ + +
+
+
+ +
+
+
+ +
+ Face registration +
+
+
+ + +
+
+ + +
+
+ + +
+
+
+ + +
+
+
+ +
+ Face Recognition +
+ + + +
+
+ Minimum Recognition Confidence + +
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ +
- -
- - - -
+
\ No newline at end of file diff --git a/demos/Python/Python.pyproj b/demos/Python/Python.pyproj index 090c309e..22b57323 100644 --- a/demos/Python/Python.pyproj +++ b/demos/Python/Python.pyproj @@ -23,45 +23,9 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demos/Python/benchmark.py b/demos/Python/benchmark.py index 8c8cfa9c..20887ebe 100644 --- a/demos/Python/benchmark.py +++ b/demos/Python/benchmark.py @@ -1,7 +1,7 @@ """ -Script to time how long it takes deepstack to process a set of images. -The purpose is to allow comparison of speed on different hosts. -We also count the total number of predictions as a quality check. +Script to time how long it takes the DeepStack modules to process a set of images. +The purpose is to allow comparison of speed on different hosts. We also count the +total number of predictions as a quality check. Example run: python3 benchmark.py --images_folder /Users/my/images """ @@ -14,24 +14,24 @@ # deepstack credentials DEFAULT_IP_ADDRESS = cfg.serverHost -DEFAULT_PORT = cfg.serverPort -DEFAULT_API_KEY = "" +DEFAULT_PORT = cfg.serverPort +DEFAULT_API_KEY = "" DEFAULT_IMAGES_FOLDER = cfg.imageDir def main(): - parser = argparse.ArgumentParser(description="Perform benchmarking of Deepstack") + parser = argparse.ArgumentParser(description="Perform benchmarking of DeepStack modules in CodeProject.SenseAI") parser.add_argument( "--ip", default=DEFAULT_IP_ADDRESS, type=str, - help="Deepstack IP", + help="CodeProject Sense Server IP address", ) parser.add_argument( "--port", default=DEFAULT_PORT, type=int, - help="Deepstack port", + help="CodeProject Sense Server Port", ) parser.add_argument( "--api_key", default=DEFAULT_API_KEY, type=str, help="Deepstack API key" @@ -40,7 +40,7 @@ def main(): "--images_folder", default=DEFAULT_IMAGES_FOLDER, type=str, - help="The folder of jpg images", + help="The folder of images to test (only jpg will be tested)", ) args = parser.parse_args() diff --git a/demos/Python/demoConfig.py b/demos/Python/demoConfig.py index bd4317c7..f2383244 100644 --- a/demos/Python/demoConfig.py +++ b/demos/Python/demoConfig.py @@ -1,14 +1,12 @@ import os # some thing we might want to change -#serverPort = 7193 # this is what I am running in developement -#serverUrl = f"https://localhost:{serverPort}/v1/" -#serverPort = 5193 # this is what I am running in developement -serverPort = 5000 # this is what I am running in docker +serverPort = 5000 serverHost = "localhost" serverUrl = f"http://{serverHost}:{serverPort}/v1/" verifySslCert = False # my development cert is self-signed so don't verify -imageDir = "images" +imageDir = "../TestData" + # names of directories of interest detectedDir = "detected" diff --git a/demos/Python/images/image3_person.jpgx b/demos/Python/images/image3_person.jpgx deleted file mode 100644 index e69de29b..00000000 diff --git a/demos/Python/images/test-image6 (1).jpg b/demos/Python/images/test-image6 (1).jpg deleted file mode 100644 index d7ad8406..00000000 Binary files a/demos/Python/images/test-image6 (1).jpg and /dev/null differ diff --git a/demos/Python/images/test-image6.jpg b/demos/Python/images/test-image6.jpg deleted file mode 100644 index 32242305..00000000 Binary files a/demos/Python/images/test-image6.jpg and /dev/null differ diff --git a/demos/Python/images/test-image7.jpg b/demos/Python/images/test-image7.jpg deleted file mode 100644 index b7970502..00000000 Binary files a/demos/Python/images/test-image7.jpg and /dev/null differ diff --git a/demos/Python/match.py b/demos/Python/match.py index 89dcd24c..d00fbc72 100644 --- a/demos/Python/match.py +++ b/demos/Python/match.py @@ -2,8 +2,8 @@ import requests import demoConfig as cfg -image_data2 = open(os.path.join(cfg.imageDir, "test-image7.jpg"), "rb").read() -image_data1 = open(os.path.join(cfg.imageDir, "test-image6.jpg"), "rb").read() +image_data2 = open(os.path.join(cfg.imageDir, "RobertDowneyJr3.jpg"), "rb").read() +image_data1 = open(os.path.join(cfg.imageDir, "RobertDowneyJr4.jpg"), "rb").read() response = requests.post( cfg.serverUrl + "vision/face/match", diff --git a/demos/Python/registeration.py b/demos/Python/registeration.py index c69e5789..4ebf038f 100644 --- a/demos/Python/registeration.py +++ b/demos/Python/registeration.py @@ -15,7 +15,8 @@ def register_face(img_path, user_id): print(response) -register_face("cruise.jpg", "Tom Cruise") register_face("adele.jpg", "Adele") +register_face("bradley.jpg", "Bradley Cooper") +register_face("cruise.jpg", "Tom Cruise") register_face("elba.jpg", "Idris Elba") register_face("perri.jpg", "Christina Perri") diff --git a/demos/Python/start.bat b/demos/Python/start.bat deleted file mode 100644 index 4bbfdb16..00000000 --- a/demos/Python/start.bat +++ /dev/null @@ -1,228 +0,0 @@ -:: CodeProject SenseAI Server startup script -:: We assume we're in the CodeProject SenseAI installed directory. - -@echo off -cls -SETLOCAL EnableDelayedExpansion - -:: Before we start, set the current directory if necessary -if "%1" == "--no-color" set NO_COLOR=true -if not "%2" == "" cd %2 - - -:: =============================================================================================== -:: 0. Basic settings - -:: verbosity can be: quiet | info | loud -set verbosity=quiet - -REM The location of large packages that need to be downloaded -set storageUrl=https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/ - - -:: =============================================================================================== -:: 1. Set environment variables - -set APPDIR=.\ -set PORT=5000 -set PROFILE=windows_native -set CUDA_MODE=False -set DATA_DIR=..\data -set TEMP_PATH=..\temp - -set VENV_PATH=venv -set INSTALL_DIR=..\..\..\..\install -set DOWNLOADS_PATH=%INSTALL_DIR%\downloads -set MODELS_DIRNAME=assets -set MODELS_DIR=%DOWNLOADS_PATH%\%MODELS_DIRNAME% - -set VISION_FACE=True -set VISION_DETECTION=True -set VISION_SCENE=True - -if "%verbosity%" == "info" ( - echo APPDIR = "!APPDIR!" - echo PROFILE = "!PROFILE!" - echo CUDA_MODE = "!CUDA_MODE!" - echo DATA_DIR = "!DATA_DIR!" - echo TEMP_PATH = "!TEMP_PATH!" - echo PORT = "!PORT!" - echo VISION_FACE = "!VISION_FACE!" - echo VISION_DETECTION = "!VISION_DETECTION!" - echo VISION_SCENE = "!VISION_SCENE!" -) - -:: =============================================================================================== -:: 1. Ensure directories are created and download required assets - -if not "%verbosity%" == "quiet" echo Current Directory: %cd% - -:: Create some directories -call :Write White "Creating Directories..." -if not exist %DOWNLOADS_PATH% mkdir %DOWNLOADS_PATH% -if not exist %DATA_DIR% mkdir %DATA_DIR% -if not exist %TEMP_PATH% mkdir %TEMP_PATH% -call :WriteLine Green "Done" - -:: Download, unzip, and move into place the Utilities and known Python version -call :WriteLine White "Download utilities and models..." - -REM Download whatever packages are missing -if not exist %DOWNLOADS_PATH%\%MODELS_DIRNAME% ( - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "%INSTALL_DIR%\scripts\download.ps1 %storageUrl% %DOWNLOADS_PATH%\ models.zip %MODELS_DIRNAME%" - if /i "%verbosity%" == "quiet" call :Write White "Downloading models Done" -) -if not exist %DOWNLOADS_PATH%\python37 ( - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "%INSTALL_DIR%\scripts\download.ps1 %storageUrl% %DOWNLOADS_PATH%\ python37.zip python37" - if /i "%verbosity%" == "quiet" call :Write White "Downloading Python interpreter Done" -) - - -:: =============================================================================================== -:: 2. Create & Activate Virtual Environment from scratch (instead of the above download/unpack/copy) - -if not exist %VENV_PATH% ( - call :Write White "Creating Virtual Environment..." - %DOWNLOADS_PATH%\python37\python37\python.exe -m venv %VENV_PATH% - call :WriteLine Green "Done" -) else ( - call :WriteLine Gray "Virtual Environment exists" -) - -call :Write White "Enabling our Virtual Environment..." - -set VIRTUAL_ENV=!VENV_PATH!\Scripts - -if not defined PROMPT set PROMPT=$P$G -set PROMPT=(venv) !PROMPT! - -set PYTHONHOME= -set PATH=!VIRTUAL_ENV!;%PATH% - -if errorlevel 1 goto errorNoPythonVenv -call :WriteLine Green "Done" - -:: Ensure Python Exists -call :Write White "Checking for Python 3.7..." -python --version | find "3.7" > NUL -if errorlevel 1 goto errorNoPython -call :WriteLine Green "present" - -if "%verbosity%"=="loud" where Python - - -:: =============================================================================================== -:: 3. Install PIP packages - -:: ASSUMPTION: If venv/Lib/site-packages/pip exists then no need to do this - -call :Write White "Checking for required packages..." - -if not exist %VENV_PATH%\Lib\site-packages\pip ( - - call :WriteLine Yellow "Installing" - - :: Set Flags - set pipFlags=-q -q - if "%verbosity%"=="info" set pipFlags=-q - if "%verbosity%"=="loud" set pipFlags= - - call :Write White "Installing Python package manager..." - python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip !pipFlags! - call :WriteLine Green "Done" - - REM call :Write White "Installing Packages into Virtual Environment..." - REM pip install -r %backendDir%\%deepstackModule%\requirements.txt !pipFlags! - REM call :WriteLine Green "Success" - - REM We'll do this the long way so we can see some progress - set currentOption= - for /f "tokens=*" %%x in (requirements.txt) do ( - - set line=%%x - - if "!line!" == "" ( - set currentOption= - ) else if "!line:~0,2!" == "##" ( - set currentOption= - ) else if "!line:~0,12!" == "--find-links" ( - set currentOption=!line! - ) else ( - call :Write White " PIP: Installing !line!..." - REM echo python.exe -m pip install !line! !currentOption! !pipFlags! - python.exe -m pip install !line! !currentOption! !pipFlags! - call :WriteLine Green "Done" - - set currentOption= - ) - ) -) else ( - call :WriteLine Green "present." -) - -:: =============================================================================================== -:: 3. Start back end analysis - -call :Write White "Starting Analysis Services..." -if /i "!VISION_DETECTION!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\detection.py -) -if /i "!VISION_FACE!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\face.py -) -if /i "!VISION_SCENE!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\scene.py -) -:: To start them all in one fell swoop... -:: START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\runAll.py -call :WriteLine Green "Done" - -:: Wait forever. We need these processes to stay alive -pause > NUL - -:: and we're done. -goto eof - - -:: sub-routines - -:WriteLine -SetLocal EnableDelayedExpansion -if /i "!NO_COLOR!" == "true" ( - REM Echo %~2 -) else ( - powershell write-host -foregroundcolor %1 %~2 - REM powershell write-host -foregroundcolor White -NoNewline -) -exit /b - -:Write -SetLocal EnableDelayedExpansion -if /i "!NO_COLOR!" == "true" ( - Echo %~2 -) else ( - powershell write-host -foregroundcolor %1 -NoNewline %~2 - REM powershell write-host -foregroundcolor White -NoNewline -) -exit /b - - -:: Jump points - -:errorNoPython -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python not installed" -call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version of Python" -goto:eof - -:errorNoPythonVenv -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python Virtual Environment activation failed" -call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version" -goto:eof - -:eof \ No newline at end of file diff --git a/demos/TestData/Matterhorn.jpg b/demos/TestData/Matterhorn.jpg new file mode 100644 index 00000000..c0a6a513 Binary files /dev/null and b/demos/TestData/Matterhorn.jpg differ diff --git a/demos/TestData/RocketRacoon.PNG b/demos/TestData/RocketRacoon.PNG new file mode 100644 index 00000000..03ad8cc0 Binary files /dev/null and b/demos/TestData/RocketRacoon.PNG differ diff --git a/demos/Python/images/adele.jpg b/demos/TestData/adele.jpg similarity index 100% rename from demos/Python/images/adele.jpg rename to demos/TestData/adele.jpg diff --git a/demos/Python/images/blank.png b/demos/TestData/blank.png similarity index 100% rename from demos/Python/images/blank.png rename to demos/TestData/blank.png diff --git a/demos/Python/images/cruise.jpg b/demos/TestData/cruise.jpg similarity index 100% rename from demos/Python/images/cruise.jpg rename to demos/TestData/cruise.jpg diff --git a/demos/Python/images/elba.jpg b/demos/TestData/elba.jpg similarity index 100% rename from demos/Python/images/elba.jpg rename to demos/TestData/elba.jpg diff --git a/demos/Python/images/face.jpg b/demos/TestData/face.jpg similarity index 100% rename from demos/Python/images/face.jpg rename to demos/TestData/face.jpg diff --git a/demos/Python/images/family.jpg b/demos/TestData/family.jpg similarity index 100% rename from demos/Python/images/family.jpg rename to demos/TestData/family.jpg diff --git a/demos/Python/images/image0.jpg b/demos/TestData/image0.jpg similarity index 100% rename from demos/Python/images/image0.jpg rename to demos/TestData/image0.jpg diff --git a/demos/Python/images/image0_person.jpg b/demos/TestData/image0_person.jpg similarity index 100% rename from demos/Python/images/image0_person.jpg rename to demos/TestData/image0_person.jpg diff --git a/demos/Python/images/image0_truck.jpg b/demos/TestData/image0_truck.jpg similarity index 100% rename from demos/Python/images/image0_truck.jpg rename to demos/TestData/image0_truck.jpg diff --git a/demos/Python/images/image1.jpg b/demos/TestData/image1.jpg similarity index 100% rename from demos/Python/images/image1.jpg rename to demos/TestData/image1.jpg diff --git a/demos/Python/images/image1_car.jpg b/demos/TestData/image1_car.jpg similarity index 100% rename from demos/Python/images/image1_car.jpg rename to demos/TestData/image1_car.jpg diff --git a/demos/Python/images/image1_truck.jpg b/demos/TestData/image1_truck.jpg similarity index 100% rename from demos/Python/images/image1_truck.jpg rename to demos/TestData/image1_truck.jpg diff --git a/demos/Python/images/image2.jpg b/demos/TestData/image2.jpg similarity index 100% rename from demos/Python/images/image2.jpg rename to demos/TestData/image2.jpg diff --git a/demos/Python/images/image2_boat.jpg b/demos/TestData/image2_boat.jpg similarity index 100% rename from demos/Python/images/image2_boat.jpg rename to demos/TestData/image2_boat.jpg diff --git a/demos/Python/images/image2_person.jpg b/demos/TestData/image2_person.jpg similarity index 100% rename from demos/Python/images/image2_person.jpg rename to demos/TestData/image2_person.jpg diff --git a/demos/Python/images/image3.jpg b/demos/TestData/image3.jpg similarity index 100% rename from demos/Python/images/image3.jpg rename to demos/TestData/image3.jpg diff --git a/demos/Python/images/image3_traffic light.jpg b/demos/TestData/image3_traffic light.jpg similarity index 100% rename from demos/Python/images/image3_traffic light.jpg rename to demos/TestData/image3_traffic light.jpg diff --git a/demos/Python/images/image4_bus.jpg b/demos/TestData/image4_bus.jpg similarity index 100% rename from demos/Python/images/image4_bus.jpg rename to demos/TestData/image4_bus.jpg diff --git a/demos/Python/images/image5_person.jpg b/demos/TestData/image5_person.jpg similarity index 100% rename from demos/Python/images/image5_person.jpg rename to demos/TestData/image5_person.jpg diff --git a/demos/Python/images/image6_person.jpg b/demos/TestData/image6_person.jpg similarity index 100% rename from demos/Python/images/image6_person.jpg rename to demos/TestData/image6_person.jpg diff --git a/demos/Python/images/image7_bus.jpg b/demos/TestData/image7_bus.jpg similarity index 100% rename from demos/Python/images/image7_bus.jpg rename to demos/TestData/image7_bus.jpg diff --git a/demos/Python/images/night.jpg b/demos/TestData/night.jpg similarity index 100% rename from demos/Python/images/night.jpg rename to demos/TestData/night.jpg diff --git a/demos/Python/images/perri.jpg b/demos/TestData/perri.jpg similarity index 100% rename from demos/Python/images/perri.jpg rename to demos/TestData/perri.jpg diff --git a/demos/Python/images/road.jpg b/demos/TestData/road.jpg similarity index 100% rename from demos/Python/images/road.jpg rename to demos/TestData/road.jpg diff --git a/demos/Python/images/test-image.jpg b/demos/TestData/test-image.jpg similarity index 100% rename from demos/Python/images/test-image.jpg rename to demos/TestData/test-image.jpg diff --git a/demos/Python/images/test-image2.jpg b/demos/TestData/test-image2.jpg similarity index 100% rename from demos/Python/images/test-image2.jpg rename to demos/TestData/test-image2.jpg diff --git a/demos/Python/images/test-image3.jpg b/demos/TestData/test-image3.jpg similarity index 100% rename from demos/Python/images/test-image3.jpg rename to demos/TestData/test-image3.jpg diff --git a/demos/Python/images/test-image3.png b/demos/TestData/test-image3.png similarity index 100% rename from demos/Python/images/test-image3.png rename to demos/TestData/test-image3.png diff --git a/demos/Python/images/test-image5.jpg b/demos/TestData/test-image5.jpg similarity index 100% rename from demos/Python/images/test-image5.jpg rename to demos/TestData/test-image5.jpg diff --git a/demos/Python/images/test-image8.jpg b/demos/TestData/test-image8.jpg similarity index 100% rename from demos/Python/images/test-image8.jpg rename to demos/TestData/test-image8.jpg diff --git a/demos/dotNet/CodeProject.SenseAI.Playground/CodeProject.SenseAI.Playground.csproj b/demos/dotNet/CodeProject.SenseAI.Playground/CodeProject.SenseAI.Playground.csproj index ebf2e78a..09fcfea4 100644 --- a/demos/dotNet/CodeProject.SenseAI.Playground/CodeProject.SenseAI.Playground.csproj +++ b/demos/dotNet/CodeProject.SenseAI.Playground/CodeProject.SenseAI.Playground.csproj @@ -8,7 +8,10 @@ favicon.ico CodeProject.SenseAI.Demo.Playground CodeProject.SenseAI.Demo.Playground - + win-x64 + false + false + none @@ -16,7 +19,6 @@ - diff --git a/demos/dotNet/CodeProject.SenseAI.Playground/Properties/PublishProfiles/FolderProfile.pubxml b/demos/dotNet/CodeProject.SenseAI.Playground/Properties/PublishProfiles/FolderProfile.pubxml index 14c1b61c..569254ba 100644 --- a/demos/dotNet/CodeProject.SenseAI.Playground/Properties/PublishProfiles/FolderProfile.pubxml +++ b/demos/dotNet/CodeProject.SenseAI.Playground/Properties/PublishProfiles/FolderProfile.pubxml @@ -12,6 +12,5 @@ https://go.microsoft.com/fwlink/?LinkID=208121. win-x64 false True - True \ No newline at end of file diff --git a/docs/Welcome.html b/docs/Welcome.html new file mode 100644 index 00000000..4c694721 --- /dev/null +++ b/docs/Welcome.html @@ -0,0 +1,156 @@ + + + + + + CodeProject SenseAI Demos + + + + + +
+ + + +

Introducing CodeProject SenseAI

+
Alpha 1.0
+ +

Our standalone, self-hosted, fast, free and Open Source Artificial Intelligence microserver for + any platform, any language.

+ +

To Get Started

+ +
    +
  1. Start the CodeProject SenseAI Server by double-clicking the + Start_SenseAI_Win.bat file
  2. +
  3. Open the CodeProject + SenseAI Playground to explore the capabilities.
  4. +
+ +
+ This is a developer preview full of sharp edges and exciting ledges, but that's part of what + makes this fun. Grab the code + and try out the playground. We're looking for help, ideas, and anyone willing to dig in + make this amazing. +
+ +

What is CodeProject SenseAI Server?

+ +

CodeProject SenseAI is a self contained server that allows other applications to easily i + nclude AI processing as part of their service. CodeProject SenseAI is a simple HTTP based + REST service that is fully self contained, installed locally, and requires no off-device + processing.

+ +

What does it include?

+ +

CodeProject SenseAI includes

+
    +
  • A HTTP REST API Server. The server listens for requests from other apps, + passes them to the backend analysis services for processing, and then passes the + results back to the caller. It runs as a simple self contained web service on your + device.
  • +
  • Backend Analysis services. The brains of the operation is in the analysis + services sitting behind the front end API. All processing of data is done on the + current machine. No calls to the cloud and no data leaving the device.
  • +
  • The Source Code, naturally. +
+ +

What can it do?

+ +

CodeProject SenseAI can currently

+
    +
  • Detect objects in images
  • +
  • Detect faces in images
  • +
  • Detect the type of scene represented in an image
  • +
  • Recognise faces that have been registered with the service
  • +
+

We will be constantly expanding the feature list.

+ +

Why CodeProject SenseAI

+ +

Because adding AI capabilities to your apps is annoying hard.

+

We want AI development to be something every developer can access, and we want integrating + AI into applications to be straightforward.

+

AI development involves multiple formats, training techniques, large amounts of data, + inscrutible choices and often expensive cloud services. We don't want that. The AI that we + include in our applications should be

+
    +
  • Completely self contained. No sign-in, no reliance on Cloud servers, nothing to + download at runtime. Everything you need already in place
  • +
  • Safe and secure. Data processed as part of the application logic should never + leave the local environment. It should not be parsed, read, inspected or stored + by anyone else other than you.
  • +
  • Always open. CodeProject is based on Open Source development and so + CodeProject SenseAI will also be Open Source.
  • +
  • Cross Platform We don't often have the luxury of picking a single platform + anymore. There needs to be support for Windows, Linux, macOS, and Rasperry Pi to + name a few.
  • +
  • Cross Architecture CPU and GPU support, of course
  • +
  • Fast and lightweight Necessary for a self-contained distributable system
  • +
  • Extendable. AI is expanding so rapidly, and there are so many wonderful + solutions popping up daaily. Adding new capabilities must be as simple as dropping + in the code and registering the new capabilities with the front end server.
  • +
+ +

Our Goals

+
    +
  • To promote AI development and inspire the AI developer community to dive in and have a + go. AI is here, it's in demand, and it's a huge paradigm change in the industry. + Whether you like AI or not, developers owe it to themselves to experiment in and + familiarise themselves with the technology. This is CodeProject SenseAI: a + demonstration, a playground, a learning tool, and a library and service that can be + used out of the box.
  • +
  • To make AI development easy. It's not that AI development is that hard. It's that + there are so, so many options. Our architecture is designed to allow any AI + implementation to find a home in our system, and for our service to be callable from + any language.
  • +
  • To focus on core use-cases. We're deliberately not a solution for everyone. Instead + we're a solution for common day-to-day needs. We will be adding dozens of modules + and scores of AI capabilities to our system, but our goal is always clarity and + simplicity over a 100% solution.
  • +
  • To tap the expertise of the Developer Community. We're not experts but we know a + developer or two out there who are. The true power of CodeProject SenseAI comes from + the contributions and improvements from our AI community.
  • +
+ +
+ + \ No newline at end of file diff --git a/docs/images/Mulitple-Project-Toolbar.png b/docs/images/Mulitple-Project-Toolbar.png new file mode 100644 index 00000000..6f327158 Binary files /dev/null and b/docs/images/Mulitple-Project-Toolbar.png differ diff --git a/docs/images/Set-Startup_Projects.png b/docs/images/Set-Startup_Projects.png new file mode 100644 index 00000000..c37eb3a1 Binary files /dev/null and b/docs/images/Set-Startup_Projects.png differ diff --git a/docs/installing on Linux.md b/docs/installing on Linux.md new file mode 100644 index 00000000..fedeba1c --- /dev/null +++ b/docs/installing on Linux.md @@ -0,0 +1,40 @@ +# Setting up the development environment for Linux + +1. Install WSL by opening a PowerShell terming and typing +`wsl --install` + +2. Ensure VS Code is installed + +3. Install the [VS Code Remote Development extension pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) + +4. Install the .NET SDK: + + 1. Add the signing keys and package repository + ```sh + wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + rm packages-microsoft-prod.deb + ``` + + 2. Install the .NET SDK + ```sh + sudo apt-get update; \ + sudo apt-get install -y apt-transport-https && \ + sudo apt-get update && \ + sudo apt-get install -y dotnet-sdk-5.0 + ``` + If you just want the runtime (which the SDK includes), use + ```sh + sudo apt-get update; \ + sudo apt-get install -y apt-transport-https && \ + sudo apt-get update && \ + sudo apt-get install -y aspnetcore-runtime-5.0 + ``` +5. Navigate to your repo and launch VS Code + ``` + cd /mnt/c/Dev/CodeProject/CodeProject.AI + ```` + +6. Re-open in WSL by hitting `Ctrl+Shift P` for the command pallete, select "Remote-WSL: Reopen Folder in WSL" and hit enter. + +You are now coding against the existing Windows repository, but using a remote connection to the WSL system from within VS Code. From within this current environment it's all Linux. \ No newline at end of file diff --git a/install/Setup_SenseAI_Win.bat b/install/Setup_SenseAI_Win.bat new file mode 100644 index 00000000..1d2baa21 --- /dev/null +++ b/install/Setup_SenseAI_Win.bat @@ -0,0 +1,315 @@ +:: =============================================================================================== +:: +:: CodeProject SenseAI Server Installation Setup script +:: +:: WELCOME TO CODEPROJECT SENSEAI! +:: +:: Please ensure this script is run before you start exploring and integrating CodeProject.SenseAI. +:: This script will download the required pieces, move them into place, run the setup commands and +:: get you on your way. +:: +:: Grab a coffee because it could take a while. But it'll be worth it. We promise. +:: +:: =============================================================================================== + + +@echo off +cls +SETLOCAL EnableDelayedExpansion + +:: ----------------------------------------------------------------------------------------------- +:: 0. Script settings. + +:: The location of large packages that need to be downloaded +:: a. From contrary GCP +rem set storageUrl=https://storage.googleapis.com/codeproject-senseai/ +:: b. From AWS +set storageUrl=https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/ +:: c. Use a local directory rather than from online. Handy for debugging. +:: set storageUrl=C:\Dev\CodeProject\CodeProject.AI\install\cached_downloads\ + +:: The name of the dir, within the current directory, where install assets will be downloaded +set downloadDir=AnalysisLayer + +:: The name of the dir containing the Python interpreter +set pythonDir=python37 + +:: The name of the dir containing the AI models themselves +set modelsDir=assets + +:: Show output in wild, crazy colours +set techniColor=true + +:: verbosity can be: quiet | info | loud +set verbosity=quiet + +:: Set the noise level when installing Python packages +set pipFlags=-q + +:: ...and some misc stuff +if /i "%verbosity%" == "info" set pipFlags= +if /i "%techniColor%" == "true" call :setESC + + +:: ----------------------------------------------------------------------------------------------- +:: 1. Download assets + +:: move down 8 lines so the download/unzip progress doesn't hide the output.' +call :WriteLine White "" +call :WriteLine White "" +call :WriteLine White "========================================================================" +call :WriteLine White "" +call :WriteLine White " CodeProject SenseAI Installer" +call :WriteLine White "" +call :WriteLine White "========================================================================" +call :WriteLine White "" + +:: For downloading assets +if exist %downloadDir%\%pythonDir% ( + call :Write White "Checking Python interpreter..." + call :WriteLine Green "Present" +) else ( + call :Download %storageUrl% %downloadDir%\ python37.zip %pythonDir% ^ + "Downloading Python interpreter..." +) +if exist %downloadDir%\%modelsDir% ( + call :Write White "Checking AI Models..." + call :WriteLine Green "Present" +) else ( + call :Download %storageUrl% %downloadDir%\ models.zip %modelsDir% ^ + "Downloading AI Models..." +) + + +:: ----------------------------------------------------------------------------------------------- +:: 2. Setup Python environment + +call :Write White "Creating a Python virtual environment..." + +:: Create the Virtual Environment +%cd%\%downloadDir%\%pythonDir%\python -m venv AnalysisLayer\venv + +:: Activate the Virtual Environment (so we can install packages) +set VIRTUAL_ENV=%cd%\AnalysisLayer\venv\Scripts + +if not defined PROMPT set PROMPT=$P$G +set PROMPT=(venv) !PROMPT! + +set PYTHONHOME= +set PATH=%VIRTUAL_ENV%;%PATH% +call :WriteLine Green "Done" + +:: Install required packages +if not exist AnalysisLayer\venv\Lib\site-packages\torch ( + call :WriteLine White "Installing required Python packages. This could take a while" + + call :Write White " - Installing Python package manager..." + if /i "%verbosity%" == "quiet" ( + python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org ^ + --trusted-host pypi.org --upgrade pip !pipFlags! >nul 2>nul + ) else ( + python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org ^ + --trusted-host pypi.org --upgrade pip !pipFlags! + ) + + call :WriteLine Green "Done" + + REM This is the easy way, but doesn't provide any feedback on what's going on + REM pip install -r %deepStackPath%\%intelligenceDir%\requirements.txt !pipFlags! + REM call :WriteLine Green "Success" + + REM We'll do this the long way so we can see some progress + set currentOption= + for /f "tokens=*" %%x in (AnalysisLayer\IntelligenceLayer\requirements.txt) do ( + + set line=%%x + + if "!line!" == "" ( + set currentOption= + ) else if "!line:~0,2!" == "##" ( + set currentOption= + ) else if "!line:~0,12!" == "--find-links" ( + set currentOption=!line! + ) else ( + call :Write White " PIP: Installing !line!..." + if /i "%verbosity%" == "quiet" ( + python.exe -m pip install !line! !currentOption! !pipFlags! >nul 2>nul + ) else ( + python.exe -m pip install !line! !currentOption! !pipFlags! + ) + call :WriteLine Green "Done" + + set currentOption= + ) + ) + call :WriteLine Green "All packages installed." +) else ( + call :WriteLine Green "Python packages already present." +) + +:: ----------------------------------------------------------------------------------------------- +:: 3. All done! + +call :WriteLine Green "" +call :WriteLine Green "" +call :WriteLine Green "Setup Complete" +call :Write Green "Run" +call :Write Yellow " Start_SenseAI_Win.bat" +call :WriteLine Green " to start the server." +start "" ./Welcome.html + + +goto:eof + + + +:: =============================================================================================== +:: =============================================================================================== + + +:: sub-routines + +:setESC + for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( + set ESC=%%b + exit /B 0 + ) + exit /B 0 + +:setColor + REM echo %ESC%[4m - Underline + REM echo %ESC%[7m - Inverse + + if /i "%2" == "foreground" ( + REM Foreground Colours + if /i "%1" == "Black" set currentColor=!ESC![30m + if /i "%1" == "DarkRed" set currentColor=!ESC![31m + if /i "%1" == "DarkGreen" set currentColor=!ESC![32m + if /i "%1" == "DarkYellow" set currentColor=!ESC![33m + if /i "%1" == "DarkBlue" set currentColor=!ESC![34m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![35m + if /i "%1" == "DarkCyan" set currentColor=!ESC![36m + if /i "%1" == "Gray" set currentColor=!ESC![37m + if /i "%1" == "DarkGray" set currentColor=!ESC![90m + if /i "%1" == "Red" set currentColor=!ESC![91m + if /i "%1" == "Green" set currentColor=!ESC![92m + if /i "%1" == "Yellow" set currentColor=!ESC![93m + if /i "%1" == "Blue" set currentColor=!ESC![94m + if /i "%1" == "Magenta" set currentColor=!ESC![95m + if /i "%1" == "Cyan" set currentColor=!ESC![96m + if /i "%1" == "White" set currentColor=!ESC![97m + ) else ( + REM Background Colours + if /i "%1" == "Black" set currentColor=!ESC![40m + if /i "%1" == "DarkRed" set currentColor=!ESC![41m + if /i "%1" == "DarkGreen" set currentColor=!ESC![42m + if /i "%1" == "DarkYellow" set currentColor=!ESC![43m + if /i "%1" == "DarkBlue" set currentColor=!ESC![44m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![45m + if /i "%1" == "DarkCyan" set currentColor=!ESC![46m + if /i "%1" == "Gray" set currentColor=!ESC![47m + if /i "%1" == "DarkGray" set currentColor=!ESC![100m + if /i "%1" == "Red" set currentColor=!ESC![101m + if /i "%1" == "Green" set currentColor=!ESC![102m + if /i "%1" == "Yellow" set currentColor=!ESC![103m + if /i "%1" == "Blue" set currentColor=!ESC![104m + if /i "%1" == "Magenta" set currentColor=!ESC![105m + if /i "%1" == "Cyan" set currentColor=!ESC![106m + if /i "%1" == "White" set currentColor=!ESC![107m + ) + exit /B 0 + +:WriteLine + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if "%~2" == "" ( + Echo: + exit /b 0 + ) + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 %~2 + call :setColor %1 foreground + echo !currentColor!%~2!resetColor! + ) else ( + Echo %~2 + ) + exit /b 0 + +:Write + + if "%~2" == "" exit /b 0 + + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 -NoNewline %~2 + call :setColor %1 foreground + nul 2>nul + pushd !dirToSave! + tar -xf !dirToSave!.zip > nul 2>nul + if "%errorlevel%" == "9009" set tarExists=false + rm !dirToSave!.zip > nul 2>nul + popd + popd + + if "!tarExists!" == "false" ( + powershell Expand-Archive -Path !downloadToDir!!dirToSave!.zip -DestinationPath !downloadToDir! -Force + ) + + del /s /f /q !downloadToDir!!dirToSave!.zip > nul + + call :WriteLine Green "Done." + + exit /b diff --git a/install/Start_SenseAI_Win.bat b/install/Start_SenseAI_Win.bat new file mode 100644 index 00000000..a3445f4f --- /dev/null +++ b/install/Start_SenseAI_Win.bat @@ -0,0 +1,246 @@ +:: CodeProject SenseAI Server startup script +:: We assume we're in the CodeProject SenseAI installed directory. + +@echo off +cls +SETLOCAL EnableDelayedExpansion + +:: Basic Settings + +:: verbosity can be: quiet | info | loud +set verbosity=quiet + +:: The name of the CodeProject Sense App Executable file +set appExe=CodeProject.SenseAI.Server.exe + +:: Can be Debug or Releaes +set config=Debug + +:: The target platform +set platform=net5.0 + +:: The name of the Environment variable setup file +set envVariablesFile=set_environment.bat + +:: Show output in wild, crazy colours +set techniColor=true + +:: ------------------------------------------------------------- +:: Set Flags + +set dotnetFlags=q +if "%verbosity%"=="info" set dotnetFlags=m +if "%verbosity%"=="loud" set dotnetFlags=n + +if /i "%techniColor%" == "true" call :setESC + +call :WriteLine Yellow "Preparing CodeProject.SenseAI Server" + +:: =============================================================================================== +:: 1. Load Installation settings + +call :Write White "Loading installation settings..." +call !envVariablesFile! +call :WriteLine Green "Done" + +if "%verbosity%" == "info" ( + echo APPDIR = "!APPDIR!" + echo PROFILE = "!PROFILE!" + echo CUDA_MODE = "!CUDA_MODE!" + echo DATA_DIR = "!DATA_DIR!" + echo TEMP_PATH = "!TEMP_PATH!" + echo PORT = "!PORT!" + echo VISION_FACE = "!VISION_FACE!" + echo VISION_DETECTION = "!VISION_DETECTION!" + echo VISION_SCENE = "!VISION_SCENE!" +) + +:: =============================================================================================== +:: 2. Activate Virtual Environment + +call :Write White "Enabling our Virtual Environment..." + +cd !APPDIR!\.. +set VIRTUAL_ENV=%cd%\venv\Scripts + +if not defined PROMPT set PROMPT=$P$G +set PROMPT=(venv) !PROMPT! + +set PYTHONHOME= +set PATH=!VIRTUAL_ENV!;%PATH% + +if errorlevel 1 goto errorNoPythonVenv +call :WriteLine Green "Done" + +:: Ensure Python Exists +call :Write White "Checking for Python 3.7..." +python --version | find "3.7" > NUL +if errorlevel 1 goto errorNoPython +call :WriteLine Green "present" + +if "%verbosity%"=="loud" where Python.exe + +:: =============================================================================================== +:: 3. Start front end server + +:: a. Startup the backend Analysis services +call :Write White "Starting Analysis Services..." +if /i "!VISION_DETECTION!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\detection.py +) +if /i "!VISION_FACE!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\face.py +) +if /i "!VISION_SCENE!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\scene.py +) +:: To start them all in one fell swoop... +:: START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\runAll.py +call :WriteLine Green "Done" + +:: b. Build and startup the API server + +set featureFlags= +if /i "!VISION_FACE!" == "true" set featureFlags=!featureFlags! --VISION_FACE true +if /i "!VISION_DETECTION!" == "true" set featureFlags=!featureFlags! --VISION-DETECTION true +if /i "!VISION_SCENE!" == "true" set featureFlags=!featureFlags! --VISION-SCENE true + +:: In an installed, Production version of SenseAI, the server sits directly in the Server/Frontend +:: folder. For the development environment the server code is in /src/Server/Frontend. For Dev +:: we'll build the API server but leave it inside the :: /bin/Debug/... folder. Hence we need to +:: update the location of the main executable. + +if /i "!CPSENSEAI_PRODUCTION!" == "true" ( + set CPSENSEAI_BUILDSERVER=False + Set CPSENSEAI_COMFIG=Release + + cd %CPSENSEAI_ROOTDIR%\%CPSENSEAI_APIDIR%\Server\FrontEnd +) else ( + if /i "!CPSENSEAI_BUILDSERVER!" == "true" ( + cd %CPSENSEAI_ROOTDIR%\%CPSENSEAI_APPDIR%\%CPSENSEAI_APIDIR%\Server\FrontEnd + dotnet build --configuration !CPSENSEAI_COMFIG! --nologo --verbosity !dotnetFlags! + REM TODO Sort out the path issues with the build + set appExe=bin\!platform!\!CPSENSEAI_COMFIG!\!platform!\!appExe! + ) +) + +call :WriteLine Yellow "Launching CodeProject.SenseAI Server" + +!appExe! !featureFlags! --urls http://*:%port% + +:: and we're done. +goto:eof + + +:: sub-routines + +:setESC + for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( + set ESC=%%b + exit /B 0 + ) + exit /B 0 + +:setColor + REM echo %ESC%[4m - Underline + REM echo %ESC%[7m - Inverse + + if /i "%2" == "foreground" ( + REM Foreground Colours + if /i "%1" == "Black" set currentColor=!ESC![30m + if /i "%1" == "DarkRed" set currentColor=!ESC![31m + if /i "%1" == "DarkGreen" set currentColor=!ESC![32m + if /i "%1" == "DarkYellow" set currentColor=!ESC![33m + if /i "%1" == "DarkBlue" set currentColor=!ESC![34m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![35m + if /i "%1" == "DarkCyan" set currentColor=!ESC![36m + if /i "%1" == "Gray" set currentColor=!ESC![37m + if /i "%1" == "DarkGray" set currentColor=!ESC![90m + if /i "%1" == "Red" set currentColor=!ESC![91m + if /i "%1" == "Green" set currentColor=!ESC![92m + if /i "%1" == "Yellow" set currentColor=!ESC![93m + if /i "%1" == "Blue" set currentColor=!ESC![94m + if /i "%1" == "Magenta" set currentColor=!ESC![95m + if /i "%1" == "Cyan" set currentColor=!ESC![96m + if /i "%1" == "White" set currentColor=!ESC![97m + ) else ( + REM Background Colours + if /i "%1" == "Black" set currentColor=!ESC![40m + if /i "%1" == "DarkRed" set currentColor=!ESC![41m + if /i "%1" == "DarkGreen" set currentColor=!ESC![42m + if /i "%1" == "DarkYellow" set currentColor=!ESC![43m + if /i "%1" == "DarkBlue" set currentColor=!ESC![44m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![45m + if /i "%1" == "DarkCyan" set currentColor=!ESC![46m + if /i "%1" == "Gray" set currentColor=!ESC![47m + if /i "%1" == "DarkGray" set currentColor=!ESC![100m + if /i "%1" == "Red" set currentColor=!ESC![101m + if /i "%1" == "Green" set currentColor=!ESC![102m + if /i "%1" == "Yellow" set currentColor=!ESC![103m + if /i "%1" == "Blue" set currentColor=!ESC![104m + if /i "%1" == "Magenta" set currentColor=!ESC![105m + if /i "%1" == "Cyan" set currentColor=!ESC![106m + if /i "%1" == "White" set currentColor=!ESC![107m + ) + exit /B 0 + +:WriteLine + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if "%~2" == "" ( + Echo: + exit /b 0 + ) + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 %~2 + call :setColor %1 foreground + echo !currentColor!%~2!resetColor! + ) else ( + Echo %~2 + ) + exit /b 0 + +:Write + + if "%~2" == "" exit /b 0 + + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 -NoNewline %~2 + call :setColor %1 foreground + nul 2>nul - -cd ..\.. -mkdir %installationDir%\demos\TestData -robocopy /e TestData %installationDir%\demos\TestData /NFL /NDL /NJH /NJS /nc /ns >nul 2>nul - -mkdir %installationDir%\demos\Javascript -robocopy /e Javascript %installationDir%\demos\Javascript /NFL /NDL /NJH /NJS /nc /ns >nul 2>nul - -:: dotnet build --configuration Release --nologo --verbosity !dotnetFlags! --self-contained true - .NET 6 - -echo Done diff --git a/install/create_installer_win.bat b/install/create_installer_win.bat new file mode 100644 index 00000000..461f240d --- /dev/null +++ b/install/create_installer_win.bat @@ -0,0 +1,463 @@ +:: =============================================================================================== +:: +:: CodeProject SenseAI Server create installer script. +:: +:: This script will build a directory full of everything needed to run CodeProject.SenseAI. It's a +:: large download. There's no getting around that, unfortunately. The only alternative is to create +:: a download that includes an install script that then pulls down the required pieces. Total +:: download will still be the same, though. +:: +:: We assume we're in the source code /install directory. +:: +:: Copyright CodeProject 2021 +:: +:: =============================================================================================== + +@echo off +cls +setlocal enabledelayedexpansion + + +:: ------------------------------------------------------------- +:: 0. Script settings. + +:: The location of the installation directory that will be created +set installationDir=c:\CodeProject.SenseAI.Package + +:: The location of the installation package that will be created +set installationPackage=c:\CodeProject.SenseAI.Package.zip + +:: The location of the solution root directory relative to this script +set rootPath=%cd%\.. + +:: Whether or not to compress the final installation package. Currently fails due to access denied error +set compressInstallation=true + +:: Whether or not to remove the installation directory after it's been compressed +set removeInstallationFolder=true + +:: verbosity can be: quiet | info | loud +set verbosity=quiet + +:: Show output in wild, crazy colours +set techniColor=true + +:: SenseAI specific ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The name of the dir holding the frontend API server +set senseAPIDir=API + +:: The name of the startup settings file +set settingsFile=CodeProject.SenseAI.config + +:: .NET build configuration: [Debug | Release] +set config=Release + +:: Where to put the Builds +set buildOutputDir=bin\InstallPackage + +:: DeepStack specific ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The name of the dir holding the DeepStack analysis services +set deepstackDir=DeepStack + +:: The name of the dir containing the Python code itself +set intelligenceDir=intelligencelayer + +:: The name of the dir containing the AI models themselves +set modelsDir=assets + +:: The name of the dir containing persisted DeepStack data +set datastoreDir=datastore + +:: The name of the dir containing temporary DeepStack data +set tempstoreDir=tempstore + +:: The name of the Environment variable setup file +set envVariablesFile=set_environment.bat + +:: Shared ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The name of the dir, within the current directory, where install assets will be downloaded +set downloadDir=downloads + +:: The name of the dir containing the Python interpreter +set pythonDir=python37 + +:: The name of the source directory +set srcDir=src + +:: The name of the dir holding the backend analysis services +set analysisLayerDir=AnalysisLayer + +:: The name of the demos directory +set demoDir=demos + + +:: ------------------------------------------------------------- +:: Set Flags and misc. + +set roboCopyFlags=/NFL /NDL /NJH /NJS /nc /ns >nul 2>nul +set dotnetFlags=q + +if "%verbosity%"=="info" set dotnetFlags=m +if "%verbosity%"=="loud" set roboCopyFlags=/NFL /NDL /nc /ns +if "%verbosity%"=="loud" set dotnetFlags=n + +if /i "%techniColor%" == "true" call :setESC + +:: ------------------------------------------------------------- +:: 1. Ensure correct permissions before we start + +:: Only need elevated permissions if we are compressing the install +if /i "%compressInstallation%" NEQ "true" goto hasCorrectPermissions + +:: We're compressing, so let's ensure we have permissions to do this +call :Write DarkYellow "Checking administrative privileges..." + +set hasAdmin=true +for /f "tokens=*" %%O in ('FSUTIL dirty query %SystemDrive% 2^> nul') do ( + set line=%%O + if "!line:denied=!" NEQ "!line!" set hasAdmin=false +) +if /i "!hasAdmin!" == "true" goto hasCorrectPermissions + +:: ------------------------------------------------------------------------------------------------ +:: We don't have permissions needed. We can try and restart this script with correct permissions, +:: or we can just tell the user to restart in admin mode. The latter is way less hassle. + +set attemptRestart=false + +if /i "%attemptRestart%" == "true" ( + REM Get the details of this script so we can relaunch it + Set _batchFile=%~f0 + Set _Args=%* + + REM remove any quotes. We'll add them back below (VBScript needs quotes doubled) + Set _batchFile=!_batchFile:"=! + + REM Create and run a temporary VBScript to elevate this batch file + del /s /f /q "%temp%\~ElevateMe.vbs" > nul + ( + Echo Dim UAC : Set UAC = CreateObject^("Shell.Application"^) + Echo UAC.ShellExecute "cmd", "/c ""!_batchFile! !_Args!"" ", "", "runas", 1 + ) > "%temp%\~ElevateMe.vbs" + more "%temp%\~ElevateMe.vbs" + cscript "%temp%\~ElevateMe.vbs" + Exit /B +) else ( + call :WriteLine Red "Insufficient privliges" + call :WriteLine DarkYellow "To compress the installation package please restart this script in admin mode" + goto:eof +) + +:hasCorrectPermissions +call :WriteLine Green "Success" + + +:: =============================================================================================== +:: 2. Do the heavy lifting of ensuring the dev environment is setup so we can just do a bunch of +:: copies + +call setup_dev_env_win.bat %techniColor% +if errorlevel 1 goto:eof + +call :WriteLine Yellow "Creating CodeProject.SenseAI Installation Package" + + +:: =============================================================================================== +:: 3. Clean the install folder + +:: We don't want the database, venv, models, or Python directories. These will be installed by the +:: Setup_SenseAI_Win.bat file, so delete them if they exist (eg someone already ran Setup). + +call :Write White "Ensuring the installation folder is reset and clean..." + +if exist %installationDir%\%analysisLayerDir%\%datastoreDir%\faceembedding.db ^ +del %installationDir%\%analysisLayerDir%\%datastoreDir%\faceembedding.db /Q > NUL +if exist %installationDir%\%analysisLayerDir%\venv ^ +rd %installationDir%\%analysisLayerDir%\venv /S /Q > NUL +if exist rd %installationDir%\%analysisLayerDir%\%modelsDir% ^ +rd %installationDir%\%analysisLayerDir%\%modelsDir% /S /Q > NUL +if exist %installationDir%\%analysisLayerDir%\%pythonDir% ^ +rd %installationDir%\%analysisLayerDir%\%pythonDir% /S /Q > NUL + +call :WriteLine Green "Done." + + +:: =============================================================================================== +:: 4. Ensure directories are created + +:: Create some directories +call :Write White "Creating Directories..." + +if not exist %installationDir% mkdir %installationDir% +if not exist %installationDir%\%analysisLayerDir% mkdir %installationDir%\%analysisLayerDir% + +:: For CodeProject.SenseAI +set senseAIInstallPath=%installationDir%\%senseAPIDir% +if not exist %senseAIInstallPath% mkdir %senseAIInstallPath% + +:: For DeepStack +:: Deepstack gets copied over in one fell swoop. No need to create dirs + +call :WriteLine Green "Done" + + +:: =============================================================================================== +:: 5. Copy over the server code, models and virtual environment + +:: For CodeProject.SenseAI + +:: Build server +call :WriteLine White "Building API Server [%config%]..." +set serverPath=%rootPath%\%srcDir%\%senseAPIDir%\Server\FrontEnd +pushd %serverPath% +REM Note: The carrot character means "line continuation" +if /i "%verbosity%"=="quiet" ( + dotnet build --configuration %config% --self-contained false -o %buildOutputDir% --nologo ^ + --verbosity !dotnetFlags! > nul +) else ( + dotnet build --configuration %config% --self-contained false -o %buildOutputDir% --nologo ^ + --verbosity !dotnetFlags! +) +popd + +:: Copy over +call :Write White "Moving API Server to installation folder..." +if /i "%verbosity%"=="quiet" ( + robocopy /e %serverPath%\%buildOutputDir% %installationDir%\%senseAPIDir%\Server\FrontEnd ^ + /XF *.pdb !roboCopyFlags! > nul +) else ( + robocopy /e %serverPath%\%buildOutputDir% %installationDir%\%senseAPIDir%\Server\FrontEnd ^ + /XF *.pdb !roboCopyFlags! +) +call :WriteLine Green "Done." + +:: For DeepStack +set deepStackPath=%rootPath%\%srcDir%\%analysisLayerDir%\%deepstackDir% + +call :Write White "Moving Analysis services to installation folder..." +if /i "%verbosity%"=="quiet" ( + robocopy /e %deepStackPath% %installationDir%\%analysisLayerDir% /XD venv %modelsDir% ^ + /XF faceembeddings.db !roboCopyFlags! > nul +) else ( + robocopy /e %deepStackPath% %installationDir%\%analysisLayerDir% /XD venv %modelsDir% ^ + /XF faceembeddings.db !roboCopyFlags! +) +call :WriteLine Green "Done." + +:: Copy over the setup and startup scripts +call :Write White "Copying over startup files..." +copy /Y "Setup_SenseAI_Win.bat" "!installationDir!" >nul 2>nul +copy /Y "Start_SenseAI_Win.bat" "!installationDir!" >nul 2>nul +copy /Y "..\docs\Welcome.html" "!installationDir!" >nul 2>nul +call :WriteLine Green "Done." + +call :Write White "Reloading base installation settings..." +call !rootPath!\!srcDir!\!envVariablesFile! +call :WriteLine Green "Done" + +call :Write White "Updating installation Environment variables..." +set CPSENSEAI_ROOTDIR=!installationDir! +set CPSENSEAI_APPDIR=!analysisLayerDir!\!intelligenceDir! +set CPSENSEAI_APIDIR=!senseAPIDir! +set CPSENSEAI_ANALYSISDIR=!analysisLayerDir! +set CPSENSEAI_COMFIG=Release +set CPSENSEAI_BUILDSERVER=False +set CPSENSEAI_PRODUCTION=True +set APPDIR=!installationDir!\!analysisLayerDir!\!intelligenceDir! +set DATA_DIR=!installationDir!\!analysisLayerDir!\!datastoreDir! +set TEMP_PATH=!installationDir!\!analysisLayerDir!\!tempstoreDir! +set MODELS_DIR=!installationDir!\!analysisLayerDir!\!modelsDir! +set PORT=5000 +set VISION_FACE=True +set VISION_DETECTION=True +set VISION_SCENE=True + +call save_environment !installationDir!\!envVariablesFile! !installationDir!\!settingsFile! +call :WriteLine Green "Done." + + +:: =============================================================================================== +:: 6. Prepare the demos + +:: Do we need this given the HTML version has feature parity? +set includeDotnetDemo=false + +if /i "%includeDotnetDemo%" == "true" ( + REM Build .NET demo + call :Write White "Building .NET demo [%config%] ..." + cd %rootPath%\%demoDir%\dotNET\CodeProject.SenseAI.Playground + + if /i "%verbosity%"=="quiet" ( + dotnet publish --configuration %config% -o %buildOutputDir% --nologo !dotnetFlags! > nul + ) else ( + dotnet publish --configuration %config% -o %buildOutputDir% --nologo !dotnetFlags! + ) + call :WriteLine Green "Done." +) + +:: Copy demos + +call :Write White "Coping demos to installation..." + +if not exist %installationDir%\%demoDir% mkdir %installationDir%\%demoDir% > nul +cd %installationDir%\%demoDir% + +if /i "%includeDotnetDemo%" == "true" ( + if not exist Playground mkdir Playground + robocopy /e %rootPath%\%demoDir%\dotNET\CodeProject.SenseAI.Playground\%buildOutputDir% ^ + %installationDir%\%demoDir%\Playground /XF *.pdb !roboCopyFlags! > nul +) + +if not exist Javascript mkdir Javascript +robocopy /e %rootPath%\%demoDir%\Javascript Javascript !roboCopyFlags! > nul + +call :WriteLine Green "Done." + + +:: Copy test data + +call :Write White "Coping test data to installation..." +if not exist TestData mkdir TestData +robocopy /e %rootPath%\%demoDir%\TestData %installationDir%\%demoDir%\TestData !roboCopyFlags! > nul +call :WriteLine Green "Done." + + +:: =============================================================================================== +:: 7. Compress the final package if required + +if /i "%compressInstallation%" == "true" ( + + call :WriteLine White "Compressing installation package..." + if exist "%installationPackage%" del "%installationPackage%" + + REM Try tar first. If that doesn't work, fall back to pwershell (slow) + set tarExists=true + pushd !downloadToDir! + + if /i "%verbosity%"=="quiet" ( + tar -caf %installationPackage% %installationDir% > nul + ) else ( + tar -cvaf %installationPackage% %installationDir% + ) + + if "%errorlevel%" == "9009" set tarExists=false + popd + + if "!tarExists!" == "false" ( + powershell Compress-Archive -Force -Path "%installationDir%\*" ^ + -DestinationPath "%installationPackage%" -CompressionLevel Optimal + ) + + if ErrorLevel 0 ( + if exist %installationPackage% ( + if /i "%removeInstallationFolder%" == "true" ( + call :Write White "Removing installation folder..." + rmdir "%installationDir%" /s /q > nul + rem del /s /f /q "%installationDir%" > nul + call :WriteLine Green "Done" + ) + ) + ) +) + + +:: =============================================================================================== +:: and we're done. + + +call :WriteLine Yellow "Installation folder creation complete" +call :WriteLine White "" +call :WriteLine White "" + +goto:eof + + + +:: =============================================================================================== +:: =============================================================================================== + +:: sub-routines + +:setESC + for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( + set ESC=%%b + exit /B 0 + ) + exit /B 0 + +:setColor + REM echo %ESC%[4m - Underline + REM echo %ESC%[7m - Inverse + + if /i "%2" == "foreground" ( + REM Foreground Colours + if /i "%1" == "Black" set currentColor=!ESC![30m + if /i "%1" == "DarkRed" set currentColor=!ESC![31m + if /i "%1" == "DarkGreen" set currentColor=!ESC![32m + if /i "%1" == "DarkYellow" set currentColor=!ESC![33m + if /i "%1" == "DarkBlue" set currentColor=!ESC![34m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![35m + if /i "%1" == "DarkCyan" set currentColor=!ESC![36m + if /i "%1" == "Gray" set currentColor=!ESC![37m + if /i "%1" == "DarkGray" set currentColor=!ESC![90m + if /i "%1" == "Red" set currentColor=!ESC![91m + if /i "%1" == "Green" set currentColor=!ESC![92m + if /i "%1" == "Yellow" set currentColor=!ESC![93m + if /i "%1" == "Blue" set currentColor=!ESC![94m + if /i "%1" == "Magenta" set currentColor=!ESC![95m + if /i "%1" == "Cyan" set currentColor=!ESC![96m + if /i "%1" == "White" set currentColor=!ESC![97m + ) else ( + REM Background Colours + if /i "%1" == "Black" set currentColor=!ESC![40m + if /i "%1" == "DarkRed" set currentColor=!ESC![41m + if /i "%1" == "DarkGreen" set currentColor=!ESC![42m + if /i "%1" == "DarkYellow" set currentColor=!ESC![43m + if /i "%1" == "DarkBlue" set currentColor=!ESC![44m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![45m + if /i "%1" == "DarkCyan" set currentColor=!ESC![46m + if /i "%1" == "Gray" set currentColor=!ESC![47m + if /i "%1" == "DarkGray" set currentColor=!ESC![100m + if /i "%1" == "Red" set currentColor=!ESC![101m + if /i "%1" == "Green" set currentColor=!ESC![102m + if /i "%1" == "Yellow" set currentColor=!ESC![103m + if /i "%1" == "Blue" set currentColor=!ESC![104m + if /i "%1" == "Magenta" set currentColor=!ESC![105m + if /i "%1" == "Cyan" set currentColor=!ESC![106m + if /i "%1" == "White" set currentColor=!ESC![107m + ) + exit /B 0 + +:WriteLine + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if "%~2" == "" ( + Echo: + exit /b 0 + ) + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 %~2 + call :setColor %1 foreground + echo !currentColor!%~2!resetColor! + ) else ( + Echo %~2 + ) + exit /b 0 + +:Write + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 -NoNewline %~2 + call :setColor %1 foreground + !envConfigFile! + +:: Also create a .BAT file for easy Starting + +( +echo REM SenseAI Application values +echo set CPSENSEAI_ROOTDIR=!CPSENSEAI_ROOTDIR! +echo set CPSENSEAI_APPDIR=!CPSENSEAI_APPDIR! +echo set CPSENSEAI_APIDIR=!CPSENSEAI_APIDIR! +echo set CPSENSEAI_ANALYSISDIR=!CPSENSEAI_ANALYSISDIR! +echo set CPSENSEAI_PORT=!PORT! +echo set CPSENSEAI_PROFILE=!PROFILE! +echo set CPSENSEAI_MODULES=!CPSENSEAI_MODULES! +echo set CPSENSEAI_PRODUCTION=!CPSENSEAI_PRODUCTION! +echo set CPSENSEAI_COMFIG=!CPSENSEAI_COMFIG! +echo set CPSENSEAI_BUILDSERVER=!CPSENSEAI_BUILDSERVER! + +echo REM DeepStack compatible values +echo set APPDIR=!APPDIR! +echo set PROFILE=!PROFILE! +echo set CUDA_MODE=!CUDA_MODE! +echo set DATA_DIR=!DATA_DIR! +echo set TEMP_PATH=!TEMP_PATH! +echo set MODELS_DIR=!MODELS_DIR! +echo set PORT=!PORT! +echo set VISION_FACE=!VISION_FACE! +echo set VISION_DETECTION=!VISION_DETECTION! +echo set VISION_SCENE=!VISION_SCENE! +) > !envVariablesFile! \ No newline at end of file diff --git a/install/scripts/download.ps1 b/install/scripts/download.ps1 deleted file mode 100644 index bf7153a3..00000000 --- a/install/scripts/download.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -function DownloadAndExtract($URL, $DownloadDir, $DirToSave){ - - Write-Host -NoNewline "Downloading to" $DownloadDir$DirToSave"..." # "from" $URL "..." - - try { - - # Doesn't provide progress as % - # Invoke-WebRequest -Uri $URL -OutFile $DownloadDir$DirToSave".zip" - - Start-BitsTransfer -Source $URL -Destination $DownloadDir$DirToSave".zip" - } - catch { - "An error occurred that could not be resolved." - } - - Write-Host -NoNewline "Expanding..." - Expand-Archive -Path $DownloadDir$DirToSave".zip" -DestinationPath $DownloadDir$DirToSave -Force - Remove-Item -Path $DownloadDir$DirToSave".zip" -Force - Write-Host "Done." -} - -$storageUrl = $args[0] # "https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/" -$downloadDir = $args[1] # "downloads/" # relative to the current directory -$fileToGet = $args[2] # eg packages_for_gpu.zip -$dirToSave = $args[3] # eg packages - -DownloadAndExtract -URL $storageUrl$fileToGet -DownloadDir $downloadDir -DirToSave $dirToSave \ No newline at end of file diff --git a/install/set_environment.sh b/install/set_environment.sh new file mode 100644 index 00000000..a72e1c16 --- /dev/null +++ b/install/set_environment.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +## If you wish to have a single environment variable file for sharing between +## operating systems then this script will read the Windows .bat version and +## export the variables within a *nix shall +## +## Usage: +## . ./set_environment.sh + +unamestr=$(uname) +if [ "$unamestr" = 'Linux' ]; then + export $(grep -v '^REM' set_environment.bat | xargs -d '\n') +elif [ "$unamestr" = 'FreeBSD' ]; then + export $(grep -v '^REM' set_environment.bat | xargs -0) +fi \ No newline at end of file diff --git a/install/setup_dev_env_win.bat b/install/setup_dev_env_win.bat new file mode 100644 index 00000000..9cdd0b6b --- /dev/null +++ b/install/setup_dev_env_win.bat @@ -0,0 +1,461 @@ +:: CodeProject SenseAI Server +:: +:: Windows Development Environment install script +:: +:: We assume we're in the source code /install directory. +:: + +@echo off +cls +setlocal enabledelayedexpansion + +:: verbosity can be: quiet | info | loud +set verbosity=quiet + +:: If files are already present, then don't overwrite if this is false +set forceOverwrite=false + +:: Show output in wild, crazy colours +set techniColor=true + +:: Basic App Features + +set enableFaceDetection=True +set enableObjectDetection=True +set enableSceneDetection=True + +set PROFILE=windows_native +set CUDA_MODE=False +set PORT=5000 + + +:: Basic locations + +:: The location of the solution root directory relative to this script +set rootPath=.. + +:: SenseAI specific ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The name of the dir holding the frontend API server +set senseAPIDir=API + +:: The name of the startup settings file +set settingsFile=CodeProject.SenseAI.config + +:: DeepStack specific ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The name of the dir holding the DeepStack analysis services +set deepstackDir=DeepStack + +:: The name of the dir containing the Python code itself +set intelligenceDir=intelligencelayer + +:: The name of the dir containing the AI models themselves +set modelsDir=assets + +:: The name of the dir containing persisted DeepStack data +set datastoreDir=datastore + +:: The name of the dir containing temporary DeepStack data +set tempstoreDir=tempstore + +:: The name of the Environment variable setup file +set envVariablesFile=set_environment.bat + +:: Shared ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The location of large packages that need to be downloaded +:: a. From contrary GCP +rem set storageUrl=https://storage.googleapis.com/codeproject-senseai/ +:: b. From AWS +set storageUrl=https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/ +:: c. Use a local directory rather than from online. Handy for debugging. +:: set storageUrl=C:\Dev\CodeProject\CodeProject.SenseAI\install\cached_downloads\ + +:: The name of the source directory +set srcDir=src + +:: The name of the dir, within the current directory, where install assets will be downloaded +set downloadDir=downloads + +:: The name of the dir containing the Python interpreter +set pythonDir=python37 + +:: The name of the dir holding the backend analysis services +set analysisLayerDir=AnalysisLayer + +:: Absolute paths ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + +:: The absolute path to the root directory of CodeProject.SenseAI +set currentDir=%cd% +cd %rootPath% +set absoluteRootDir=%cd% +cd %currentDir% + +:: The location of the backend analysis layer relative to the root of the solution directory +set analysisLayerPath=%absoluteRootDir%\%srcDir%\%analysisLayerDir% + +if /i "%1" == "false" set techniColor=false +if /i "%techniColor%" == "true" call :setESC + +:: Set Flags + +set pipFlags=-q -q +set rmdirFlags=/q +set roboCopyFlags=/NFL /NDL /NJH /NJS /nc /ns >nul 2>nul + +if "%verbosity%"=="info" set pipFlags=-q +if "%verbosity%"=="info" set rmdirFlags=/q +if "%verbosity%"=="info" set roboCopyFlags=/NFL /NDL /NJH + +if "%verbosity%"=="loud" set pipFlags= +if "%verbosity%"=="loud" set rmdirFlags= +if "%verbosity%"=="loud" set roboCopyFlags= + +call :WriteLine Yellow "Setting up CodeProject.SenseAI Development Environment" +call :WriteLine White "" +call :WriteLine White "========================================================================" +call :WriteLine White "" +call :WriteLine White " CodeProject SenseAI Installer" +call :WriteLine White "" +call :WriteLine White "========================================================================" +call :WriteLine White "" + +:: =============================================================================================== +:: 1. Ensure directories are created and download required assets + +:: Create some directories +call :Write White "Creating Directories..." + +:: For downloading assets +if not exist %downloadDir%\ mkdir %downloadDir% + +:: For DeepStack +set deepStackPath=%analysisLayerPath%\%deepstackDir% +if not exist %deepStackPath%\%tempstoreDir%\ mkdir %deepStackPath%\%tempstoreDir% +if not exist %deepStackPath%\%datastoreDir%\ mkdir %deepStackPath%\%datastoreDir% + +call :WriteLine Green "Done" + +call :Write White "Downloading utilities and models: " +call :WriteLine Gray "Starting" + +:: Clean up directories to force a re-download if necessary +if /i "%forceOverwrite%" == "true" ( + if exist %downloadDir%\%modelsDir% rmdir /s %rmdirFlags% %downloadDir%\%modelsDir% + if exist %downloadDir%\%pythonDir% rmdir /s %rmdirFlags% %downloadDir%\%pythonDir% +) + +:: Download whatever packages are missing +if not exist %downloadDir%\%modelsDir% ( + call :Download %storageUrl% %downloadDir%\ models.zip %modelsDir% ^ + "Downloading models..." +) +if not exist %downloadDir%\python37 ( + call :Download %storageUrl% %downloadDir%\ python37.zip %pythonDir% ^ + "Downloading Python interpreter..." +) + +:: Move downloads into place +call :Write White "Moving downloads into place..." +if exist %downloadDir%\%modelsDir% robocopy /e %downloadDir%\%modelsDir% %deepStackPath%\%modelsDir% !roboCopyFlags! > NUL +call :WriteLine Green "Done" + +:: Copy over the startup script +call :Write White "Copying over startup script..." +copy /Y "Start_SenseAI_Win.bat" "!absoluteRootDir!\!srcDir!" >nul 2>nul +call :WriteLine Green "Done." + +call :Write White "Downloading utilities and models: " +call :WriteLine Green "Completed" + +:: =============================================================================================== +:: 2. Create & Activate Virtual Environment: DeepStack specific / Python 3.7 + +call :Write White "Creating Virtual Environment..." +if exist %deepStackPath%\venv ( + call :WriteLine Green "Already present" +) else ( + %downloadDir%\%pythonDir%\python.exe -m venv %deepStackPath%\venv + call :WriteLine Green "Done" +) + +call :Write White "Enabling our Virtual Environment..." + +set currentDir=%cd% +cd !deepStackPath! + +set VIRTUAL_ENV=%cd%\venv\Scripts + +cd !currentDir! + +if not defined PROMPT set PROMPT=$P$G +set PROMPT=(venv) !PROMPT! + +set PYTHONHOME= +set PATH=!VIRTUAL_ENV!;%PATH% + +if errorlevel 1 goto errorNoPythonVenv +call :WriteLine Green "Done" + +:: Ensure Python Exists +call :Write White "Checking for Python 3.7..." +python --version | find "3.7" > NUL +if errorlevel 1 goto errorNoPython +call :WriteLine Green "present" + +if "%verbosity%"=="loud" where Python + + +:: =============================================================================================== +:: 3. Install PIP packages + +:: ASSUMPTION: If venv\Lib\site-packages\torch exists then no need to do this + +call :Write White "Checking for required packages..." + +if not exist %deepStackPath%\venv\Lib\site-packages\torch ( + + call :WriteLine Yellow "Installing" + + call :Write White "Installing Python package manager..." + python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip !pipFlags! + call :WriteLine Green "Done" + + REM call :Write White "Installing Packages into Virtual Environment..." + REM pip install -r %deepStackPath%\%intelligenceDir%\requirements.txt !pipFlags! + REM call :WriteLine Green "Success" + + REM We'll do this the long way so we can see some progress + set currentOption= + for /f "tokens=*" %%x in (%deepStackPath%\%intelligenceDir%\requirements.txt) do ( + + set line=%%x + + if "!line!" == "" ( + set currentOption= + ) else if "!line:~0,2!" == "##" ( + set currentOption= + ) else if "!line:~0,12!" == "--find-links" ( + set currentOption=!line! + ) else ( + call :Write White " PIP: Installing !line!..." + REM echo python.exe -m pip install !line! !currentOption! !pipFlags! + python.exe -m pip install !line! !currentOption! !pipFlags! + call :WriteLine Green "Done" + + set currentOption= + ) + ) +) else ( + call :WriteLine Green "present." +) + +:: =============================================================================================== +:: 5. Let's do this! + + +:: a) SET all Env. variables and store in a json file that will be loaded by the .NET API app + +:: For DeepStack +set APPDIR=%deepStackPath%\%intelligenceDir% +set MODELS_DIR=%deepStackPath%\%modelsDir% +set DATA_DIR=%deepStackPath%\%datastoreDir% +set TEMP_PATH=%deepStackPath%\%tempstoreDir% +set VISION_FACE=%enableFaceDetection% +set VISION_DETECTION=%enableObjectDetection% +set VISION_SCENE=%enableSceneDetection% + +:: For CodeProject.SenseAI + +set modulesEnabled=, +if /i "%enableFaceDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_FACE, +if /i "%enableObjectDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_DETECTION, +if /i "%enableSceneDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_SCENE, +set modulesEnabled=!modulesEnabled:~1,-1! + +call :Write White "Saving Environment variables..." + +set CPSENSEAI_ROOTDIR=!absoluteRootDir! +set CPSENSEAI_APPDIR=!srcDir! +set CPSENSEAI_APIDIR=!senseAPIDir! +set CPSENSEAI_MODULES=!modulesEnabled! +set CPSENSEAI_ANALYSISDIR=!analysisLayerDir! +set CPSENSEAI_COMFIG=Debug +set CPSENSEAI_PRODUCTION=False +set CPSENSEAI_BUILDSERVER=True + +call save_environment !absoluteRootDir!\!srcDir!\!envVariablesFile! !absoluteRootDir!\!srcDir!\!settingsFile! +call :WriteLine White "Done." + +:: and we're done. +call :WriteLine Yellow "Development Environment setup complete" +call :WriteLine White "" +call :WriteLine White "" + +goto:eof + + + +:: sub-routines + +:setESC + for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( + set ESC=%%b + exit /B 0 + ) + exit /B 0 + +:setColor + REM echo %ESC%[4m - Underline + REM echo %ESC%[7m - Inverse + + if /i "%2" == "foreground" ( + REM Foreground Colours + if /i "%1" == "Black" set currentColor=!ESC![30m + if /i "%1" == "DarkRed" set currentColor=!ESC![31m + if /i "%1" == "DarkGreen" set currentColor=!ESC![32m + if /i "%1" == "DarkYellow" set currentColor=!ESC![33m + if /i "%1" == "DarkBlue" set currentColor=!ESC![34m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![35m + if /i "%1" == "DarkCyan" set currentColor=!ESC![36m + if /i "%1" == "Gray" set currentColor=!ESC![37m + if /i "%1" == "DarkGray" set currentColor=!ESC![90m + if /i "%1" == "Red" set currentColor=!ESC![91m + if /i "%1" == "Green" set currentColor=!ESC![92m + if /i "%1" == "Yellow" set currentColor=!ESC![93m + if /i "%1" == "Blue" set currentColor=!ESC![94m + if /i "%1" == "Magenta" set currentColor=!ESC![95m + if /i "%1" == "Cyan" set currentColor=!ESC![96m + if /i "%1" == "White" set currentColor=!ESC![97m + ) else ( + REM Background Colours + if /i "%1" == "Black" set currentColor=!ESC![40m + if /i "%1" == "DarkRed" set currentColor=!ESC![41m + if /i "%1" == "DarkGreen" set currentColor=!ESC![42m + if /i "%1" == "DarkYellow" set currentColor=!ESC![43m + if /i "%1" == "DarkBlue" set currentColor=!ESC![44m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![45m + if /i "%1" == "DarkCyan" set currentColor=!ESC![46m + if /i "%1" == "Gray" set currentColor=!ESC![47m + if /i "%1" == "DarkGray" set currentColor=!ESC![100m + if /i "%1" == "Red" set currentColor=!ESC![101m + if /i "%1" == "Green" set currentColor=!ESC![102m + if /i "%1" == "Yellow" set currentColor=!ESC![103m + if /i "%1" == "Blue" set currentColor=!ESC![104m + if /i "%1" == "Magenta" set currentColor=!ESC![105m + if /i "%1" == "Cyan" set currentColor=!ESC![106m + if /i "%1" == "White" set currentColor=!ESC![107m + ) + exit /B 0 + +:WriteLine + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if "%~2" == "" ( + Echo: + exit /b 0 + ) + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 %~2 + call :setColor %1 foreground + echo !currentColor!%~2!resetColor! + ) else ( + Echo %~2 + ) + exit /b 0 + +:Write + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 -NoNewline %~2 + call :setColor %1 foreground + nul 2>nul + pushd !dirToSave! + tar -xf !dirToSave!.zip > nul 2>nul + if "%errorlevel%" == "9009" set tarExists=false + rm !dirToSave!.zip > nul 2>nul + popd + popd + + if "!tarExists!" == "false" ( + powershell Expand-Archive -Path !downloadToDir!!dirToSave!.zip ^ + -DestinationPath !downloadToDir! -Force + ) + + del /s /f /q !downloadToDir!!dirToSave!.zip > nul + + call :WriteLine Green "Done." + + exit /b + +:: Jump points + +:errorNoPython +call :WriteLine White "" +call :WriteLine White "" +call :WriteLine White "---------------------------------------------------------------------------" +call :WriteLine Red "Error: Python not installed" +call :WriteLine Red "Go to https://www.python.org/downloads/release/python-3712/ for Python 3.7" +goto:eof + +:errorNoPythonVenv +call :WriteLine White "" +call :WriteLine White "" +call :WriteLine White "---------------------------------------------------------------------------" +call :WriteLine Red "Error: Python Virtual Environment activation failed" +call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version" +goto:eof \ No newline at end of file diff --git a/install/windows_install.bat b/install/windows_install.bat deleted file mode 100644 index ae7293ff..00000000 --- a/install/windows_install.bat +++ /dev/null @@ -1,449 +0,0 @@ -:: CodeProject SenseAI Server install script -:: We assume we're in the source code /install directory. - -:: syntax is: windows_install install_dir startupServer -:: -:: eg to install in c:\setup and not start the server after installation: -:: windows_install c:\setup false -:: -:: leave startupServer empty, or both empty, for defaults - -@echo off -cls -setlocal enabledelayedexpansion - -:: Enable the modules -set enableFaceDetection=true -set enableObjectDetection=true -set enableSceneDetection=true - -:: verbosity can be: quiet | info | loud -set verbosity=quiet - -:: If files are already present, then don't overwrite if this is false -set forceOverwrite=false - -:: Whether to attempt to open the inbound port for the server (requires admin mode) -set attemptOpenPort=false - -:: Whether to install python packages via PIP -set installPythonPackages=true - -:: Whether to start the server on completion -set startupServer=true - - -:: Basic locations - -REM The name of the CodeProject Sense App -set appName=CodeProject.SenseAI - -REM The name of the CodeProject Sense App Executable file -set appExe=CodeProject.SenseAI.Server.exe - -:: The name of the startup settings file -set settingsFile=CodeProject.SenseAI.config - -:: The name of the Environment variable setup file -set envVariablesFile=set_environment.bat - -REM The port to expose for the front end service -set port=5000 - -REM The full path to the directory holding the main app and it's sub-dirs -set senseAppDir=C:\CodeProject.SenseAI - -REM The name of the dir holding the backend analysis services -set backendName=AnalysisLayer - -REM The name of the dir holding the DeepStack analysis services -set deepstackModule=DeepStack - -REM The name of the dir holding the frontend API server -set frontendName=API - -REM The location of large packages that need to be downloaded -set storageUrl=https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/ - -REM The name of the dir, within the current directory, where install assets will be downloaded to -set downloadName=downloads - -REM The name of the dir containing the AI models themselves -set modelsDirName=assets - -REM The name of the dir containing persisted data -set storeName=datastore - -REM The name of the dir containing temporary data -set tempName=tempstore - -REM Handle parameter overrides -if not "%1" == "" set senseAppDir=%1 -if not "%2" == "" set startupServer=%2 - - -:: ------------------------------------------------------------- -:: Set Flags - -set pipFlags=-q -q -set rmdirFlags=/q -set roboCopyFlags=/NFL /NDL /NJH /NJS /nc /ns >nul 2>nul -set dotnetFlags=q -set activateFlags= - -if "%verbosity%"=="info" set pipFlags=-q -if "%verbosity%"=="info" set rmdirFlags=/q -if "%verbosity%"=="info" set roboCopyFlags=/NFL /NDL /NJH -if "%verbosity%"=="info" set dotnetFlags=m -if "%verbosity%"=="info" set activateFlags= - -if "%verbosity%"=="loud" set pipFlags= -if "%verbosity%"=="loud" set rmdirFlags= -if "%verbosity%"=="loud" set roboCopyFlags= -if "%verbosity%"=="loud" set dotnetFlags=n -if "%verbosity%"=="loud" set activateFlags=-Verbose - - -REM Robocopy: -REM /NFL : No File List - don't log file names. -REM /NDL : No Directory List - don't log directory names. -REM /NJH : No Job Header. -REM /NJS : No Job Summary. -REM /NP : No Progress - don't display percentage copied. -REM /NS : No Size - don't log file sizes. -REM /NC : No Class - don't log file classes. - - -:: =============================================================================================== -:: 1. Ensure directories are created and download required assets - -:: Create some directories -call :Write White "Creating Directories..." - -if not exist %downloadName%\ mkdir %downloadName% - -if not exist %senseAppDir% mkdir %senseAppDir% -if not exist %senseAppDir%\%frontendName%\ mkdir %senseAppDir%\%frontendName% - -set backendDir=%senseAppDir%\%backendName% -if not exist %backendDir% mkdir %backendDir% -if not exist %backendDir%\%deepstackModule% mkdir %backendDir%\%deepstackModule% -if not exist %backendDir%\%deepstackModule%\%tempName%\ mkdir %backendDir%\%deepstackModule%\%tempName% -if not exist %backendDir%\%deepstackModule%\%storeName%\ mkdir %backendDir%\%deepstackModule%\%storeName% - -call :WriteLine Green "Done" - - -call :WriteLine White "Downloading utilities and models: Starting." - -REM Clean up directories to force a re-download if necessary -if /i "%forceOverwrite%" == "true" ( - if exist %downloadName%\%modelsDirName% rmdir /s %rmdirFlags% %downloadName%\%modelsDirName% - if exist %downloadName%\python37 rmdir /s %rmdirFlags% %downloadName%\python37 - - if exist %backendDir%\%deepstackModule%\%modelsDirName% rmdir /s %rmdirFlags% %backendDir%\%deepstackModule%\%modelsDirName% - if exist %backendDir%\python37 rmdir /s %rmdirFlags% %backendDir%\python37 -) - -REM Download whatever packages are missing -if not exist %downloadName%\%modelsDirName% ( - if /i "%verbosity%" == "quiet" call :Write White "Downloading models..." - PowerShell -NoProfile -ExecutionPolicy Bypass -Command ".\scripts\download.ps1 %storageUrl% %downloadName%/ models.zip %modelsDirName%" - if /i "%verbosity%" == "quiet" call :WriteLine Green "Done" -) -if not exist %downloadName%\python37 ( - if /i "%verbosity%" == "quiet" call :Write White "Downloading Python interpreter..." - PowerShell -NoProfile -ExecutionPolicy Bypass -Command ".\scripts\download.ps1 %storageUrl% %downloadName%/ python37.zip python37" - if /i "%verbosity%" == "quiet" call :WriteLine Green "Done" -) - -REM Move downloads to the installation backend -call :Write White "Moving assets to installation folder..." -if exist %downloadName%\%modelsDirName% robocopy /e %downloadName%\%modelsDirName% %backendDir%\%deepstackModule%\%modelsDirName% !roboCopyFlags! > NUL -if exist %downloadName%\python37 robocopy /e %downloadName%\python37 %backendDir%\ !roboCopyFlags! > NUL -call :WriteLine Green "Done" - -call :WriteLine White "Downloading utilities and models: Completed" - -:: =============================================================================================== -:: 2. Create & Activate Virtual Environment - -call :Write White "Creating Virtual Environment..." -%backendDir%\python37\python.exe -m venv %backendDir%\venv -call :WriteLine Green "Done" - -call :Write White "Enabling our Virtual Environment..." - -set VIRTUAL_ENV=%backendDir%\venv\Scripts - -if not defined PROMPT set PROMPT=$P$G -set PROMPT=(venv) !PROMPT! - -set PYTHONHOME= -set PATH=!VIRTUAL_ENV!;%PATH% - -if errorlevel 1 goto errorNoPythonVenv -call :WriteLine Green "Done" - -:: Ensure Python Exists -call :Write White "Checking for Python 3.7..." -python --version | find "3.7" > NUL -if errorlevel 1 goto errorNoPython -call :WriteLine Green "present" - -if "%verbosity%"=="loud" where Python - - -:: =============================================================================================== -:: 3. Copy over the AI engine itself and install PIP packages - -call :Write White "Copying over backend Python Intelligence layer..." -robocopy /e ..\src\AnalysisLayer\DeepStack\intelligencelayer %backendDir%\%deepstackModule% !roboCopyFlags! > NUL -call :WriteLine Green "Done" - -if /i "%installPythonPackages%" == "true" ( - - call :Write White "Installing Python package manager..." - python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip !pipFlags! - call :WriteLine Green "Done" - - REM call :Write White "Installing Packages into Virtual Environment..." - REM pip install -r %backendDir%\%deepstackModule%\requirements.txt !pipFlags! - REM call :WriteLine Green "Success" - - REM We'll do this the long way so we can see some progress - set currentOption= - for /f "tokens=*" %%x in (%backendDir%\%deepstackModule%\requirements.txt) do ( - - set line=%%x - - if "!line!" == "" ( - set currentOption= - ) else if "!line:~0,2!" == "##" ( - set currentOption= - ) else if "!line:~0,12!" == "--find-links" ( - set currentOption=!line! - ) else ( - call :Write White " PIP: Installing !line!..." - REM echo python.exe -m pip install !line! !currentOption! !pipFlags! - python.exe -m pip install !line! !currentOption! !pipFlags! - call :WriteLine Green "Done" - - set currentOption= - ) - ) -) - - -:: =============================================================================================== -:: 4. Build and copy over front end API server - -call :WriteLine White "Preparing front end API server" - -:: Copy over the startup script -copy /Y "windows_start.bat" "%senseAppDir%" >nul 2>nul - -:: Build the server executable and copy over -cd ..\src\API\Server\FrontEnd\ - -dotnet build --configuration Release --nologo --verbosity !dotnetFlags! -:: dotnet build --configuration Release --nologo --verbosity !dotnetFlags! --self-contained true - .NET 6 - - -robocopy /e bin/Release/net5.0 %senseAppDir%\%frontendName% !roboCopyFlags! - -if /i "%attemptOpenPort%" == "true" ( - call :Write White "Opening port..." - - netstat /o /a /n | find /i "listening" | find ":%port%" >nul 2>nul && ( - call :WriteLine Green "Port %port% is open for listening" - ) || ( - - set RULE_NAME="Open Port %port% for %appName%" - netsh advfirewall firewall show rule name=%RULE_NAME% >nul - if not ERRORLEVEL 1 ( - call :WriteLine Green "Success" - ) else ( - call :WriteLine Gray "Retrying..." - netsh advfirewall firewall add rule name=%RULE_NAME% dir=in action=allow protocol=TCP localport=%port% - if not ERRORLEVEL 1 call :WriteLine Green "Success" - ) - ) -) - -:: =============================================================================================== -:: 5. Let's do this! - - -:: a) SET all Env. variables and store in a json file that will be loaded by the .NET API app - -cd %senseAppDir%\%frontendName% - -:: For DeepStack -set APPDIR=%backendDir%\%deepstackModule% -set MODELS_DIR=%backendDir%\%deepstackModule%\%modelsDirName% -set DATA_DIR=%backendDir%\%deepstackModule%\%storeName% -set TEMP_PATH=%backendDir%\%deepstackModule%\%tempName% -set PROFILE=windows_native -set CUDA_MODE=False - -set modulesEnabled=, -if /i "%enableFaceDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_FACE, -if /i "%enableObjectDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_DETECTION, -if /i "%enableSceneDetection%" == "true" set modulesEnabled=!modulesEnabled!VISION_SCENE, -set modulesEnabled=!modulesEnabled:~1,-1! - -( -echo { -:: SenseAI Application values -echo "CPSENSEAI_APPDIR" : "!senseAppDir!", -echo "CPSENSEAI_PORT" : "!port!", -echo "CPSENSEAI_PROFILE" : "!PROFILE!", -echo "CPSENSEAI_FRONTEND" : "!frontendName!", -echo "CPSENSEAI_BACKEND" : "!backendName!", -echo "CPSENSEAI_MODULES" : "!modulesEnabled:,=;!", - -:: DeepStack compatible values -echo "APPDIR" : "!APPDIR!", -echo "PROFILE" : "!PROFILE!", -echo "CUDA_MODE" : "!CUDA_MODE!", -echo "DATA_DIR" : "!DATA_DIR!", -echo "TEMP_PATH" : "!TEMP_PATH!", -echo "MODELS_DIR" : "!MODELS_DIR!", -echo "PORT" : "!PORT!", -echo "VISION_FACE" : "!enableFaceDetection!", -echo "VISION_DETECTION" : "!enableObjectDetection!", -echo "VISION_SCENE" : "!enableSceneDetection!" -echo } -) > %senseAppDir%\%settingsFile% - -:: Also create a .BAT file for easy Starting - -( -:: SenseAI Application values -echo set CPSENSEAI_APPDIR=!senseAppDir! -echo set CPSENSEAI_PORT=!port! -echo set CPSENSEAI_PROFILE=!PROFILE! -echo set CPSENSEAI_FRONTEND=!frontendName! -echo set CPSENSEAI_BACKEND=!backendName! -echo set CPSENSEAI_MODULES=!modulesEnabled:,=;! - -:: DeepStack compatible values -echo set APPDIR=!APPDIR! -echo set PROFILE=!PROFILE! -echo set CUDA_MODE=!CUDA_MODE! -echo set DATA_DIR=!DATA_DIR! -echo set TEMP_PATH=!TEMP_PATH! -echo set MODELS_DIR=!MODELS_DIR! -echo set PORT=!PORT! -echo set VISION_FACE=!enableFaceDetection! -echo set VISION_DETECTION=!enableObjectDetection! -echo set VISION_SCENE=!enableSceneDetection! -) > %senseAppDir%\%envVariablesFile% - - -:: -- interlude -- -:: If we don't need to go any futher, let's blow this popsicle stand -if /i not "%startupServer%" == "true" goto eof -:: -- interlude -- - - -:: b) Load Installation settings - -call :Write White "Loading installation settings..." - -:: Load Json string from settings file -for /f "tokens=*" %%x in (%senseAppDir%\%settingsFile%) do ( - set line=%%x - - REM Remove brackets, commas and quotes - set line=!line:}=! - set line=!line:{=! - set line=!line:,=! - set line=!line:"=! - REM Convert ": " to "=". BE CAREFUL of drive letters: Order of operations matters - set line=!line:: ==! - REM Now remove the spaces - set line=!line: =! - - if "%verbosity%" == "loud" echo Config File line: !line! - - if not "!line!" == "" Set !line! -) - -call :WriteLine Green "Done" - - -:: c) Start the backend analysis processes - -call :Write White "Starting Analysis Services..." - -if /i "%enableObjectDetection%" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python %backendDir%\%deepstackModule%\detection.py -) -if /i "%enableFaceDetection%" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python %backendDir%\%deepstackModule%\face.py -) -if /i "%enableSceneDetection%" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python %backendDir%\%deepstackModule%\scene.py -) -:: To start them all in one fell swoop... -:: START "CodeProject SenseAI Analysis Services" /B python %backendDir%\%deepstackModule%\runAll.py -call :WriteLine Green "Done" - - -:: d) Startup the API server - -call :Write White "Starting API server..." - -set featureFlags= -if /i "%enableFaceDetection%" == "true" set featureFlags=!featureFlags! --VISION_FACE true -if /i "%enableObjectDetection%" == "true" set featureFlags=!featureFlags! --VISION-DETECTION true -if /i "%enableSceneDetection%" == "true" set featureFlags=!featureFlags! --VISION-SCENE true - -%appExe% !featureFlags! --urls http://*:%port% - -call :WriteLine Green "Done" - - -:: and we're done. -goto eof - - -:: sub-routines - -:Trim -SetLocal EnableDelayedExpansion -set Params=%* -for /f "tokens=1*" %%a in ("!Params!") do EndLocal & set %1=%%b -exit /b - -:WriteLine -SetLocal EnableDelayedExpansion -powershell write-host -foregroundcolor %1 %~2 -exit /b - -:Write -SetLocal EnableDelayedExpansion -powershell write-host -foregroundcolor %1 -NoNewline %~2 -exit /b - -:: Jump points - -:errorNoPython -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python not installed" -call :WriteLine Red "Go to https://www.python.org/downloads/release/python-3712/ for Python 3.7" -goto:eof - -:errorNoPythonVenv -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python Virtual Environment activation failed" -call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version" -goto:eof - -:eof \ No newline at end of file diff --git a/install/windows_start.bat b/install/windows_start.bat deleted file mode 100644 index 67b68fa7..00000000 --- a/install/windows_start.bat +++ /dev/null @@ -1,175 +0,0 @@ -:: CodeProject SenseAI Server startup script -:: We assume we're in the CodeProject SenseAI installed directory. - -@echo off -cls -SETLOCAL EnableDelayedExpansion - -:: Basic Settings - -:: The name of the CodeProject Sense App -set appName=CodeProject.SenseAI - -:: The name of the CodeProject Sense App Executable file -set appExe=CodeProject.SenseAI.Server.exe - -:: The name of the startup settings file -set settingsFile=CodeProject.SenseAI.config - -:: The name of the Environment variable setup file -set envVariablesFile=set_environment.bat - -:: Whether to attempt to open the inbound port for the server (requires admin mode) -set attemptOpenPort=false - -:: verbosity can be: quiet | info | loud -set verbosity=quiet - -:: =============================================================================================== -:: 2. Load Installation settings - -call :Write White "Loading installation settings..." - -:: Easy way is to just run %envVariablesFile%, but that won't provide any summary - -if not exist %settingsFile% goto noSettingsFile - -:: Load Json string from settings file -for /f "tokens=*" %%x in (%settingsFile%) do ( - set line=%%x - - REM Remove brackets, commas and quotes - set line=!line:}=! - set line=!line:{=! - set line=!line:,=! - set line=!line:"=! - REM Convert ": " to "=". BE CAREFUL of drive letters: Order of operations matters - set line=!line:: ==! - REM Now remove the spaces - set line=!line: =! - - if "%verbosity%" == "loud" echo Config File line: !line! - - if not "!line!" == "" Set !line! -) - -call :WriteLine Green "Done" - -:: =============================================================================================== -:: 2. Activate Virtual Environment - -call :Write White "Enable our Virtual Environment..." - -set VIRTUAL_ENV=!APPDIR!\..\venv\Scripts - -if not defined PROMPT set PROMPT=$P$G -set PROMPT=(venv) !PROMPT! - -set PYTHONHOME= -set PATH=!VIRTUAL_ENV!;%PATH% - -if errorlevel 1 goto errorNoPythonVenv -call :WriteLine Green "Done" - -:: Ensure Python Exists -call :Write White "Checking for Python 3.7..." -python --version | find "3.7" > NUL -if errorlevel 1 goto errorNoPython -call :WriteLine Green "present" - -if "%verbosity%"=="loud" where Python - -:: =============================================================================================== -:: 3. Open port if needed - -if "%attemptOpenPort%" == "true" ( - call :Write White "Opening port..." - - netstat /o /a /n | find /i "listening" | find ":%CPSENSEAI_PORT%" >nul 2>nul && ( - call :WriteLine Green "Port %CPSENSEAI_PORT% is open for listening" - ) || ( - - set RULE_NAME="Open Port %CPSENSEAI_PORT% for %appName%" - netsh advfirewall firewall show rule name=%RULE_NAME% >nul - if not ERRORLEVEL 1 ( - call :WriteLine Green "Success" - ) else ( - call :WriteLine Gray "Retrying..." - netsh advfirewall firewall add rule name=%RULE_NAME% dir=in action=allow protocol=TCP localport=%CPSENSEAI_PORT% - if not ERRORLEVEL 1 call :WriteLine Green "Success" - ) - ) -) - -:: =============================================================================================== -:: 3. Start front end server - -call :Write White "Starting Analysis Services..." -if /i "!VISION_DETECTION!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\detection.py -) -if /i "!VISION_FACE!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\face.py -) -if /i "!VISION_SCENE!" == "true" ( - START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\scene.py -) -:: To start them all in one fell swoop... -:: START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\runAll.py -call :WriteLine Green "Done" - -:: b. Startup the API server -set featureFlags= -if /i "!VISION_FACE!" == "true" set featureFlags=!featureFlags! --VISION_FACE true -if /i "!VISION_DETECTION!" == "true" set featureFlags=!featureFlags! --VISION-DETECTION true -if /i "!VISION_SCENE!" == "true" set featureFlags=!featureFlags! --VISION-SCENE true - -cd %CPSENSEAI_APPDIR%\%CPSENSEAI_FRONTEND% -%appExe% !featureFlags! --urls http://*:%port% - - -:: and we're done. -goto eof - - -:: sub-routines - -:WriteLine -SetLocal EnableDelayedExpansion -powershell write-host -foregroundcolor %1 %~2 -:: powershell write-host -foregroundcolor White -NoNewline -exit /b - -:Write -SetLocal EnableDelayedExpansion -powershell write-host -foregroundcolor %1 -NoNewline %~2 -:: powershell write-host -foregroundcolor White -NoNewline -exit /b - -:: Jump ooints - -:errorNoSettingsFile -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: %appName% settings file not found" -goto:eof - - -:errorNoPython -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python not installed" -call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version of Python" -goto:eof - -:errorNoPythonVenv -call :WriteLine White "" -call :WriteLine White "" -call :WriteLine White "---------------------------------------------------------------------------" -call :WriteLine Red "Error: Python Virtual Environment activation failed" -call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version" -goto:eof - -:eof \ No newline at end of file diff --git a/src/API/Server/FrontEnd/Dockerfile b/src/API/Server/FrontEnd/Dockerfile deleted file mode 100644 index 1ea96964..00000000 --- a/src/API/Server/FrontEnd/Dockerfile +++ /dev/null @@ -1,24 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build -WORKDIR /src -COPY ["src/API/CodeProject.AI.FrontEnd/CodeProject.AI.FrontEnd.csproj", "src/API/CodeProject.AI.FrontEnd/"] -COPY ["src/API/CodeProject.AI.Backend/CodeProject.AI.Backend.csproj", "src/API/CodeProject.AI.Backend/"] -COPY ["src/API/CodeProject.Ai.Common/CodeProject.Ai.Common.csproj", "src/API/CodeProject.Ai.Common/"] -RUN dotnet restore "src/API/CodeProject.AI.FrontEnd/CodeProject.AI.FrontEnd.csproj" -COPY . . -WORKDIR "/src/src/API/CodeProject.AI.FrontEnd" -RUN dotnet build "CodeProject.AI.FrontEnd.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "CodeProject.AI.FrontEnd.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "CodeProject.AI.FrontEnd.dll"] \ No newline at end of file diff --git a/src/API/Server/FrontEnd/Dockerfilexxx b/src/API/Server/FrontEnd/Dockerfilexxx deleted file mode 100644 index bb27dfef..00000000 --- a/src/API/Server/FrontEnd/Dockerfilexxx +++ /dev/null @@ -1,22 +0,0 @@ -#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. - -FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base -WORKDIR /app -EXPOSE 80 -EXPOSE 443 - -FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build -WORKDIR /src -COPY ["CodeProject.AI.DeepStack.FrontEnd/CodeProject.AI.DeepStack.FrontEnd.csproj", "CodeProject.AI.DeepStack.FrontEnd/"] -RUN dotnet restore "CodeProject.AI.DeepStack.FrontEnd/CodeProject.AI.DeepStack.FrontEnd.csproj" -COPY . . -WORKDIR "/src/CodeProject.AI.DeepStack.FrontEnd" -RUN dotnet build "CodeProject.AI.DeepStack.FrontEnd.csproj" -c Release -o /app/build - -FROM build AS publish -RUN dotnet publish "CodeProject.AI.DeepStack.FrontEnd.csproj" -c Release -o /app/publish - -FROM base AS final -WORKDIR /app -COPY --from=publish /app/publish . -ENTRYPOINT ["dotnet", "CodeProject.AI.DeepStack.FrontEnd.dll"] \ No newline at end of file diff --git a/src/API/Server/FrontEnd/appsettings.Development.json b/src/API/Server/FrontEnd/appsettings.Development.json index c9be8e82..9fefc7dd 100644 --- a/src/API/Server/FrontEnd/appsettings.Development.json +++ b/src/API/Server/FrontEnd/appsettings.Development.json @@ -1,9 +1,9 @@ { "Logging": { "LogLevel": { - "Default": "Warning", - "Microsoft.AspNetCore": "Information", - "Microsoft.Hosting.Lifetime": "Warning" + "Default": "Warning", + "Microsoft.AspNetCore": "Information", + "Microsoft.Hosting.Lifetime": "Information" } } } diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5n.onnx b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5n.onnx similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5n.onnx rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5n.onnx diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5n6.onnx b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5n6.onnx similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5n6.onnx rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5n6.onnx diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5s.onnx b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5s.onnx similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/Weights/yolov5s.onnx rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/Weights/yolov5s.onnx diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/test.jpg b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/test.jpg similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Assets/test.jpg rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Assets/test.jpg diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/CodeProject.SenseAI.Analysis.Yolo.csproj b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/CodeProject.SenseAI.Analysis.Yolo.csproj similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/CodeProject.SenseAI.Analysis.Yolo.csproj rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/CodeProject.SenseAI.Analysis.Yolo.csproj diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/ObjectDetector.cs b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/ObjectDetector.cs similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/ObjectDetector.cs rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/ObjectDetector.cs diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Program.cs b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Program.cs similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Program.cs rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Program.cs diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Properties/launchSettings.json b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Properties/launchSettings.json similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/Properties/launchSettings.json rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/Properties/launchSettings.json diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/YoloProcessor.cs b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/YoloProcessor.cs similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/YoloProcessor.cs rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/YoloProcessor.cs diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/appsettings.Development.json b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/appsettings.Development.json similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/appsettings.Development.json rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/appsettings.Development.json diff --git a/src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/appsettings.json b/src/AnalysisLayer/CodeProject.AI.Backend.Yolo/appsettings.json similarity index 100% rename from src/AnalysisLayer/CodeProject.SenseAI.Backend.Yolo/appsettings.json rename to src/AnalysisLayer/CodeProject.AI.Backend.Yolo/appsettings.json diff --git a/src/AnalysisLayer/DeepStack/data/faceembedding.db b/src/AnalysisLayer/DeepStack/data/faceembedding.db deleted file mode 100644 index 2750f2be..00000000 Binary files a/src/AnalysisLayer/DeepStack/data/faceembedding.db and /dev/null differ diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/DeepStack.pyproj b/src/AnalysisLayer/DeepStack/intelligencelayer/DeepStack.pyproj index ad8561cb..3fc1b6aa 100644 --- a/src/AnalysisLayer/DeepStack/intelligencelayer/DeepStack.pyproj +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/DeepStack.pyproj @@ -20,7 +20,9 @@ 10.0 + + @@ -39,8 +41,6 @@ - - @@ -54,7 +54,6 @@ - diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/face.py b/src/AnalysisLayer/DeepStack/intelligencelayer/face.py index 8a74a26d..74dfd00e 100644 --- a/src/AnalysisLayer/DeepStack/intelligencelayer/face.py +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/face.py @@ -23,7 +23,6 @@ from PIL import Image, UnidentifiedImageError from process import YOLODetector from recognition import FaceRecognitionModel -# from redis import RedisError, StrictRedis import traceback databaseFilePath = os.path.join(SharedOptions.DATA_DIR,"faceembedding.db") @@ -70,18 +69,6 @@ def load_faces(): master_face_map["tensors"] = embedding_arr facemap = repr(master_face_map) - # Store map in Redis - # SharedOptions.db.set("facemap", facemap) - - # ...or Store map in SQLite - # cursor.execute("DELETE FROM TB_FACEMAP") - # ADD_MAP = "INSERT INTO TB_FACEMAP(map) VALUES(?)" - # map_rep = json.dumps(facemap) - # cursor.execute(ADD_MAP, (map_rep,)) - # conn.commit() - # conn.close() - - def face(thread_name, delay): if SharedOptions.MODE == "High": @@ -369,19 +356,6 @@ def face(thread_name, delay): try: - # Get map from redis - # stored_master_face_map = SharedOptions.db.get("facemap") - # master_face_map = ast.literal_eval(stored_master_face_map) - - # ... Or get map from SQLite - # conn = sqlite3.connect(SharedOptions.DATA_DIR + "/faceembedding.db") - # cursor = conn.cursor() - # SELECT_MAP = "SELECT top 1 * FROM TB_FACEMAP" - # maps = cursor.execute(SELECT_MAP) - # map_rep = maps[0] - # master_face_map = json.loads(map_rep) - - facemap = master_face_map ["map"] face_array = master_face_map ["tensors"] diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/noop.bat b/src/AnalysisLayer/DeepStack/intelligencelayer/noop.bat new file mode 100644 index 00000000..a69fe356 --- /dev/null +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/noop.bat @@ -0,0 +1 @@ +:: Empty NOOP script, used so launch.json has something to chew on when launching a background task. \ No newline at end of file diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/requirements.txt b/src/AnalysisLayer/DeepStack/intelligencelayer/requirements.txt index 9cf925e0..f09bbc38 100644 --- a/src/AnalysisLayer/DeepStack/intelligencelayer/requirements.txt +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/requirements.txt @@ -1,13 +1,13 @@ ONNXRuntime -Redis -OpenCV-Python -Cython +## OpenCV-Python +## Cython Pillow SciPy -TDQM -Tensorboard +## TDQM +## Tensorboard PyYAML -Matplotlib +## wMatplotlib +requests ## these were missing in models/*.py but aren't used everywhere. THOP @@ -18,7 +18,7 @@ CoreMLTools ## These were missing, but we might need directml versions --find-links https://download.pytorch.org/whl/torch_stable.html -Torch==1.6.0 +Torch==1.6.0+cpu --find-links https://download.pytorch.org/whl/torch_stable.html -TorchVision==v0.7.0 +TorchVision==v0.7.0+cpu diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/shared.py b/src/AnalysisLayer/DeepStack/intelligencelayer/shared.py index 4360da7d..9a039b56 100644 --- a/src/AnalysisLayer/DeepStack/intelligencelayer/shared.py +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/shared.py @@ -38,16 +38,14 @@ def __init__( class SharedOptions: - APPDIR = getEnvVariable("APPDIR", "C:\\CodeProject.SenseAI\\AnalysisLayer\\DeepStack") + APPDIR = getEnvVariable("APPDIR", os.path.join(os.getcwd(), "..")) PROFILE = getEnvVariable("PROFILE", "desktop_cpu") if PROFILE == "windows_native": sys.path.append(os.path.join(APPDIR,"python_packages")) - # from redis import RedisError, StrictRedis - CUDA_MODE = getEnvVariable("CUDA_MODE", "False") TEMP_PATH = getEnvVariable("TEMP_PATH", "") - DATA_DIR = getEnvVariable("DATA_DIR", "/datastore") + DATA_DIR = getEnvVariable("DATA_DIR", f"{APPDIR}\datastore") MODELS_DIR = getEnvVariable("MODELS_DIR", "assets") PORT = getEnvVariable("PORT", "5000") @@ -58,10 +56,6 @@ class SharedOptions: GPU_APP_DIR = os.path.join(APPDIR, "gpufiles") CPU_APP_DIR = os.path.join(APPDIR, "cpufiles") - # print("APPDIR: " + APPDIR) - # print("DATA_DIR: " + DATA_DIR) - # print("TEMP_PATH: " + DATA_DIR) - if CUDA_MODE == "True": APP_DIR = GPU_APP_DIR CUDA_MODE = True @@ -75,10 +69,6 @@ class SharedOptions: MODE = os.environ["MODE"] BaseUrl = f"http://localhost:{PORT}/v1/queue/" - # This will be going - # db = StrictRedis(host="localhost", db=0, decode_responses=True) - - # TB_EMBEDDINGS = "TB_EMBEDDINGS" PROFILE_SETTINGS = { "desktop_cpu": Settings( diff --git a/src/AnalysisLayer/DeepStack/intelligencelayer/start.bat b/src/AnalysisLayer/DeepStack/intelligencelayer/start.bat index 4bbfdb16..5f71bd4f 100644 --- a/src/AnalysisLayer/DeepStack/intelligencelayer/start.bat +++ b/src/AnalysisLayer/DeepStack/intelligencelayer/start.bat @@ -1,101 +1,59 @@ -:: CodeProject SenseAI Server startup script -:: We assume we're in the CodeProject SenseAI installed directory. +:: CodeProject SenseAI Analysis services (DeepStack module) startup script for Windows +:: +:: Usage: +:: start.bat +:: +:: We assume we're in the AnalysisLayer/DeepStack directory @echo off cls SETLOCAL EnableDelayedExpansion +set techniColor=true +set envVariablesFile=..\..\..\set_environment.bat + :: Before we start, set the current directory if necessary -if "%1" == "--no-color" set NO_COLOR=true +if "%1" == "--no-color" set techniColor=false if not "%2" == "" cd %2 - :: =============================================================================================== :: 0. Basic settings :: verbosity can be: quiet | info | loud set verbosity=quiet -REM The location of large packages that need to be downloaded -set storageUrl=https://codeproject-ai.s3.ca-central-1.amazonaws.com/sense/installer/ - - -:: =============================================================================================== -:: 1. Set environment variables - -set APPDIR=.\ -set PORT=5000 -set PROFILE=windows_native -set CUDA_MODE=False -set DATA_DIR=..\data -set TEMP_PATH=..\temp - -set VENV_PATH=venv -set INSTALL_DIR=..\..\..\..\install -set DOWNLOADS_PATH=%INSTALL_DIR%\downloads -set MODELS_DIRNAME=assets -set MODELS_DIR=%DOWNLOADS_PATH%\%MODELS_DIRNAME% - -set VISION_FACE=True -set VISION_DETECTION=True -set VISION_SCENE=True - -if "%verbosity%" == "info" ( - echo APPDIR = "!APPDIR!" - echo PROFILE = "!PROFILE!" - echo CUDA_MODE = "!CUDA_MODE!" - echo DATA_DIR = "!DATA_DIR!" - echo TEMP_PATH = "!TEMP_PATH!" - echo PORT = "!PORT!" - echo VISION_FACE = "!VISION_FACE!" - echo VISION_DETECTION = "!VISION_DETECTION!" - echo VISION_SCENE = "!VISION_SCENE!" -) +if not "%verbosity%" == "quiet" call :WriteLine Yellow "Current Directory: %cd%" +if /i "%techniColor%" == "true" call :setESC :: =============================================================================================== -:: 1. Ensure directories are created and download required assets - -if not "%verbosity%" == "quiet" echo Current Directory: %cd% +:: 1. Load environment variables -:: Create some directories -call :Write White "Creating Directories..." -if not exist %DOWNLOADS_PATH% mkdir %DOWNLOADS_PATH% -if not exist %DATA_DIR% mkdir %DATA_DIR% -if not exist %TEMP_PATH% mkdir %TEMP_PATH% +call :Write White "Loading installation settings..." +call !envVariablesFile! call :WriteLine Green "Done" -:: Download, unzip, and move into place the Utilities and known Python version -call :WriteLine White "Download utilities and models..." +set VENV_PATH=!APPDIR!\..\venv -REM Download whatever packages are missing -if not exist %DOWNLOADS_PATH%\%MODELS_DIRNAME% ( - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "%INSTALL_DIR%\scripts\download.ps1 %storageUrl% %DOWNLOADS_PATH%\ models.zip %MODELS_DIRNAME%" - if /i "%verbosity%" == "quiet" call :Write White "Downloading models Done" -) -if not exist %DOWNLOADS_PATH%\python37 ( - PowerShell -NoProfile -ExecutionPolicy Bypass -Command "%INSTALL_DIR%\scripts\download.ps1 %storageUrl% %DOWNLOADS_PATH%\ python37.zip python37" - if /i "%verbosity%" == "quiet" call :Write White "Downloading Python interpreter Done" +if "%verbosity%" == "info" ( + call :WriteLine Yellow "APPDIR = !APPDIR!" + call :WriteLine Yellow "PROFILE = !PROFILE!" + call :WriteLine Yellow "CUDA_MODE = !CUDA_MODE!" + call :WriteLine Yellow "DATA_DIR = !DATA_DIR!" + call :WriteLine Yellow "TEMP_PATH = !TEMP_PATH!" + call :WriteLine Yellow "PORT = !PORT!" + call :WriteLine Yellow "VISION_FACE = !VISION_FACE!" + call :WriteLine Yellow "VISION_DETECTION = !VISION_DETECTION!" + call :WriteLine Yellow "VISION_SCENE = !VISION_SCENE!" ) - :: =============================================================================================== -:: 2. Create & Activate Virtual Environment from scratch (instead of the above download/unpack/copy) - -if not exist %VENV_PATH% ( - call :Write White "Creating Virtual Environment..." - %DOWNLOADS_PATH%\python37\python37\python.exe -m venv %VENV_PATH% - call :WriteLine Green "Done" -) else ( - call :WriteLine Gray "Virtual Environment exists" -) +:: 2. Activate Virtual Environment call :Write White "Enabling our Virtual Environment..." set VIRTUAL_ENV=!VENV_PATH!\Scripts - if not defined PROMPT set PROMPT=$P$G set PROMPT=(venv) !PROMPT! - set PYTHONHOME= set PATH=!VIRTUAL_ENV!;%PATH% @@ -111,55 +69,6 @@ call :WriteLine Green "present" if "%verbosity%"=="loud" where Python -:: =============================================================================================== -:: 3. Install PIP packages - -:: ASSUMPTION: If venv/Lib/site-packages/pip exists then no need to do this - -call :Write White "Checking for required packages..." - -if not exist %VENV_PATH%\Lib\site-packages\pip ( - - call :WriteLine Yellow "Installing" - - :: Set Flags - set pipFlags=-q -q - if "%verbosity%"=="info" set pipFlags=-q - if "%verbosity%"=="loud" set pipFlags= - - call :Write White "Installing Python package manager..." - python -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org --upgrade pip !pipFlags! - call :WriteLine Green "Done" - - REM call :Write White "Installing Packages into Virtual Environment..." - REM pip install -r %backendDir%\%deepstackModule%\requirements.txt !pipFlags! - REM call :WriteLine Green "Success" - - REM We'll do this the long way so we can see some progress - set currentOption= - for /f "tokens=*" %%x in (requirements.txt) do ( - - set line=%%x - - if "!line!" == "" ( - set currentOption= - ) else if "!line:~0,2!" == "##" ( - set currentOption= - ) else if "!line:~0,12!" == "--find-links" ( - set currentOption=!line! - ) else ( - call :Write White " PIP: Installing !line!..." - REM echo python.exe -m pip install !line! !currentOption! !pipFlags! - python.exe -m pip install !line! !currentOption! !pipFlags! - call :WriteLine Green "Done" - - set currentOption= - ) - ) -) else ( - call :WriteLine Green "present." -) - :: =============================================================================================== :: 3. Start back end analysis @@ -181,30 +90,91 @@ call :WriteLine Green "Done" pause > NUL :: and we're done. -goto eof +goto:eof :: sub-routines +:setESC + for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( + set ESC=%%b + exit /B 0 + ) + exit /B 0 + +:setColor + REM echo %ESC%[4m - Underline + REM echo %ESC%[7m - Inverse + + if /i "%2" == "foreground" ( + REM Foreground Colours + if /i "%1" == "Black" set currentColor=!ESC![30m + if /i "%1" == "DarkRed" set currentColor=!ESC![31m + if /i "%1" == "DarkGreen" set currentColor=!ESC![32m + if /i "%1" == "DarkYellow" set currentColor=!ESC![33m + if /i "%1" == "DarkBlue" set currentColor=!ESC![34m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![35m + if /i "%1" == "DarkCyan" set currentColor=!ESC![36m + if /i "%1" == "Gray" set currentColor=!ESC![37m + if /i "%1" == "DarkGray" set currentColor=!ESC![90m + if /i "%1" == "Red" set currentColor=!ESC![91m + if /i "%1" == "Green" set currentColor=!ESC![92m + if /i "%1" == "Yellow" set currentColor=!ESC![93m + if /i "%1" == "Blue" set currentColor=!ESC![94m + if /i "%1" == "Magenta" set currentColor=!ESC![95m + if /i "%1" == "Cyan" set currentColor=!ESC![96m + if /i "%1" == "White" set currentColor=!ESC![97m + ) else ( + REM Background Colours + if /i "%1" == "Black" set currentColor=!ESC![40m + if /i "%1" == "DarkRed" set currentColor=!ESC![41m + if /i "%1" == "DarkGreen" set currentColor=!ESC![42m + if /i "%1" == "DarkYellow" set currentColor=!ESC![43m + if /i "%1" == "DarkBlue" set currentColor=!ESC![44m + if /i "%1" == "DarkMagenta" set currentColor=!ESC![45m + if /i "%1" == "DarkCyan" set currentColor=!ESC![46m + if /i "%1" == "Gray" set currentColor=!ESC![47m + if /i "%1" == "DarkGray" set currentColor=!ESC![100m + if /i "%1" == "Red" set currentColor=!ESC![101m + if /i "%1" == "Green" set currentColor=!ESC![102m + if /i "%1" == "Yellow" set currentColor=!ESC![103m + if /i "%1" == "Blue" set currentColor=!ESC![104m + if /i "%1" == "Magenta" set currentColor=!ESC![105m + if /i "%1" == "Cyan" set currentColor=!ESC![106m + if /i "%1" == "White" set currentColor=!ESC![107m + ) + exit /B 0 + :WriteLine -SetLocal EnableDelayedExpansion -if /i "!NO_COLOR!" == "true" ( - REM Echo %~2 -) else ( - powershell write-host -foregroundcolor %1 %~2 - REM powershell write-host -foregroundcolor White -NoNewline -) -exit /b + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if "%~2" == "" ( + Echo: + exit /b 0 + ) + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 %~2 + call :setColor %1 foreground + echo !currentColor!%~2!resetColor! + ) else ( + Echo %~2 + ) + exit /b 0 :Write -SetLocal EnableDelayedExpansion -if /i "!NO_COLOR!" == "true" ( - Echo %~2 -) else ( - powershell write-host -foregroundcolor %1 -NoNewline %~2 - REM powershell write-host -foregroundcolor White -NoNewline -) -exit /b + SetLocal EnableDelayedExpansion + set resetColor=!ESC![0m + + if /i "%techniColor%" == "true" ( + REM powershell write-host -foregroundcolor %1 -NoNewline %~2 + call :setColor %1 foreground + NUL +if errorlevel 1 goto errorNoPython +call :WriteLine Green "present" + +if "%verbosity%"=="loud" where Python + + +:: =============================================================================================== +:: 3. Start back end analysis + +call :Write White "Starting Analysis Services..." +if /i "!VISION_DETECTION!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\detection.py +) +if /i "!VISION_FACE!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\face.py +) +if /i "!VISION_SCENE!" == "true" ( + START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\scene.py +) +:: To start them all in one fell swoop... +:: START "CodeProject SenseAI Analysis Services" /B python !APPDIR!\%deepstackModule%\runAll.py +call :WriteLine Green "Done" + +:: Wait forever. We need these processes to stay alive +pause > NUL + +:: and we're done. +goto:eof + + +:: sub-routines + +:WriteLine +SetLocal EnableDelayedExpansion +REM Remember that %%~N means "parameter N with the quotes removed" +if /i "%techniColor%" == "true" ( + powershell write-host -foregroundcolor %1 %~2 +) else ( + Echo %~2 +) +exit /b + +:Write +SetLocal EnableDelayedExpansion +if /i "%techniColor%" == "true" ( + powershell write-host -foregroundcolor %1 -NoNewline %~2 +) else ( + + REM Writes have been causing errors to be raised. + if errorlevel 1 Echo ErrorLevel is currently %ErrorLevel% + nul +) +exit /b + + +:: Jump points + +:errorNoPython +call :WriteLine White "" +call :WriteLine White "" +call :WriteLine White "---------------------------------------------------------------------------" +call :WriteLine Red "Error: Python not installed" +call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version of Python" +goto:eof + +:errorNoPythonVenv +call :WriteLine White "" +call :WriteLine White "" +call :WriteLine White "---------------------------------------------------------------------------" +call :WriteLine Red "Error: Python Virtual Environment activation failed" +call :WriteLine Red "Go to https://www.python.org/downloads/ for the latest version" +goto:eof \ No newline at end of file