123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using AI.Common;
- using AI.Common.InferenceNetworks;
- using Microsoft.ML.OnnxRuntime;
- using System.Collections.Generic;
- namespace NerveIdentificationLib
- {
- /// <summary>
- /// 分割神经
- /// </summary>
- public class InferNetOnnxNerveSeg: InferNetOnnxSemanticSegBasic
- {
- #region override
- /// <summary>
- /// 哈希值
- /// </summary>
- public override string HashCode => "283f7ec736b2570d9a09fc79264d76f7";
- /// <summary>
- /// 网络名
- /// </summary>
- public override string NetworkName => "Nerve-ContourSeg.emd";
- /// <summary>
- /// 后处理
- /// </summary>
- /// <param name="image"></param>
- /// <returns></returns>
- public override IDetectedObject[] PostProcess(InferenceNetworkInputImage image)
- {
- // 调用基类的Process
- var results = base.PostProcess(image);
- return results;
- }
- /// <summary>
- /// 复制
- /// </summary>
- /// <param name="cloneMethod"></param>
- /// <returns></returns>
- public override IInferenceNetwork Clone(EnumCloneMethod cloneMethod)
- {
- if (!_modelLoaded)
- {
- return new InferNetOnnxNerveSeg();
- }
- return new InferNetOnnxNerveSeg(_trainedModel, _sessionOption);
- }
- #endregion
- #region constructor
- public InferNetOnnxNerveSeg()
- {
- ModelParamsAssign();
- ConstructIntermediateVariables();
- }
- public InferNetOnnxNerveSeg(byte[] trainedModel, SessionOptions sessionOption)
- {
- ModelParamsAssign();
- ConstructIntermediateVariables();
- ConstructClonedModelRelatedVariables(trainedModel, sessionOption);
- }
- #endregion
- #region private funcs
- private void ModelParamsAssign()
- {
- _inputVariableName = "input.1";
- _inputAxisOrder = EnumAxisOrder.CHW;
- _modelInputC = 3;
- _modelInputH = 256;
- _modelInputW = 256;
- _outputVariableName = "755";
- _outputAxisOrder = EnumAxisOrder.CHW;
- _modelOutputC = 4;
- _modelOutputH = 256;
- _modelOutputW = 256;
- _resizeMode = EnumResizeMode.Warp;
- _meanValueType = EnumMeanValueType.None;
- _scaleType = EnumScaleValueType.ConstantScale;
- _scaleR = 255;
- _scaleG = 255;
- _scaleB = 255;
- _normType = EnumNormalizationType.None;
- _reverseInputChannels = true;
- _segPostProcessParam = new Dictionary<int, SemanticSegmentationPostProcessParams>
- {
- // 神经
- { 1, new SemanticSegmentationPostProcessParams(new List<LesionAreaSelectInfo>(){new LesionAreaSelectInfo(EnumLesionAreaThresholdType.RatioInMask, 1.0f/100, 1.0f)}, 5)},
- // 动脉
- { 2, new SemanticSegmentationPostProcessParams(new List<LesionAreaSelectInfo>(){new LesionAreaSelectInfo(EnumLesionAreaThresholdType.RatioInMask, 1.0f/100, 1.0f)}, 2)},
- // 静脉
- { 3, new SemanticSegmentationPostProcessParams(new List<LesionAreaSelectInfo>(){new LesionAreaSelectInfo(EnumLesionAreaThresholdType.RatioInMask, 1.0f/100, 1.0f)}, 2)},
- };
- }
- #endregion
- }
- }
|