mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:06:30 +00:00
stop inference on stop pressed
small fixes
This commit is contained in:
@@ -393,6 +393,7 @@ public partial class Annotator
|
||||
private void OnFormClosed(object? sender, EventArgs e)
|
||||
{
|
||||
MainCancellationSource.Cancel();
|
||||
_inferenceService.StopInference();
|
||||
DetectionCancellationSource.Cancel();
|
||||
_mediaPlayer.Stop();
|
||||
_mediaPlayer.Dispose();
|
||||
@@ -500,30 +501,30 @@ public partial class Annotator
|
||||
IsInferenceNow = true;
|
||||
FollowAI = true;
|
||||
DetectionCancellationSource = new CancellationTokenSource();
|
||||
var ct = DetectionCancellationSource.Token;
|
||||
var detectToken = DetectionCancellationSource.Token;
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
while (!ct.IsCancellationRequested)
|
||||
while (!detectToken.IsCancellationRequested)
|
||||
{
|
||||
var files = new List<string>();
|
||||
await Dispatcher.Invoke(async () =>
|
||||
{
|
||||
//Take not annotataed medias
|
||||
//Take all medias
|
||||
files = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?.Skip(LvFiles.SelectedIndex)
|
||||
.Where(x => !x.HasAnnotations)
|
||||
//.Where(x => !x.HasAnnotations)
|
||||
.Take(Constants.DETECTION_BATCH_SIZE)
|
||||
.Select(x => x.Path)
|
||||
.ToList() ?? [];
|
||||
if (files.Count != 0)
|
||||
{
|
||||
await _mediator.Publish(new AnnotatorControlEvent(PlaybackControlEnum.Play), ct);
|
||||
await _mediator.Publish(new AnnotatorControlEvent(PlaybackControlEnum.Play), detectToken);
|
||||
await ReloadAnnotations();
|
||||
}
|
||||
});
|
||||
if (files.Count == 0)
|
||||
break;
|
||||
|
||||
await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage, ct), ct);
|
||||
await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage, detectToken), detectToken);
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user