From 792abce8c4e00648a9ed40fcacc5d04cd38d6d24 Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Tue, 4 Mar 2025 13:30:13 +0200 Subject: [PATCH] small ux fixes --- Azaion.Annotator/Annotator.xaml | 58 ++++- Azaion.Annotator/Annotator.xaml.cs | 5 + Azaion.Common/Constants.cs | 8 + Azaion.Common/Controls/DetectionClasses.xaml | 20 +- .../Controls/DetectionClasses.xaml.cs | 17 +- Azaion.Suite.sln | 1 + Azaion.Suite/config.json | 2 +- build/installer.iss | 208 ++++++++++++++++++ 8 files changed, 305 insertions(+), 14 deletions(-) create mode 100644 build/installer.iss diff --git a/Azaion.Annotator/Annotator.xaml b/Azaion.Annotator/Annotator.xaml index 486977f..bc1b9dc 100644 --- a/Azaion.Annotator/Annotator.xaml +++ b/Azaion.Annotator/Annotator.xaml @@ -297,7 +297,8 @@ - + + + + + diff --git a/Azaion.Annotator/Annotator.xaml.cs b/Azaion.Annotator/Annotator.xaml.cs index e52d578..10679e4 100644 --- a/Azaion.Annotator/Annotator.xaml.cs +++ b/Azaion.Annotator/Annotator.xaml.cs @@ -586,4 +586,9 @@ public partial class Annotator } }); } + + private void SoundDetections(object sender, RoutedEventArgs e) + { + throw new NotImplementedException(); + } } diff --git a/Azaion.Common/Constants.cs b/Azaion.Common/Constants.cs index 67e7d14..61c9aeb 100644 --- a/Azaion.Common/Constants.cs +++ b/Azaion.Common/Constants.cs @@ -82,4 +82,12 @@ public class Constants #endregion + #region Mode Captions + + public const string REGULAR_MODE_CAPTION = "Норма"; + public const string WINTER_MODE_CAPTION = "Зима"; + public const string NIGHT_MODE_CAPTION = "Ніч"; + + #endregion + } \ No newline at end of file diff --git a/Azaion.Common/Controls/DetectionClasses.xaml b/Azaion.Common/Controls/DetectionClasses.xaml index ec8ffef..eb0d847 100644 --- a/Azaion.Common/Controls/DetectionClasses.xaml +++ b/Azaion.Common/Controls/DetectionClasses.xaml @@ -87,7 +87,7 @@ Tag="0" GroupName="Mode" Checked="ModeRadioButton_Checked" - IsChecked="{Binding IsChecked}" + IsChecked="True" Style="{StaticResource ButtonRadioButtonStyle}"> @@ -111,9 +111,9 @@ - + - + - + diff --git a/Azaion.Common/Controls/DetectionClasses.xaml.cs b/Azaion.Common/Controls/DetectionClasses.xaml.cs index 0a2e3a6..5558144 100644 --- a/Azaion.Common/Controls/DetectionClasses.xaml.cs +++ b/Azaion.Common/Controls/DetectionClasses.xaml.cs @@ -13,11 +13,26 @@ public class DetectionClassChangedEventArgs(DetectionClass detectionClass, int c public partial class DetectionClasses { public event EventHandler? DetectionClassChanged; - public bool IsChecked = true; + private const int CaptionedMinWidth = 230; public DetectionClasses() { InitializeComponent(); + SizeChanged += (sender, args) => + { + if (args.NewSize.Width < CaptionedMinWidth) + { + RegularModeButton.Text = ""; + WinterModeButton.Text = ""; + NightModeButton.Text = ""; + } + else + { + RegularModeButton.Text = Constants.REGULAR_MODE_CAPTION; + WinterModeButton.Text= Constants.WINTER_MODE_CAPTION; + NightModeButton.Text= Constants.NIGHT_MODE_CAPTION; + } + }; } public void Init(List detectionClasses) diff --git a/Azaion.Suite.sln b/Azaion.Suite.sln index 9f2616d..5315379 100644 --- a/Azaion.Suite.sln +++ b/Azaion.Suite.sln @@ -28,6 +28,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CF141A48 build\requirements.txt = build\requirements.txt build\build_downloader.cmd = build\build_downloader.cmd build\installer.iss = build\installer.iss + build\cdn_manager.py = build\cdn_manager.py EndProjectSection EndProject Global diff --git a/Azaion.Suite/config.json b/Azaion.Suite/config.json index 25cceb5..6829833 100644 --- a/Azaion.Suite/config.json +++ b/Azaion.Suite/config.json @@ -1,7 +1,7 @@ { "PythonConfig": { "ZeroMqHost": "127.0.0.1", - "ZeroMqPort": 5128, + "ZeroMqPort": 5127, "RetryCount": 25, "TimeoutSeconds": 5, "ResourcesFolder": "stage" diff --git a/build/installer.iss b/build/installer.iss new file mode 100644 index 0000000..db5f985 --- /dev/null +++ b/build/installer.iss @@ -0,0 +1,208 @@ +[Setup] +AppName=Azaion Suite +AppVersion=1.3.2 +DefaultDirName={localappdata}\Azaion\Azaion Suite +DefaultGroupName=Azaion Suite +OutputDir=..\ +OutputBaseFilename=AzaionSuiteInstaller +SetupIconFile=..\dist\logo.ico +UninstallDisplayName=Azaion Suite +UninstallDisplayIcon={app}\Azaion.Suite.exe +Compression=lzma2/fast +SolidCompression=yes + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Tasks] +Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + +[Files] +Source: "..\dist\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs; + +[Icons] +Name: "{group}\Azaion Suite"; Filename: "{app}\Azaion.Suite.exe" +Name: "{commondesktop}\Azaion Suite"; Filename: "{app}\Azaion.Suite.exe"; Tasks: desktopicon + +[Constants] +CUDA12_URL=https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda_12.8.0_571.96_windows.exe +CUDNN9_URL=https://developer.download.nvidia.com/compute/cudnn/9.7.1/local_installers/cudnn_9.7.1_windows.exe + +function GetEnvironmentVariable(const Name: string): string; +var + Buffer: array[0..2047] of Char; + Size: DWORD; +begin + Size := SizeOf(Buffer) - 1; + if GetEnvironmentVariableW(PChar(Name), Buffer, Size) = 0 then + Result := '' + else + Result := Buffer; +end; + +function CheckCUDAGPU(): Boolean; +var + ResultCode: Integer; + Output: string; + GPUInfo: string; +begin + Result := False; + if not Exec('wmic', 'path win32_VideoController get name, caption', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then + begin + MsgBox('Error checking GPU information.', mbError, MB_OK); + Exit; + end; + + Output := GetShellOutput('wmic path win32_VideoController get name, caption'); + Output := LowerCase(Output); + + if (Pos('nvidia', Output) > 0) or (Pos('amd', Output) > 0) then + Result := True + else + MsgBox('No CUDA-compatible GPU detected. This application requires a CUDA-capable GPU to run.', mbError, MB_OK); +end; + +function CheckCUDA12(): Boolean; +var + CUDA_PATH: string; +begin + Result := False; + CUDA_PATH := GetEnvironmentVariable('CUDA_PATH'); + if CUDA_PATH <> '' then + Result := True + else + MsgBox('CUDA 12.x is not detected. Please ensure CUDA Toolkit 12.x is installed and CUDA_PATH environment variable is set.', mbError, MB_OK); +end; + +function CheckcuDNN9(): Boolean; +var + ResultCode: Integer; + Output: string; +begin + Result := False; + if not Exec('where', 'cudnn*', '', SW_HIDE, ewWaitUntilTerminated, ResultCode) then + begin + MsgBox('Error checking for cuDNN.', mbError, MB_OK); + Exit; + end; + + Output := GetShellOutput('where cudnn*'); + Output := LowerCase(Output); + + if Pos('v9', Output) > 0 then + Result := True + else + MsgBox('cuDNN 9.x is not detected. Please ensure cuDNN 9.x is installed and accessible in your system path.', mbError, MB_OK); +end; + +function DownloadFileSilent(const URL, LocalFile: string): Boolean; +var + ResultCode: Integer; +begin + Result := URLDownloadToFile(nil, PChar(URL), PChar(LocalFile), 0, nil) = 0; + if not Result then + MsgBox('Error downloading file from: ' + URL, mbError, MB_OK); +end; + +function InstallExecutableSilent(const ExecutablePath: string; const Parameters: string): Boolean; +var + ResultCode: Integer; +begin + Result := Exec(ExecutablePath, Parameters, '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + if not Result then + MsgBox('Error executing: ' + ExecutablePath, mbError, MB_OK); +end; + +procedure CurStepChanged(CurStep: TSetupStep); +var + NeedsCUDA12, NeedscuDNN9: Boolean; + CUDA12InstallerURL, cuDNN9InstallerURL, CUDA12InstallerLocal, cuDNN9InstallerLocal: string; + DownloadSuccess, InstallSuccess: Boolean; +begin + if CurStep = ssInstall then + begin + if not CheckCUDAGPU() then + begin + Abort(); + Exit; + end; + + NeedsCUDA12 := not CheckCUDA12(); + NeedscuDNN9 := not CheckcuDNN9(); + + if NeedsCUDA12 or NeedscuDNN9 then + begin + SuppressMessages(True); + SuppressMovieModalMessages(True); + + MsgBox('Required dependencies (CUDA and/or cuDNN) are missing. Installer will attempt to download and install them silently.', mbInformation, MB_OK); + + CUDA12InstallerURL := '{const:CUDA12_URL}'; + cuDNN9InstallerURL := '{const:CUDNN9_URL}'; + CUDA12InstallerLocal := ExpandConstant('{tmp}\cuda_installer.exe'); + cuDNN9InstallerLocal := ExpandConstant('{tmp}\cudnn_installer.exe'); + + if NeedsCUDA12 then + begin + Log('Downloading CUDA 12 installer...'); + if DownloadFileSilent(CUDA12InstallerURL, CUDA12InstallerLocal) then + begin + Log('Installing CUDA 12 silently...'); + if InstallExecutableSilent(CUDA12InstallerLocal, '-s') then + Log('CUDA 12 installed successfully.') + else + begin + Log('CUDA 12 installation failed.'); + MsgBox('CUDA 12 installation failed. Please install CUDA Toolkit 12.x manually and restart the installer.', mbCriticalError, MB_OK); + Abort(); + Exit; + end; + else + begin + MsgBox('Failed to download CUDA 12 installer. Please download and install CUDA Toolkit 12.x manually and restart the installer.', mbCriticalError, MB_OK); + Abort(); + Exit; + end; + end; + + if NeedscuDNN9 then + begin + Log('Downloading cuDNN 9 installer...'); + if DownloadFileSilent(cuDNN9InstallerURL, cuDNN9InstallerLocal) then + begin + Log('Installing cuDNN 9 silently...'); + if InstallExecutableSilent(cuDNN9InstallerLocal, '-s') then + Log('cuDNN 9 installed successfully.') + else + begin + Log('cuDNN 9 installation failed.'); + MsgBox('cuDNN 9 installation failed. Please install cuDNN 9.x manually and restart the installer.', mbCriticalError, MB_OK); + Abort(); + Exit; + end; + else + begin + MsgBox('Failed to download cuDNN 9 installer. Please download and install cuDNN 9.x manually and restart the installer.', mbCriticalError, MB_OK); + Abort(); + Exit; + end; + end; + + SuppressMessages(False); + SuppressMovieModalMessages(False); + + if NeedsCUDA12 or NeedscuDNN9 then + begin + MsgBox('CUDA and cuDNN dependencies installation completed.', mbInformation, MB_OK); + if not CheckCUDA12() or not CheckcuDNN9() then + MsgBox('Dependencies installation finished, but still not detected correctly. Please verify your CUDA and cuDNN installation.', mbWarning, MB_OK); + end; + end; + end; +end; + +procedure InitializeSetup(); +begin +end; + +[UninstallRun] \ No newline at end of file