Files
better-genshin-impact/BetterGenshinImpact/Core/Config/HardwareAccelerationConfig.cs
Takaranoao 5b3bac478d 升级多个依赖&增加额外的推理加速功能&迁移OCR (#1459)
* 更新多个NuGet包至最新版本

* 重构模型加载以适应yolosharp

* feat: 改变接口。TensorRT缓存的初步支持,修改配置项。

* 更新依赖并调整变量顺序,修复加载问题

* 更新AvalonEdit和Microsoft.ML.OnnxRuntime包至最新版本,以修复问题

* fix: downgrade Microsoft.ML.OnnxRuntime.DirectML to version 1.21.0

* typo

* fix: change log level from warning to error for ONNX provider loading failure

* 增加 paddle ocr 的 onnx 模型

* feat: add PaddleOCR models for Chinese, English, and Latin recognition

* 使用cv的DNN生成Tensor,加速Yap文字识别

* feat: 尝试搓一个onnx的ocr

* clean up code

* chore: update OpenCvSharp4 package versions to 4.10.0.20241108

* 修复因格式化代码而丢的引用

* chore: update Microsoft.ML.OnnxRuntime.DirectML package to version 1.21.1 and improve logging for ONNX provider initialization

* chore: 等yolosharp更新再升级onnx

* chore: add Microsoft.ML.OnnxRuntime.Managed package and clean up logging in Det class

* fix: refactor output tensor handling in Det class for improved clarity

* 补充注释,修复DML的OCR问题

* 默认OCR推理使用CPU,整理配置

* fix error NETSDK1152: 找到了多个具有相同相对路径的发布输出文件

* fix(logging): enhance debug log for ONNX initialization with provider details

* 修复TensorRT模型缓存的加载问题

* fix(onnx): improve cached model retrieval and add file existence check

* fix(ocr): replace SrcGreyMat with SrcMat for region of interest processing

* fix(onnx): add file existence check for cached model and adjust session options for DirectML provider

* 增加硬件加速配置UI界面

* 移除旧的OCR模型

* 错别字

---------

Co-authored-by: 辉鸭蛋 <huiyadanli@gmail.com>
2025-05-11 01:08:37 +08:00

75 lines
2.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using BetterGenshinImpact.Core.Recognition.ONNX;
using CommunityToolkit.Mvvm.ComponentModel;
namespace BetterGenshinImpact.Core.Config;
[Serializable]
public partial class HardwareAccelerationConfig : ObservableObject
{
/// <summary>
/// 推理使用的设备。默认CPU
/// </summary>
[ObservableProperty]
private InferenceDeviceType _inferenceDevice = InferenceDeviceType.Cpu;
/// <summary>
/// 是否强制OCR使用CPU推理。在某些环境上使用GPU进行OCR推理会导致性能下降(比如很多使用DirectML推理的情况下)。默认开。
/// </summary>
[ObservableProperty]
private bool _cpuOcr = true;
#region GPU加速设置
/// <summary>
/// 强制指定gpu设备,默认为0(使用默认设备)
/// </summary>
[ObservableProperty]
private int _gpuDevice = 0;
/// <summary>
/// 附加path用;分割。默认为空。
/// </summary>
[ObservableProperty]
private string _additionalPath = "";
/// <summary>
/// 是否输出优化后的模型文件到缓存。注意:在不支持的执行器上使用会导致异常。默认关闭。
/// </summary>
[ObservableProperty]
private bool _optimizedModel = false;
#endregion
#region cuda设置
/// <summary>
/// 强制指定cuda设备,默认为0(使用默认设备)
/// </summary>
[ObservableProperty]
private int _cudaDevice = 0;
/// <summary>
/// 自动附加cuda的path。一般情况下用这个就足够了。默认开启。
/// </summary>
[ObservableProperty]
private bool _autoAppendCudaPath = true;
#endregion
#region TensorRT缓存设置
/// <summary>
/// 启用TensorRT缓存。默认开启。不开的话使用TensorRT每次加载模型会卡爆。
/// </summary>
[ObservableProperty]
private bool _enableTensorRtCache = true;
/// <summary>
/// 嵌入式引擎缓存。将引擎缓存嵌入到模型中。默认开启。关闭它可能会提高性能(如果不爆炸的话)。
/// </summary>
[ObservableProperty]
private bool _embedTensorRtCache = true;
#endregion
}