diff --git a/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml b/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml index b7685ff..16e8326 100644 --- a/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml +++ b/src/SopHelper.Avalonia/VVMs/SopPage/SopPage.axaml @@ -68,6 +68,7 @@ + @@ -151,4 +152,4 @@ - \ No newline at end of file + diff --git a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs index 7b72d6a..7954517 100644 --- a/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs +++ b/src/SopHelper.Avalonia/VVMs/SopPage/SopPageViewModel.cs @@ -211,6 +211,9 @@ public class SopPageViewModel : ViewModelBase set { SetProperty(ref _inferenceText, value); } } + /// 实际推理设备,CPU 回退时直接显示在运行界面。 + public string InferenceBackendText => $"手部:{_pipeline.HandBackend};目标:{_pipeline.YoloBackend}"; + /// 是否运行中 public bool IsRunning { @@ -637,7 +640,8 @@ public class SopPageViewModel : ViewModelBase RequireGpu = OperatingSystem.IsLinux(), }; - _pipeline.LoadModels(options); + try { _pipeline.LoadModels(options); } + finally { RaisePropertyChanged(nameof(InferenceBackendText)); } ActiveRecipe = SelectedRecipe; Log("info", $"推理设备:手部={_pipeline.HandBackend},YOLO={_pipeline.YoloBackend}"); diff --git a/tests/Avalonia.Smoke/Program.cs b/tests/Avalonia.Smoke/Program.cs index e989ee8..a295440 100644 --- a/tests/Avalonia.Smoke/Program.cs +++ b/tests/Avalonia.Smoke/Program.cs @@ -83,6 +83,9 @@ internal static class Smoke sop.SelectedRecipe="pending.yaml"; Check(sop.ActiveRecipe==applied,"Unapplied recipe selection does not change current recipe"); navigation.SelectedIndex=0;await Task.Delay(80); + Check(window.GetVisualDescendants().OfType().Any(t=>t.Name=="InferenceBackend"&&t.Text==sop.InferenceBackendText) + &&sop.InferenceBackendText.Contains("手部:")&&sop.InferenceBackendText.Contains("目标:"), + "Operator page displays the actual inference backends, including CPU fallback"); Check(window.GetVisualDescendants().OfType().Single().GetVisualDescendants().OfType().Any(t=>t.Text=="pending.yaml"),"Operator page updates to the selected recipe without applying or starting"); sop.SelectedRecipe=selected;await Task.Delay(80); Check(window.GetVisualDescendants().OfType().Single().GetVisualDescendants().OfType().Any(t=>t.Text==selected),"Recipe selection changes notify the operator page immediately");