From babcbc0fc77ca5e471cdc6fb28ad1347fc0bdf43 Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Mon, 28 Apr 2025 10:20:06 +0300 Subject: [PATCH] clean postbuild script clean warnings --- Azaion.Annotator/Annotator.xaml.cs | 5 ++-- Azaion.Annotator/Controls/CircleVisual.cs | 9 ++++--- Azaion.Annotator/Controls/MapMatcher.xaml.cs | 10 ++++--- Azaion.Common/Constants.cs | 6 ++--- Azaion.Common/Services/SatelliteDownloader.cs | 6 ++--- Azaion.Dataset/DatasetExplorerEventHandler.cs | 5 ++-- Azaion.Inference/api_client.pyx | 4 +-- Azaion.Inference/inference_engine.pyx | 7 +++-- Azaion.Inference/remote_command_handler.pyx | 2 +- Azaion.Suite/copy_inf_gps.cmd | 26 +++++++++++++++++++ Azaion.Suite/postbuild.cmd | 26 ------------------- build/installer.iss | 1 + 12 files changed, 56 insertions(+), 51 deletions(-) create mode 100644 Azaion.Suite/copy_inf_gps.cmd diff --git a/Azaion.Annotator/Annotator.xaml.cs b/Azaion.Annotator/Annotator.xaml.cs index e3b3f19..48c33d4 100644 --- a/Azaion.Annotator/Annotator.xaml.cs +++ b/Azaion.Annotator/Annotator.xaml.cs @@ -253,10 +253,10 @@ public partial class Annotator ShowAnnotations(res.Annotation, showImage: true); } - private async Task SaveUserSettings() + private Task SaveUserSettings() { if (_suspendLayout) - return; + return Task.CompletedTask; _appConfig.UIConfig.LeftPanelWidth = MainGrid.ColumnDefinitions.FirstOrDefault()!.Width.Value; _appConfig.UIConfig.RightPanelWidth = MainGrid.ColumnDefinitions.LastOrDefault()!.Width.Value; @@ -266,6 +266,7 @@ public partial class Annotator _configUpdater.Save(_appConfig); return Task.CompletedTask; }, SaveConfigTaskId, TimeSpan.FromSeconds(5)); + return Task.CompletedTask; } private void ShowTimeAnnotations(TimeSpan time) diff --git a/Azaion.Annotator/Controls/CircleVisual.cs b/Azaion.Annotator/Controls/CircleVisual.cs index 82239a6..48db328 100644 --- a/Azaion.Annotator/Controls/CircleVisual.cs +++ b/Azaion.Annotator/Controls/CircleVisual.cs @@ -178,12 +178,13 @@ namespace Azaion.Annotator.Controls void ForceUpdateText() { + _fText = new FormattedText(_text, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, Font, FontSize, - Foreground); + Foreground, 1.0); IsChanged = true; } @@ -207,7 +208,7 @@ namespace Azaion.Annotator.Controls Visual _child = null!; - public virtual Visual Child + public virtual Visual? Child { get => _child; set @@ -228,7 +229,7 @@ namespace Azaion.Annotator.Controls } // cache the new child - _child = value; + _child = value!; InvalidateVisual(); } @@ -295,7 +296,7 @@ namespace Azaion.Annotator.Controls } } - protected override Visual GetVisualChild(int index) + protected override Visual? GetVisualChild(int index) { return Child; } diff --git a/Azaion.Annotator/Controls/MapMatcher.xaml.cs b/Azaion.Annotator/Controls/MapMatcher.xaml.cs index 20c6600..ed8922e 100644 --- a/Azaion.Annotator/Controls/MapMatcher.xaml.cs +++ b/Azaion.Annotator/Controls/MapMatcher.xaml.cs @@ -46,8 +46,11 @@ public partial class MapMatcher : UserControl private async Task OpenGpsLocation(int gpsFilesIndex) { - var media = GpsFiles.Items[gpsFilesIndex] as MediaFileInfo; + //var media = GpsFiles.Items[gpsFilesIndex] as MediaFileInfo; var ann = _annotations.GetValueOrDefault(gpsFilesIndex); + if (ann == null) + return; + GpsImageEditor.Background = new ImageBrush { ImageSource = await Path.Combine(_currentDir, ann.Name).OpenImage() @@ -110,9 +113,9 @@ public partial class MapMatcher : UserControl await _gpsMatcherService.RunGpsMatching(dir.FullName, initialLat, initialLon, async res => await SetMarker(res)); } - private async Task SetMarker(GpsMatchResult result) + private Task SetMarker(GpsMatchResult result) { - await Dispatcher.Invoke(async () => + Dispatcher.Invoke(() => { var marker = new GMapMarker(new PointLatLng(result.Latitude, result.Longitude)); var ann = _annotations[result.Index]; @@ -126,6 +129,7 @@ public partial class MapMatcher : UserControl SatelliteMap.Position = new PointLatLng(result.Latitude, result.Longitude); SatelliteMap.ZoomAndCenterMarkers(null); }); + return Task.CompletedTask; } private async Task SetFromCsv(List mediaFiles) diff --git a/Azaion.Common/Constants.cs b/Azaion.Common/Constants.cs index fe55ccd..556017b 100644 --- a/Azaion.Common/Constants.cs +++ b/Azaion.Common/Constants.cs @@ -27,9 +27,9 @@ public class Constants public static readonly AnnotationConfig DefaultAnnotationConfig = new() { - DetectionClasses = DefaultAnnotationClasses, - VideoFormats = DefaultVideoFormats, - ImageFormats = DefaultImageFormats, + DetectionClasses = DefaultAnnotationClasses!, + VideoFormats = DefaultVideoFormats!, + ImageFormats = DefaultImageFormats!, AnnotationsDbFile = DEFAULT_ANNOTATIONS_DB_FILE }; diff --git a/Azaion.Common/Services/SatelliteDownloader.cs b/Azaion.Common/Services/SatelliteDownloader.cs index 867980d..ffa9120 100644 --- a/Azaion.Common/Services/SatelliteDownloader.cs +++ b/Azaion.Common/Services/SatelliteDownloader.cs @@ -51,7 +51,7 @@ public class SatelliteDownloader( Directory.CreateDirectory(_satDirectory); var downloadTilesResult = await DownloadTiles(centerLat, centerLon, radiusM, zoomLevel, token); - var image = await ComposeTiles(downloadTilesResult.Tiles, token); + var image = ComposeTiles(downloadTilesResult.Tiles, token); if (image != null) await SplitToTiles(image, downloadTilesResult, token); } @@ -104,7 +104,7 @@ public class SatelliteDownloader( await Task.Run(() => Parallel.ForEach(cropTasks, action => action()), token); } - private async Task?> ComposeTiles(ConcurrentDictionary<(int x, int y), byte[]> downloadedTiles, CancellationToken token = default) + private Image? ComposeTiles(ConcurrentDictionary<(int x, int y), byte[]> downloadedTiles, CancellationToken token = default) { if (downloadedTiles.IsEmpty) return null; @@ -148,8 +148,6 @@ public class SatelliteDownloader( } }); - // await largeImage.SaveAsync(Path.Combine(_satDirectory, "full_map.tif"), - // new TiffEncoder { Compression = TiffCompression.Deflate }, token); return largeImage; } diff --git a/Azaion.Dataset/DatasetExplorerEventHandler.cs b/Azaion.Dataset/DatasetExplorerEventHandler.cs index de4b3c8..d2ee77e 100644 --- a/Azaion.Dataset/DatasetExplorerEventHandler.cs +++ b/Azaion.Dataset/DatasetExplorerEventHandler.cs @@ -109,9 +109,9 @@ public class DatasetExplorerEventHandler( } } - public async Task Handle(AnnotationCreatedEvent notification, CancellationToken cancellationToken) + public Task Handle(AnnotationCreatedEvent notification, CancellationToken cancellationToken) { - datasetExplorer.Dispatcher.Invoke(async () => + datasetExplorer.Dispatcher.Invoke(() => { var annotation = notification.Annotation; var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber; @@ -133,6 +133,7 @@ public class DatasetExplorerEventHandler( datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb); } }); + return Task.CompletedTask; } public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken) diff --git a/Azaion.Inference/api_client.pyx b/Azaion.Inference/api_client.pyx index f0d533c..dffaf3f 100644 --- a/Azaion.Inference/api_client.pyx +++ b/Azaion.Inference/api_client.pyx @@ -79,9 +79,9 @@ cdef class ApiClient: try: r = requests.post(url, headers=headers, files=files, allow_redirects=True) r.raise_for_status() - print(f"Uploaded {filename} to {constants.API_URL}/{folder} successfully: {r.status_code}.") + constants.log(f"Uploaded {filename} to {constants.API_URL}/{folder} successfully: {r.status_code}.") except Exception as e: - print(f"Upload fail: {e}") + constants.log(f"Upload fail: {e}") cdef load_bytes(self, str filename, str folder): hardware_service = HardwareService() diff --git a/Azaion.Inference/inference_engine.pyx b/Azaion.Inference/inference_engine.pyx index 6617279..0353111 100644 --- a/Azaion.Inference/inference_engine.pyx +++ b/Azaion.Inference/inference_engine.pyx @@ -7,7 +7,7 @@ import tensorrt as trt import pycuda.driver as cuda import pycuda.autoinit # required for automatically initialize CUDA, do not remove. import pynvml - +cimport constants cdef class InferenceEngine: def __init__(self, model_bytes: bytes, batch_size: int = 1, **kwargs): @@ -51,7 +51,6 @@ cdef class OnnxEngine(InferenceEngine): cdef class TensorRTEngine(InferenceEngine): def __init__(self, model_bytes: bytes, batch_size: int = 4, **kwargs): super().__init__(model_bytes, batch_size) - print('Enter init TensorRT') try: logger = trt.Logger(trt.Logger.WARNING) @@ -142,7 +141,7 @@ cdef class TensorRTEngine(InferenceEngine): return None if builder.platform_has_fast_fp16: - print('Converting to supported fp16') + constants.log('Converting to supported fp16') config.set_flag(trt.BuilderFlag.FP16) else: print('Converting to supported fp32. (fp16 is not supported)') @@ -151,7 +150,7 @@ cdef class TensorRTEngine(InferenceEngine): if plan is None: print('Conversion failed.') return None - print('conversion done!') + constants.log('conversion done!') return bytes(plan) cdef tuple get_input_shape(self): diff --git a/Azaion.Inference/remote_command_handler.pyx b/Azaion.Inference/remote_command_handler.pyx index 3cefff3..d380cc5 100644 --- a/Azaion.Inference/remote_command_handler.pyx +++ b/Azaion.Inference/remote_command_handler.pyx @@ -66,7 +66,7 @@ cdef class RemoteCommandHandler: self._on_command(cmd) except Exception as e: if not self._shutdown_event.is_set(): - print(f"Worker error: {e}") + constants.log(f"Worker error: {e}") import traceback traceback.print_exc() finally: diff --git a/Azaion.Suite/copy_inf_gps.cmd b/Azaion.Suite/copy_inf_gps.cmd new file mode 100644 index 0000000..9d6b762 --- /dev/null +++ b/Azaion.Suite/copy_inf_gps.cmd @@ -0,0 +1,26 @@ +rem Inference + +set INFERENCE_PATH=%cd%\..\Azaion.Inference +xcopy /E /Y %INFERENCE_PATH%\dist\azaion-inference %SUITE_FOLDER% +copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll %SUITE_FOLDER% +copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll %SUITE_FOLDER% +copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll %SUITE_FOLDER% +copy %INFERENCE_PATH%\config.yaml %SUITE_FOLDER% + +rem Gps Denied +set DESTINATION=%SUITE_FOLDER%\gps-denied +set GPS_DENIED=%cd%\..\..\gps-denied\ + +rmdir %DESTINATION% /s /q +mkdir %DESTINATION% +copy %GPS_DENIED%\image-matcher\build\Desktop_Qt_6_9_0_MSVC2022_64bit-Release\release\image-matcher.exe %DESTINATION% + +copy %GPS_DENIED%\.libs\libzmq\build\dist\bin\libzmq-v143-mt-4_3_6.dll %DESTINATION% +copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime.dll %DESTINATION% +copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime_providers_cuda.dll %DESTINATION% +copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime_providers_shared.dll %DESTINATION% +copy %GPS_DENIED%\.libs\opencv\build\x64\vc16\bin\opencv_world4110.dll %DESTINATION% +copy C:\Qt\6.9.0\msvc2022_64\bin\Qt6Core.dll %DESTINATION% + +mkdir %DESTINATION%\models +copy ..\..\gps-denied-work\models\* %DESTINATION%\models \ No newline at end of file diff --git a/Azaion.Suite/postbuild.cmd b/Azaion.Suite/postbuild.cmd index 93ca1b7..b97ba0d 100644 --- a/Azaion.Suite/postbuild.cmd +++ b/Azaion.Suite/postbuild.cmd @@ -11,29 +11,3 @@ call upload-file %FILE2_TO_UPLOAD% %RESOURCES_FOLDER% set SUITE_FOLDER=%cd%\bin\%CONFIG%\net8.0-windows\ -rem Inference - -set INFERENCE_PATH=%cd%\..\Azaion.Inference -xcopy /E /Y %INFERENCE_PATH%\dist\azaion-inference %SUITE_FOLDER% -copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_10.dll %SUITE_FOLDER% -copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvinfer_plugin_10.dll %SUITE_FOLDER% -copy %INFERENCE_PATH%\venv\Lib\site-packages\tensorrt_libs\nvonnxparser_10.dll %SUITE_FOLDER% -copy %INFERENCE_PATH%\config.yaml %SUITE_FOLDER% - -rem Gps Denied -set DESTINATION=%SUITE_FOLDER%\gps-denied -set GPS_DENIED=%cd%\..\..\gps-denied\ - -rmdir %DESTINATION% /s /q -mkdir %DESTINATION% -copy %GPS_DENIED%\image-matcher\build\Desktop_Qt_6_9_0_MSVC2022_64bit-Release\release\image-matcher.exe %DESTINATION% - -copy %GPS_DENIED%\.libs\libzmq\build\dist\bin\libzmq-v143-mt-4_3_6.dll %DESTINATION% -copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime.dll %DESTINATION% -copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime_providers_cuda.dll %DESTINATION% -copy %GPS_DENIED%\.libs\onnxruntime\lib\onnxruntime_providers_shared.dll %DESTINATION% -copy %GPS_DENIED%\.libs\opencv\build\x64\vc16\bin\opencv_world4110.dll %DESTINATION% -copy C:\Qt\6.9.0\msvc2022_64\bin\Qt6Core.dll %DESTINATION% - -mkdir %DESTINATION%\models -copy ..\..\gps-denied-work\models\* %DESTINATION%\models \ No newline at end of file diff --git a/build/installer.iss b/build/installer.iss index 0ad09ed..41de936 100644 --- a/build/installer.iss +++ b/build/installer.iss @@ -12,6 +12,7 @@ UninstallDisplayName=Azaion Suite UninstallDisplayIcon={app}\Azaion.Suite.exe Compression=lzma2/fast SolidCompression=yes +DiskSpanning=yes [Languages] Name: "english"; MessagesFile: "compiler:Default.isl"