modify device name

This commit is contained in:
辉鸭蛋
2024-05-28 19:08:28 +08:00
parent 889955389b
commit 94c8c6a842
7 changed files with 42 additions and 26 deletions

View File

@@ -43,7 +43,6 @@
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.77" />
<PackageReference Include="MouseKeyHook" Version="5.7.1" />
<PackageReference Include="Sdcb.PaddleInference" Version="2.5.0.1" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.cuda118_cudnn86_tr85_sm86_89" Version="2.5.1" />
<PackageReference Include="Sdcb.PaddleInference.runtime.win64.openblas" Version="2.5.1" />
<PackageReference Include="Sdcb.PaddleOCR" Version="2.7.0" />
<PackageReference Include="Sdcb.PaddleOCR.Models.Online" Version="2.7.0.1" />
@@ -55,7 +54,7 @@
<PackageReference Include="Vanara.PInvoke.User32" Version="3.4.17" />
<PackageReference Include="WPF-UI" Version="3.0.0-preview.7" />
<PackageReference Include="WPF-UI.Tray" Version="3.0.0-preview.7" />
<PackageReference Include="YoloV8.Gpu" Version="2.0.1" />
<PackageReference Include="YoloV8" Version="2.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">

View File

@@ -30,13 +30,13 @@ public class PaddleOcrService : IOcrService
var localClsModel = ClassificationModel.FromDirectory(Path.Combine(path, "ch_ppocr_mobile_v2.0_cls"));
var localRecModel = RecognizationModel.FromDirectory(Path.Combine(path, "ch_PP-OCRv4_rec"), Path.Combine(path, "ppocr_keys_v1.txt"), ModelVersion.V4);
var model = new FullOcrModel(localDetModel, localClsModel, localRecModel);
Action<PaddleConfig> device = TaskContext.Instance().Config.InferenceDevice switch
{
"CPU" => PaddleDevice.Onnx(),
"GPU" => PaddleDevice.Onnx(),
_ => throw new InvalidEnumArgumentException("无效的推理设备")
};
_paddleOcrAll = new PaddleOcrAll(model, device)
// Action<PaddleConfig> device = TaskContext.Instance().Config.InferenceDevice switch
// {
// "CPU" => PaddleDevice.Onnx(),
// "GPU_DirectML" => PaddleDevice.Onnx(),
// _ => throw new InvalidEnumArgumentException("无效的推理设备")
// };
_paddleOcrAll = new PaddleOcrAll(model, PaddleDevice.Onnx())
{
AllowRotateDetection = false, /* 允许识别有角度的文字 */
Enable180Classification = false /* 允许识别旋转角度大于90度的文字 */

View File

@@ -7,10 +7,12 @@ namespace BetterGenshinImpact.Core.Recognition.ONNX;
public class BgiSessionOption : Singleton<BgiSessionOption>
{
public static string[] InferenceDeviceTypes { get; } = ["CPU", "GPU_DirectML"];
public SessionOptions Options { get; set; } = TaskContext.Instance().Config.InferenceDevice switch
{
"CPU" => new SessionOptions(),
"GPU" => MakeSessionOptionWithDirectMlProvider(),
"GPU_DirectML" => MakeSessionOptionWithDirectMlProvider(),
_ => throw new InvalidEnumArgumentException("无效的推理设备")
};
@@ -20,4 +22,14 @@ public class BgiSessionOption : Singleton<BgiSessionOption>
sessionOptions.AppendExecutionProvider_DML(0);
return sessionOptions;
}
// /// <summary>
// /// 重新加载每个推理器(测试没用,只能重启)
// /// </summary>
// public void RefreshInference()
// {
// // 自动秘境每次都会NEW不用管
// // Yap、自动钓鱼
// GameTaskManager.RefreshTriggerConfigs();
// }
}

View File

@@ -56,17 +56,10 @@ internal class GameTaskManager
{
if (TriggerDictionary is { Count: > 0 })
{
TriggerDictionary["AutoPick"].IsEnabled = TaskContext.Instance().Config.AutoPickConfig.Enabled;
// 用于刷新AutoPick的黑白名单
TriggerDictionary["AutoPick"].Init();
TriggerDictionary["AutoSkip"].IsEnabled = TaskContext.Instance().Config.AutoSkipConfig.Enabled;
TriggerDictionary["AutoFishing"].IsEnabled = TaskContext.Instance().Config.AutoFishingConfig.Enabled;
// 钓鱼有很多变量要初始化直接重新newZA
if (TriggerDictionary["AutoFishing"].IsEnabled == false)
{
TriggerDictionary["AutoFishing"].Init();
}
TriggerDictionary["QuickTeleport"].IsEnabled = TaskContext.Instance().Config.QuickTeleportConfig.Enabled;
TriggerDictionary["AutoSkip"].Init();
TriggerDictionary["AutoFishing"].Init();
TriggerDictionary["QuickTeleport"].Init();
TriggerDictionary["GameLoading"].Init();
TriggerDictionary["AutoCook"].Init();
// 清理画布

View File

@@ -1,5 +1,4 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System;
using System.Threading;
namespace BetterGenshinImpact.Model;

View File

@@ -211,14 +211,20 @@
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="GPU推理需要安装CUDA切换后需要重启程序"
Text="切换后需要重启程序生效"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
ItemsSource="{Binding InferenceDevices}"
SelectedItem="{Binding Config.InferenceDevice, Mode=TwoWay}" />
ItemsSource="{Binding InferenceDeviceTypes}"
SelectedItem="{Binding Config.InferenceDevice, Mode=TwoWay}">
<b:Interaction.Triggers>
<b:EventTrigger EventName="SelectionChanged">
<b:InvokeCommandAction Command="{Binding InferenceDeviceTypeDropDownChangedCommand}" CommandParameter="{Binding Config.InferenceDevice}" />
</b:EventTrigger>
</b:Interaction.Triggers>
</ComboBox>
</Grid>
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
<Grid Margin="16">

View File

@@ -1,5 +1,6 @@
using BetterGenshinImpact.Core;
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Recognition.ONNX;
using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.Genshin.Paths;
using BetterGenshinImpact.Helpers;
@@ -48,7 +49,8 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
// 记录上次使用原神的句柄
private IntPtr _hWnd;
[ObservableProperty] private string[] _inferenceDevices = ["CPU", "GPU"];
[ObservableProperty]
private string[] _inferenceDeviceTypes = BgiSessionOption.InferenceDeviceTypes;
public HomePageViewModel(IConfigService configService, TaskTriggerDispatcher taskTriggerDispatcher)
{
@@ -117,6 +119,11 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
}
}
[RelayCommand]
private void OnInferenceDeviceTypeDropDownChanged(string value)
{
}
[RelayCommand]
private void OnStartCaptureTest()
{