Compare commits

..
Author SHA1 Message Date
辉鸭蛋 fe2fd5d67c fix merge 2024-05-28 18:02:56 +08:00
9 changed files with 31 additions and 56 deletions

No files matched your search

@@ -35,7 +35,7 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.DirectML" Version="1.17.1" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.Gpu" Version="1.17.1" />
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="1.17.1" />
<PackageReference Include="Ookii.Dialogs.Wpf" Version="5.0.1" />
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.8.0.20230708" />
@@ -43,6 +43,7 @@
<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" />
@@ -54,7 +55,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" Version="2.0.1" />
<PackageReference Include="YoloV8.Gpu" Version="2.0.1" />
</ItemGroup>
<ItemGroup Condition=" '$(Configuration)' == 'Debug'">
@@ -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_DirectML" => PaddleDevice.Onnx(),
// _ => throw new InvalidEnumArgumentException("无效的推理设备")
// };
_paddleOcrAll = new PaddleOcrAll(model, PaddleDevice.Onnx())
Action<PaddleConfig> device = TaskContext.Instance().Config.InferenceDevice switch
{
"CPU" => PaddleDevice.Onnx(),
"GPU" => PaddleDevice.Gpu(),
_ => throw new InvalidEnumArgumentException("无效的推理设备")
};
_paddleOcrAll = new PaddleOcrAll(model, device)
{
AllowRotateDetection = false, /* 允许识别有角度的文字 */
Enable180Classification = false /* 允许识别旋转角度大于90度的文字 */
@@ -7,29 +7,10 @@ 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_DirectML" => MakeSessionOptionWithDirectMlProvider(),
"GPU" => SessionOptions.MakeSessionOptionWithCudaProvider(),
_ => throw new InvalidEnumArgumentException("无效的推理设备")
};
public static SessionOptions MakeSessionOptionWithDirectMlProvider()
{
var sessionOptions = new SessionOptions();
sessionOptions.AppendExecutionProvider_DML(0);
return sessionOptions;
}
// /// <summary>
// /// 重新加载每个推理器(测试没用,只能重启)
// /// </summary>
// public void RefreshInference()
// {
// // 自动秘境每次都会NEW不用管
// // Yap、自动钓鱼
// GameTaskManager.RefreshTriggerConfigs();
// }
}
@@ -9,7 +9,6 @@ using BetterGenshinImpact.GameTask.AutoFight.Script;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
using BetterGenshinImpact.GameTask.AutoPick.Assets;
using BetterGenshinImpact.GameTask.Common.Map;
using BetterGenshinImpact.GameTask.Model.Area;
using BetterGenshinImpact.GameTask.Model.Enum;
using BetterGenshinImpact.Helpers;
using BetterGenshinImpact.Service.Notification;
@@ -25,8 +24,10 @@ using System.Drawing.Imaging;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.Model.Area;
using static BetterGenshinImpact.GameTask.Common.TaskControl;
using static Vanara.PInvoke.User32;
using System.Windows.Media.Media3D;
namespace BetterGenshinImpact.GameTask.AutoDomain;
@@ -47,9 +48,7 @@ public class AutoDomainTask
_taskParam = taskParam;
_simulator = AutoFightContext.Instance.Simulator;
_predictor = new YoloV8(Global.Absolute("Assets\\Model\\Domain\\bgi_tree.onnx"), BgiSessionOption.Instance.Options);
_config = TaskContext.Instance().Config.AutoDomainConfig;
_predictor = new(Global.Absolute("Assets\\Model\\Domain\\bgi_tree.onnx"), BgiSessionOption.Instance.Options);
_combatScriptBag = CombatScriptParser.ReadAndParse(_taskParam.CombatStrategyPath);
}
@@ -18,7 +18,6 @@ using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Threading;
using BetterGenshinImpact.Core.Recognition.ONNX;
using BetterGenshinImpact.GameTask.Model.Area;
using static BetterGenshinImpact.GameTask.Common.TaskControl;
@@ -38,7 +37,7 @@ public class CombatScenes : IDisposable
public int AvatarCount { get; set; }
private readonly YoloV8 _predictor = new(Global.Absolute("Assets\\Model\\Common\\avatar_side_classify_sim.onnx"), BgiSessionOption.Instance.Options);
private readonly YoloV8 _predictor = new(Global.Absolute("Assets\\Model\\Common\\avatar_side_classify_sim.onnx"));
/// <summary>
/// 通过YOLO分类器识别队伍内角色
@@ -56,10 +56,17 @@ internal class GameTaskManager
{
if (TriggerDictionary is { Count: > 0 })
{
TriggerDictionary["AutoPick"].IsEnabled = TaskContext.Instance().Config.AutoPickConfig.Enabled;
// 用于刷新AutoPick的黑白名单
TriggerDictionary["AutoPick"].Init();
TriggerDictionary["AutoSkip"].Init();
TriggerDictionary["AutoFishing"].Init();
TriggerDictionary["QuickTeleport"].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["GameLoading"].Init();
TriggerDictionary["AutoCook"].Init();
// 清理画布
+2 -1
View File
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading;
namespace BetterGenshinImpact.Model;
+3 -9
View File
@@ -211,20 +211,14 @@
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="切换后需要重启程序生效"
Text="GPU推理需要安装CUDA,切换后需要重启程序"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
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>
ItemsSource="{Binding InferenceDevices}"
SelectedItem="{Binding Config.InferenceDevice, Mode=TwoWay}" />
</Grid>
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
<Grid Margin="16">
@@ -1,6 +1,5 @@
using BetterGenshinImpact.Core;
using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Recognition.ONNX;
using BetterGenshinImpact.GameTask;
using BetterGenshinImpact.Genshin.Paths;
using BetterGenshinImpact.Helpers;
@@ -49,8 +48,7 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
// 记录上次使用原神的句柄
private IntPtr _hWnd;
[ObservableProperty]
private string[] _inferenceDeviceTypes = BgiSessionOption.InferenceDeviceTypes;
[ObservableProperty] private string[] _inferenceDevices = ["CPU", "GPU"];
public HomePageViewModel(IConfigService configService, TaskTriggerDispatcher taskTriggerDispatcher)
{
@@ -119,11 +117,6 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
}
}
[RelayCommand]
private void OnInferenceDeviceTypeDropDownChanged(string value)
{
}
[RelayCommand]
private void OnStartCaptureTest()
{