Files
CheckDevice/Check.Main/Infer/ModelSettings.cs
17860779768 2e46747ba9 视觉修改
2025-08-25 16:33:58 +08:00

132 lines
4.0 KiB
C#
Raw 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 Check.Main.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace Check.Main.Infer
{
public enum DetectDevice
{
[Description("CPU")]
CPU = 0,
[Description("GPU")]
GPU,
[Description("VPU")]
VPU,
}
public enum ModelVersion
{
[Description("v8")]
V8 = 0,
[Description("v11")]
V11,
}
public enum CheckModelType
{
[Description("分类")]
Classification,
[Description("检测")]
ObjectDetection,
[Description("OBB")]
ObbDetection,
[Description("分割")]
Segmentation,
[Description("位姿")]
PoseEstimation
}
[Serializable] // 确保可被XML序列化
public class ModelSettings : INotifyPropertyChanged, ICloneable
{
public event PropertyChangedEventHandler PropertyChanged;
private int _id;
private string _name = "New Model";
private string _path = "";
private DetectDevice _checkDevice=DetectDevice.CPU;
private ModelVersion _mVersion=ModelVersion.V8;
private CheckModelType _mType = CheckModelType.Classification;
private bool _isEnabled = true;
[Category("基本信息"), DisplayName("模型编号"), Description("模型的唯一标识符,用于与相机编号对应。")]
public int Id
{
get => _id;
set { if (_id != value) { _id = value; OnPropertyChanged(); } }
}
[Category("基本信息"), DisplayName("模型名称"), Description("给模型起一个易于识别的别名。")]
public string Name
{
get => _name;
set { if (_name != value) { _name = value; OnPropertyChanged(); } }
}
[Category("基本信息"), DisplayName("推理设备"), Description("推理模型的设备。")]
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public DetectDevice CheckDevice
{
get => _checkDevice;
set { if (_checkDevice != value) { _checkDevice = value; OnPropertyChanged(); } }
}
[Category("基本信息"), DisplayName("模型版本"), Description("推理模型的版本。")]
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public ModelVersion MVersion
{
get => _mVersion;
set { if (_mVersion != value) { _mVersion = value; OnPropertyChanged(); } }
}
[Category("基本信息"), DisplayName("模型类型"), Description("推理模型的类型。")]
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public CheckModelType MType
{
get => _mType;
set { if (_mType != value) { _mType = value; OnPropertyChanged(); } }
}
[Category("基本信息"), DisplayName("是否启用"), Description("是否在程序启动时是否启用模型")]
public bool IsEnabled
{
get => _isEnabled;
set
{
if (_isEnabled != value)
{
_isEnabled = value;
OnPropertyChanged();
}
}
}
[Category("文件"), DisplayName("模型路径"), Description("选择模型文件(.onnx, .bin, etc., .pt。")]
[Editor(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
public string Path
{
get => _path;
set { if (_path != value) { _path = value; OnPropertyChanged(); } }
}
protected void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public object Clone()
{
return this.MemberwiseClone(); // 浅克隆对于这个类足够了
}
}
}