改进:在运行界面显示实际推理设备以识别 CPU 回退

This commit is contained in:
tfarcraw 2026-11-09 20:32:27 +08:00
parent 5b0a9ca263
commit 81b42a2d1b
3 changed files with 10 additions and 2 deletions

View File

@ -68,6 +68,7 @@
<TextBlock Text="帧率" Margin="16,0,6,0" />
<TextBlock Text="{Binding FpsText}" Foreground="{StaticResource FgDim}" />
</WrapPanel>
<TextBlock x:Name="InferenceBackend" Text="{Binding InferenceBackendText}" Margin="0,8,0,0" FontSize="12" TextWrapping="Wrap" Foreground="{StaticResource FgDim}" />
</StackPanel>
</Border>
<WrapPanel Grid.Row="1" Margin="0,10,0,0" HorizontalAlignment="Left">
@ -151,4 +152,4 @@
</StackPanel>
</Grid>
</Grid>
</UserControl>
</UserControl>

View File

@ -211,6 +211,9 @@ public class SopPageViewModel : ViewModelBase
set { SetProperty(ref _inferenceText, value); }
}
/// <summary>实际推理设备,CPU 回退时直接显示在运行界面。</summary>
public string InferenceBackendText => $"手部:{_pipeline.HandBackend};目标:{_pipeline.YoloBackend}";
/// <summary>是否运行中</summary>
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}");

View File

@ -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<TextBlock>().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<SopPage>().Single().GetVisualDescendants().OfType<TextBlock>().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<SopPage>().Single().GetVisualDescendants().OfType<TextBlock>().Any(t=>t.Text==selected),"Recipe selection changes notify the operator page immediately");