add publish script, check its work

This commit is contained in:
Alex Bezdieniezhnykh
2025-02-14 23:08:50 +02:00
parent 961d2499de
commit 0d6ea4264f
11 changed files with 97 additions and 43 deletions
+27 -9
View File
@@ -14,7 +14,6 @@ using Azaion.Common.DTO.Config;
using Azaion.Common.Events; using Azaion.Common.Events;
using Azaion.Common.Extensions; using Azaion.Common.Extensions;
using Azaion.Common.Services; using Azaion.Common.Services;
using Azaion.CommonSecurity.Services;
using LibVLCSharp.Shared; using LibVLCSharp.Shared;
using MediatR; using MediatR;
using Microsoft.WindowsAPICodePack.Dialogs; using Microsoft.WindowsAPICodePack.Dialogs;
@@ -520,7 +519,7 @@ public partial class Annotator
var files = new List<string>(); var files = new List<string>();
await Dispatcher.Invoke(async () => await Dispatcher.Invoke(async () =>
{ {
//Take not annotated medias //Take not annotataed medias
files = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?.Skip(LvFiles.SelectedIndex) files = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?.Skip(LvFiles.SelectedIndex)
.Take(Constants.DETECTION_BATCH_SIZE) .Take(Constants.DETECTION_BATCH_SIZE)
.Where(x => !x.HasAnnotations) .Where(x => !x.HasAnnotations)
@@ -532,16 +531,16 @@ public partial class Annotator
await ReloadAnnotations(); await ReloadAnnotations();
} }
}); });
if (files.Count == 0) if (files.Count == 0)
break; break;
await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage), ct); await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage, ct), ct);
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
if (LvFiles.SelectedIndex + files.Count >= LvFiles.Items.Count)
DetectionCancellationSource.Cancel();
LvFiles.SelectedIndex += files.Count; LvFiles.SelectedIndex += files.Count;
LvFiles.Items.Refresh();
}); });
} }
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
@@ -553,15 +552,28 @@ public partial class Annotator
}); });
} }
private async Task ProcessDetection(AnnotationImage annotationImage) private async Task ProcessDetection(AnnotationImage annotationImage, CancellationToken ct = default)
{ {
await Dispatcher.Invoke(async () => await Dispatcher.Invoke(async () =>
{ {
try try
{ {
var annotation = await _annotationService.SaveAnnotation(annotationImage); var annotation = await _annotationService.SaveAnnotation(annotationImage, ct);
if (annotation.OriginalMediaName != _formState.CurrentMedia?.FName) if (annotation.OriginalMediaName != _formState.CurrentMedia?.FName)
return; {
var nextFile = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?
.Select((info, i) => new
{
MediaInfo = info,
Index = i
})
.FirstOrDefault(x => x.MediaInfo.FName == annotation.OriginalMediaName);
if (nextFile != null)
{
LvFiles.SelectedIndex = nextFile.Index;
await _mediator.Publish(new AnnotatorControlEvent(PlaybackControlEnum.Play), ct);
}
}
AddAnnotation(annotation); AddAnnotation(annotation);
if (FollowAI) if (FollowAI)
@@ -573,7 +585,13 @@ public partial class Annotator
$"size=({det.Width:F2}, {det.Height:F2}), " + $"size=({det.Width:F2}, {det.Height:F2}), " +
$"prob: {det.Probability*100:F0}%")); $"prob: {det.Probability*100:F0}%"));
Dispatcher.Invoke(() => StatusHelp.Text = log); Dispatcher.Invoke(() =>
{
if (_formState.CurrentMedia != null)
_formState.CurrentMedia.HasAnnotations = true;
LvFiles.Items.Refresh();
StatusHelp.Text = log;
});
} }
catch (Exception e) catch (Exception e)
{ {
+9 -7
View File
@@ -123,7 +123,7 @@ public class AnnotatorEventHandler(
switch (controlEnum) switch (controlEnum)
{ {
case PlaybackControlEnum.Play: case PlaybackControlEnum.Play:
Play(); await Play(cancellationToken);
break; break;
case PlaybackControlEnum.Pause: case PlaybackControlEnum.Pause:
mediaPlayer.Pause(); mediaPlayer.Pause();
@@ -170,10 +170,10 @@ public class AnnotatorEventHandler(
mediaPlayer.Volume = 0; mediaPlayer.Volume = 0;
break; break;
case PlaybackControlEnum.Previous: case PlaybackControlEnum.Previous:
NextMedia(isPrevious: true); await NextMedia(isPrevious: true, ct: cancellationToken);
break; break;
case PlaybackControlEnum.Next: case PlaybackControlEnum.Next:
NextMedia(); await NextMedia(ct: cancellationToken);
break; break;
case PlaybackControlEnum.None: case PlaybackControlEnum.None:
break; break;
@@ -188,7 +188,7 @@ public class AnnotatorEventHandler(
} }
} }
private void NextMedia(bool isPrevious = false) private async Task NextMedia(bool isPrevious = false, CancellationToken ct = default)
{ {
var increment = isPrevious ? -1 : 1; var increment = isPrevious ? -1 : 1;
var check = isPrevious ? -1 : mainWindow.LvFiles.Items.Count; var check = isPrevious ? -1 : mainWindow.LvFiles.Items.Count;
@@ -196,7 +196,7 @@ public class AnnotatorEventHandler(
return; return;
mainWindow.LvFiles.SelectedIndex += increment; mainWindow.LvFiles.SelectedIndex += increment;
Play(); await Play(ct);
} }
public async Task Handle(VolumeChangedEvent notification, CancellationToken cancellationToken) public async Task Handle(VolumeChangedEvent notification, CancellationToken cancellationToken)
@@ -211,7 +211,7 @@ public class AnnotatorEventHandler(
mediaPlayer.Volume = volume; mediaPlayer.Volume = volume;
} }
private void Play() private async Task Play(CancellationToken ct = default)
{ {
if (mainWindow.LvFiles.SelectedItem == null) if (mainWindow.LvFiles.SelectedItem == null)
return; return;
@@ -219,6 +219,8 @@ public class AnnotatorEventHandler(
mainWindow.Editor.ResetBackground(); mainWindow.Editor.ResetBackground();
formState.CurrentMedia = mediaInfo; formState.CurrentMedia = mediaInfo;
//need to wait a bit for correct VLC playback event handling
await Task.Delay(100, ct);
mediaPlayer.Stop(); mediaPlayer.Stop();
mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}"; mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}";
mainWindow.BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.PauseForAnnotations]); mainWindow.BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.PauseForAnnotations]);
@@ -269,7 +271,7 @@ public class AnnotatorEventHandler(
else else
{ {
File.Copy(formState.CurrentMedia.Path, imgPath, overwrite: true); File.Copy(formState.CurrentMedia.Path, imgPath, overwrite: true);
NextMedia(); await NextMedia(ct: cancellationToken);
} }
var annotation = await annotationService.SaveAnnotation(formState.VideoName, time, imageExtension, currentDetections, SourceEnum.Manual, token: cancellationToken); var annotation = await annotationService.SaveAnnotation(formState.VideoName, time, imageExtension, currentDetections, SourceEnum.Manual, token: cancellationToken);
mainWindow.AddAnnotation(annotation); mainWindow.AddAnnotation(annotation);
@@ -35,6 +35,8 @@ public class PythonResourceLoader : IResourceLoader, IAuthProvider
} }
private void StartPython() private void StartPython()
{
try
{ {
using var process = new Process(); using var process = new Process();
process.StartInfo = new ProcessStartInfo process.StartInfo = new ProcessStartInfo
@@ -51,6 +53,12 @@ public class PythonResourceLoader : IResourceLoader, IAuthProvider
process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); }; process.ErrorDataReceived += (_, e) => { if (e.Data != null) Console.WriteLine(e.Data); };
process.Start(); process.Start();
} }
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
public void Login(ApiCredentials credentials) public void Login(ApiCredentials credentials)
{ {
+1 -1
View File
@@ -199,7 +199,7 @@ public partial class DatasetExplorer
RefreshThumbnailsButtonItem.Visibility = Visibility.Hidden; RefreshThumbnailsButtonItem.Visibility = Visibility.Hidden;
RefreshProgressBarItem.Visibility = Visibility.Visible; RefreshProgressBarItem.Visibility = Visibility.Visible;
var result = MessageBox.Show($"Видалити всі іконки і згенерувати нову базу іконок в {_directoriesConfig.ThumbnailsDirectory}?", var result = MessageBox.Show($"Видалити всі іконки та згенерувати нову базу іконок в {_directoriesConfig.ThumbnailsDirectory}?",
"Підтвердження оновлення іконок", MessageBoxButton.YesNo, MessageBoxImage.Question); "Підтвердження оновлення іконок", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result != MessageBoxResult.Yes) if (result != MessageBoxResult.Yes)
return; return;
+5
View File
@@ -22,6 +22,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azaion.Dataset", "Dummy\Aza
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azaion.CommonSecurity", "Azaion.CommonSecurity\Azaion.CommonSecurity.csproj", "{E0C7176D-2E91-4928-B3C1-55CC91C8F77D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azaion.CommonSecurity", "Azaion.CommonSecurity\Azaion.CommonSecurity.csproj", "{E0C7176D-2E91-4928-B3C1-55CC91C8F77D}"
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CF141A48-8002-4006-81CF-6B85AE5B0B5F}"
ProjectSection(SolutionItems) = preProject
build\publish.cmd = build\publish.cmd
EndProjectSection
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
+1 -1
View File
@@ -57,7 +57,7 @@
<MakeDir Directories="$(TargetDir)dummy" /> <MakeDir Directories="$(TargetDir)dummy" />
<Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)dummy" /> <Move SourceFiles="$(TargetDir)Azaion.Annotator.dll" DestinationFolder="$(TargetDir)dummy" />
<Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)dummy" /> <Move SourceFiles="$(TargetDir)Azaion.Dataset.dll" DestinationFolder="$(TargetDir)dummy" />
<Exec Command="upload.cmd $(ConfigurationName)" /> <Exec Command="upload.cmd $(ConfigurationName) stage" />
</Target> </Target>
</Project> </Project>
+1 -3
View File
@@ -74,7 +74,6 @@
BorderBrush="DimGray" BorderBrush="DimGray"
BorderThickness="0,0,0,1" BorderThickness="0,0,0,1"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="admin@azaion.com"
/> />
<TextBlock Text="Пароль" <TextBlock Text="Пароль"
Grid.Row="2" Grid.Row="2"
@@ -88,8 +87,7 @@
Padding="0,5" Padding="0,5"
Width="300" Width="300"
BorderThickness="0,0,0,1" BorderThickness="0,0,0,1"
HorizontalAlignment="Left" HorizontalAlignment="Left"/>
Password="Az@1on1000Odm$n"/>
</Grid> </Grid>
<Button x:Name="LoginBtn" <Button x:Name="LoginBtn"
Content="Вхід" Content="Вхід"
+2 -3
View File
@@ -1,7 +1,6 @@
{ {
"ApiConfig": { "ApiConfig": {
"TimeoutSeconds": 20.0, "TimeoutSeconds": 20.0
"ResourcesFolder": "stage"
}, },
"DirectoriesConfig": { "DirectoriesConfig": {
"VideosDirectory": "E:\\Azaion6", "VideosDirectory": "E:\\Azaion6",
+6 -4
View File
@@ -3,7 +3,7 @@ set CONFIG=%1
@echo off @echo off
set API_URL=https://api.azaion.com set API_URL=https://api.azaion.com
set RESOURCES_FOLDER=stage set RESOURCES_FOLDER=%2
set EMAIL=uploader@azaion.com set EMAIL=uploader@azaion.com
set PASSWORD=Az@1on_10Upl0@der set PASSWORD=Az@1on_10Upl0@der
@@ -28,14 +28,16 @@ for /f "tokens=2 delims=:" %%a in ('echo %RESPONSE% ^| findstr /i "token"') do (
:: Step 2: Upload the DLL file :: Step 2: Upload the DLL file
echo Uploading files to resources... set UPLOAD_URL=%API_URL%/resources/%RESOURCES_FOLDER%
curl --location %API_URL%/resources/%RESOURCES_FOLDER% ^ echo Uploading file %FILE1_TO_UPLOAD% to %UPLOAD_URL%...
curl --location %UPLOAD_URL% ^
-H "Authorization: Bearer %TOKEN%" ^ -H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: multipart/form-data" ^ -H "Content-Type: multipart/form-data" ^
--form "data=@%FILE1_TO_UPLOAD%" --form "data=@%FILE1_TO_UPLOAD%"
curl --location %API_URL%/resources/%RESOURCES_FOLDER% ^ echo Uploading file %FILE2_TO_UPLOAD% to %UPLOAD_URL%...
curl --location %UPLOAD_URL% ^
-H "Authorization: Bearer %TOKEN%" ^ -H "Authorization: Bearer %TOKEN%" ^
-H "Content-Type: multipart/form-data" ^ -H "Content-Type: multipart/form-data" ^
--form "data=@%FILE2_TO_UPLOAD%" --form "data=@%FILE2_TO_UPLOAD%"
@@ -1,3 +1,24 @@
@echo off
cd Azaion.Suite
echo Build .net app
dotnet build -c Release
call upload.cmd Release
echo Publish .net app
dotnet publish -r win-x64 -p:SatelliteResourceLanguages="en" -p:DebugSymbols=false -p:ForPublish=true --self-contained true
cd ..
rmdir dist /s /q
xcopy Azaion.Suite\bin\Release\net8.0-windows\win-x64\publish dist\ /s /e /q
mkdir dist\dummy
move dist\Azaion.Annotator.dll dist\dummy\
move dist\Azaion.Dataset.dll dist\dummy\
echo Build Cython app
cd Azaion.Inference\
call ".\venv\Scripts\activate.bat"
pyinstaller --onefile ^ pyinstaller --onefile ^
--collect-all jwt ^ --collect-all jwt ^
--collect-all requests ^ --collect-all requests ^
@@ -21,3 +42,4 @@ pyinstaller --onefile ^
--hidden-import inference ^ --hidden-import inference ^
--hidden-import remote_command_handler ^ --hidden-import remote_command_handler ^
start.py start.py
move dist\start.exe ..\dist\azaion-inference.exe