AI 공통 설정
1 개요
- 모든 Model에 대해 공통적으로 설정하는 기능들에 대한 설명입니다.
2 필수 옵션
2.1 Image 설정
2.1.1 개요
- 딥러닝에 사용할 이미지를 설정합니다.
- Validation Image 미 설정 시 Validation 없이 동작합니다.
- Inference Result 이미지를 설정하여야 해당 이미지에서 추론 결과를 얻을 수 있습니다.
2.1.2 API
- Learn Image 설정
SetLearningImage(const Base::CFLImage&)
SetLearningImage(const Base::CFLImage*)
- Validation Image 설정
SetLearningValidationImage(const Base::CFLImage&)
SetLearningValidationImage(const Base::CFLImage*)
- Inference Image 설정
SetInferenceImage(const Base::CFLImage&)
SetInferenceImage(const Base::CFLImage*)
- Inference Result Image 설정
SetInferenceResultImage(Base::CFLImage&)
SetInferenceResultImage(Base::CFLImage*)
2.1.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
CFLImage fliLearnImage;
CFLImage fliValidationImage;
CFLImage fliInferenceImage;
CFLImage fliInferenceResultImage;
fliLearnImage.Load(L"Learn.flif");
fliValidationImage.Load(L"Validation.flif");
fliInferenceImage.Load(L"Inference.flif");
// fliInferenceResultImage 는 결과를 받아오는 이미지 객체
semanticSegmentationDL.SetLearningImage(fliLearnImage);
semanticSegmentationDL.SetLearningValidationImage(fliValidationImage);
semanticSegmentationDL.SetInferenceImage(fliInferenceImage);
semanticSegmentationDL.SetInferenceResultImage(fliInferenceResultImage);
2.1.4 GUI에서 설정 방법
- 학습/검증/추론할 이미지를 Image View에 로드합니다.

Fig. Dialog 창에서 출력되는 학습 결과 정보
- 각 동작에 사용할 이미지가 있는 뷰를 선택합니다. 또는 학습/검증 이미지는 Load Image With Path 옵션으로 해당 이미지가 있는 경로를 지정하여 설정할 수 있습니다.

Fig. Dialog 창에서 출력되는 학습 결과 정보
2.2 Optimizer 설정
2.2.1 개요
- 학습에 사용할 Optimizer를 선택합니다.
- 다양한 Optimizer를 지원하며, 기본값은 Adam Optimizer를 사용합니다.
- 별도의 설정을 하지 않더라도 기본값으로 사용 가능합니다.
- OptimizerSpec 클래스를 통해 파라미터를 설정합니다.
- Learning Rate 및 Optimizer 종류에 따라 Beta 값 등을 설정합니다.
- Spec 클래스는 Optimizer의 종류마다 개별적으로 구현되어 있습니다.
- Gradient Descent
- Stochastic Gradient Descent
- Ada Gradient Descent
- Momentum Gradient Descent
- RMS Prop Gradient Descent
- Adam Gradient Descent
- Ada Belief Gradient Descent
- Gradient Clipping 적용 여부를 선택합니다.
- 모델에 따라 학습을 진행하면 미분값이 매우 커지거나, 작아지는 가능성이 존재합니다.
- Gradient clipping은 이러한 현상을 방지하기 위해 gradient가 일정 threshold를 넘어가면 gradient의 크기를 재조정합니다.
2.2.2 API
SetLearningOptimizerSpec(const COptimizerSpecBase&)
SetLearningOptimizerSpec(const COptimizerSpecBase*)
2.2.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
// 일반적으로 설정할 필요 없음
COptimizerSpecAdamGradientDescent optSpec;
optSpec.SetLearningRate(1e-3f);
optSpec.SetBeta1(0.99f);
optSpec.EnableAutoSubdivision(false);
semanticSegmentationDL.EnableLearningGradientClipping(true);
semanticSegmentationDL.SetLearningGradientClippingThreshold(20.f);
semanticSegmentationDL.SetLearningOptimizerSpec(optSpec);
2.2.4 GUI에서 설정 방법

Fig. Optimizer 종류 선택

Fig. Optimizer 관련 세부 parameter 설정
2.3 Learning 정보 설정
2.3.1 Learning Epoch 설정
2.3.1.1 개요
- 학습을 반복할 횟수를 설정합니다.
2.3.1.2 API
SetLearningEpoch(int32_t)
2.3.1.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.SetLearningEpoch(10000);
2.3.1.4 GUI에서 설정 방법

Fig. Epoch 설정
2.3.2 Validation Step 설정
2.3.2.1 개요
- 학습 중 특정 Epoch 마다 Validation을 진행하도록 설정합니다.
- 기본값은 1이며, 매 Epoch 마다 Validation합니다.
- 0인 경우 Validation을 하지 않습니다.
- 1보다 큰 경우 설정한 Epoch 단위 마다 Validation을 진행하며, 마지막 Epoch에는 항상 Validation 합니다.
2.3.2.2 API
SetLearningValidationStep(int32_t)
2.3.2.3 예제 코드
CFLImage fliValidationImage;
CSemanticSegmentationDL semanticSegmentationDL;
fliValidationImage.Load(L"Validation.flif");
semanticSegmentationDL.SetLearningValidationImage(fliValidationImage);
semanticSegmentationDL.SetLearningValidationStep(3);
2.3.2.4 GUI에서 설정 방법

Fig. Validation Step 설정
2.4 Augmentation 설정
2.4.1 개요
- 학습 이미지를 다양한 방법으로 증강시켜, 학습 dataset의 규모를 늘리는 기법입니다. Augmentation을 사용하여 overfitting을 줄일 수 있습니다.
- 기본값은 설정되어 있지 않습니다.
- 특정 Augmentation 기법은 모델에 따라 사용이 제한되어 있습니다.
- 기본적으로 Enable~ 함수로 각각의 Augmentation 기법들을 활성화할 수 있습니다.
- 추가적인 Parameter가 필요한 기법들은 Set~Param 함수를 사용하여 Augmentation에 필요한 값들을 설정합니다.
2.4.2 API
-
Common Parameter 관련
EnableAugmentation(bool)
: true가 기본값이며, false로 설정 시 모든 옵션 비활성화됩니다.SetCommonActivationRate(double)
: 설정한 비율만큼 Augmentation 동작을 활성화합니다.SetCommonIoUThreshold(double)
: Rotation, CutMix와 같이 Label Figure의 넓이가 연산 후 너무 많이 제거된 경우 설정한 Threshold 비율로 제거합니다. Augmentation IoU Threshold는 Augmentation으로 인해 라벨링된 부분이 짤릴 경우 라벨링을 보존 여부를 정하는 임곗 값입니다. 0.0 ~ 1.0의 범위를 가지며 0.8을 설정할 경우 원래의 영역의 80%가 넘게 남아있지 않은 경우 라벨을 제거합니다.SetCommonInterpolationMethod(ImageProcessing::EInterpolationMethod)
: Rotation, Scale, Perspective과 같은 Augmentation 기법에서 사용할 Interpolation 방법을 설정합니다.
- 각각의 Augmentation 방식 관련
-
Mix Method
EnableMixMethod(bool)
SetMixMethodParam(EMixMethod eMixMethod = EMixMethod_None, double f64MixActivationRate = 1.)
eMixMethod
: 사용할 Mix 방식f64MixActivationRate
: 전체 데이터에 대해 Mix 방식을 적용하는 데이터의 비율
- MixUp
SetMixUpParam(double f64MinMixUpBlendRatio = 4., double f64MaxMixUpBlendRatio = .6)
f64MinMixUpBlendRatio
: MixUp 최소 Blend 비율f64MaxMixUpBlendRatio
: MixUp 최대 Blend 비율
- Mosaic
- 별도의 Parameter 설정이 없음
- CutMix
SetCutMixParam(double f64MinCutMixRatioX = 0.1, double f64MaxCutMixRatioX = .4, double f64MinCutMixRatioY = 0.1, double f64MaxCutMixRatioY = .4, double f64MinCutMixBlendRatio = 0., double f64MaxCutMixBlendRatio = .0)
f64MinCutMixRatioX
: X방향으로의 CutMix 최소 비율f64MaxCutMixRatioX
: X방향으로의 CutMix 최대 비율f64MinCutMixRatioY
: Y방향으로의 CutMix 최소 비율f64MaxCutMixRatioY
: Y방향으로의 CutMix 최대 비율f64MinCutMixBlendRatio
: CutMix 최소 Blend 비율f64MaxCutMixBlendRatio
: CutMix 최대 Blend 비율
- ObjectMix
SetObjectMixParam(double f64MinTranslationRatioX = -0.1, double f64MaxTranslationRatioX = 0.1, double f64MinTranslationRatioY = -0.1, double f64MaxTranslationRatioY = 0.1, double f64MinObjectMixScaleRatioX = 00.8, double f64MaxObjectMixScaleRatioX = 1.25, double f64MinObjectMixScaleRatioY = 00.8, double f64MaxObjectMixScaleRatioY = 1.25, bool bObjectMixPreservingScaleRatio = true, double f64MinObjectMixRotation = -5., double f64MaxObjectMixRotation = .5, bool bObjectMixHorizontalFlip = false, bool bObjectMixVerticalFlip = false, int64_t i64MinObjectMixCount = 1, int64_t i64MaxObjectMixCount = 2)
f64MinTranslationRatioX
: X방향으로의 ObjectMix 최소 옮기는 비율f64MaxTranslationRatioX
: X방향으로의 ObjectMix 최대 옮기는 비율f64MinTranslationRatioY
: Y방향으로의 ObjectMix 최소 옮기는 비율f64MaxTranslationRatioY
: Y방향으로의 ObjectMix 최대 옮기는 비율f64MinObjectMixScaleRatioX
: X방향으로의 ObjectMix 최소 확장 비율f64MaxObjectMixScaleRatioX
: X방향으로의 ObjectMix 최대 확장 비율f64MinObjectMixScaleRatioY
: Y방향으로의 ObjectMix 최소 확장 비율f64MaxObjectMixScaleRatioY
: Y방향으로의 ObjectMix 최대 확장 비율bObjectMixPreservingScaleRatio
: ObjectMix 최대 확장 비율f64MinObjectMixRotation
: ObjectMix 최소 회전 비율f64MaxObjectMixRotation
: ObjectMix 최대 회전 비율bObjectMixHorizontalFlip
: ObjectMix 좌우 반전bObjectMixVerticalFlip
: ObjectMix 상하 반전i64MinObjectMixCount
: ObjectMix 최소 개수i64MaxObjectMixCount
: ObjectMix 최대 개수수
-
Resized Crop
EnableResizedCrop(bool)
SetResizedCropParam(double f64MinResizedCropScaleRatio = .8, double f64MaxResizedCropScaleRatio = 1.0, double f64MinResizedCropAspectRatio = 0.8, double f64MaxResizedCropAspectRatio = 1.25, double f64ResizedCropActivationRate = 1.)
f64MinResizedCropScaleRatio
: Resized 되기 전 Crop 되어질 영역의 면적의 스케일 최소 비율f64MaxResizedCropScaleRatio
: Resized 되기 전 Crop 되어질 영역의 면적의 스케일 최대 비율f64MinResizedCropAspectRatio
: Resized 되기 전 Crop 되어질 영역의 최소 종횡비 비율f64MaxResizedCropAspectRatio
: Resized 되기 전 Crop 되어질 영역의 최대 종횡비 비율f64ResizedCropActivationRate
: Batch 마다 적용되는 ResizedCrop 활성화 비율
-
Horizontal Flip
EnableHorizontalFlip(bool)
SetHorizontalFlipParam(double f64HorizontalFlipActivationRate = 1.)
f64HorizontalFlipActivationRate
: Batch 마다 적용되는 수평 반전 활성화 비율
-
Vertical Flip
EnableVerticalFlip(bool)
SetVerticalFlipParam(double f64VerticalFlipActivationRate = 1.)
f64VerticalFlipActivationRate
: Batch 마다 적용되는 수직 반전 활성화 비율
-
Adjustment
EnableAdjustment(bool)
SetAdjustmentParam(double f64MinAdjustmentBrightness = 0.8, double f64MaxAdjustmentBrightness = 1.25, double f64MinAdjustmentContrast = 0.8, double f64MaxAdjustmentContrast = 1.25, double f64AdjustmentActivationRate = 1.)
f64MinAdjustmentBrightness
: 최소 밝기f64MaxAdjustmentBrightness
: 최대 밝기f64MinAdjustmentContrast
: 최소 대비f64MaxAdjustmentContrast
: 최대 대비f64AdjustmentActivationRate
: Batch 마다 적용되는 Adjustment 활성화 비율
-
Intensity
EnableIntensity(bool)
SetIntensityParam(double f64MinSaturation = 0.8, double f64MaxSaturation = 1.25, double f64MinExposure = 0.8, double f64MaxExposure = 1.25, double f64MinHue = -.03, double f64MaxHue = .03, double f64IntensityActivationRate = 1.)
f64MinSaturation
: S 최소 값f64MaxSaturation
: S 최대 값f64MinExposure
: V 최소 값f64MaxExposure
: V 최대 값f64MinHue
: H 최소 값f64MaxHue
: H 최대 값f64IntensityActivationRate
: Batch 마다 적용되는 Intensity 활성화 비율
-
Gradation
EnableGradation(bool)
SetGradationParam(double f64GradationMinAlpha = 0., double f64GradationMaxAlpha = .5, double f64GradationActivationRate = 1.)
f64GradationMinAlpha
: 최소 밝기 변화율f64GradationMaxAlpha
: 최대 밝기 변화율f64GradationActivationRate
: Batch 마다 적용되는 Gradation 활성화 비율
-
Emphasize
EnableEmphasize(bool)
SetEmphasizeParam(int64_t i64MinimumKernelSize = 1, int64_t i64MaximumKernelSize = 3, double f64MinimumFactor = 0., double f64MaximumFactor = 1., double f64EmphasizeActivationRate = 1.)
i64MinimumKernelSize
: 최소 필터 사이즈 크기i64MaximumKernelSize
: 최대 필터 사이즈 크기f64MinimumFactor
: 최소 Factorf64MaximumFactor
: 최대 Factorf64EmphasizeActivationRate
: Batch 마다 적용되는 Emphasize 활성화 비율
-
Gaussian Blur
EnableGaussianBlur(bool)
SetGaussianBlurParam(int64_t i64MinKernelSize = 1, int64_t i64MaxKernelSize = 3, double f64GaussianBlurActivationRate = 1.)
i64MinKernelSize
: 최소 필터 크기i64MaxKernelSize
: 최대 필터 크기f64GaussianBlurActivationRate
: Batch 마다 적용되는 Gaussian Blur 활성화 비율
-
Gaussian Noise
EnableGaussianNoise(bool)
SetGaussianNoiseParam(double f64MinMean = 0., double f64MaxMean = 0., double f64MinStdev = 0., double f64MaxStdev = .04, double f64GaussianNoiseActivationRate = 1.)
f64MinMean
: 가우시안 분포의 최소 평균f64MaxMean
: 가우시안 분포의 최대 평균f64MinStdev
: 가우시안 분포의 최소 표준 편차f64MaxStdev
: 가우시안 분포의 최대 표준 편차f64GaussianNoiseActivationRate
: Batch 마다 적용되는 Gaussian Noise 활성화 비율
-
Alpha Blend Mask
EnableAlphaBlendMask(bool)
SetAlphaBlendMaskParam(double f64MinAlphaBlendMaskRatioX = 0.05, double f64MaxAlphaBlendMaskRatioX = .1, double f64MinAlphaBlendMaskRatioY = 0.05, double f64MaxAlphaBlendMaskRatioY = .1, double f64MinAlphaBlendMaskValue = 0., double f64MaxAlphaBlendMaskValue = 1., double f64MinAlphaBlendMaskBlendRatio = 0.6, double f64MaxAlphaBlendMaskBlendRatio = 1., double f64AlphaBlendMaskActivationRate = .5, int64_t i64MinAlphaBlendMaskCount = 1, int64_t i64MaxAlphaBlendMaskCount = 2)
f64MinAlphaBlendMaskRatioX
: X 방향 최소 섞는 범위 *f64MaxAlphaBlendMaskRatioX
: X 방향 최대 섞는 범위 *f64MinAlphaBlendMaskRatioY
: Y 방향 최소 섞는 범위 *f64MaxAlphaBlendMaskRatioY
: Y 방향 최대 섞는 범위 *f64MinAlphaBlendMaskValue
: 섞는 최소 값 *f64MaxAlphaBlendMaskValue
: 섞는 최대 값 *f64MinAlphaBlendMaskBlendRatio
: 최소 섞는 비율 *f64MaxAlphaBlendMaskBlendRatio
: 최대 섞는 비율 *f64AlphaBlendMaskActivationRate
: 섞는 활성화 비율 *i64MinAlphaBlendMaskCount
: 최소 섞는 개수 *i64MaxAlphaBlendMaskCount
: 최대 섞는 개수
-
Perspective
EnablePerspective(bool)
SetPerspectiveParam(double f64MinPerspectiveRatio = .0, double f64MaxPerspectiveRatio = .1, double f64PerspectiveActivationRate = 1.)
f64MinPerspectiveRatio
: Projection quad 점 4개의 대한 최소 변형 비율f64MaxPerspectiveRatio
: Projection quad 점 4개의 대한 최대 변형 비율f64PerspectiveActivationRate
: Batch 마다 적용되는 Perspective 활성화 비율
-
Quarter Rotation
EnableQuarterRotation(bool)
SetQuarterRotationParam(bool bAngle0 = true, bool bAngle90 = true, bool bAngle180 = true, bool bAngle270 = true, double f64QuarterRotationActivationRate = 1.)
bAngle0
: 0도 회전 사용 여부bAngle90
: 90도 회전 사용 여부bAngle180
: 180도 회전 사용 여부bAngle270
: 270도 회전 사용 여부f64QuarterRotationActivationRate
: Batch 마다 적용되는 Quarter Rotation 활성화 비율
-
Rotation
EnableRotation(bool)
SetRotationParam(double f64MinAngle = -5., double f64MaxAngle = 5., bool bRectMode = false, bool bFitTensor = false, double f64RotationActivationRate = 1.)
f64MinAngle
: 최소 Rotation 각도 범위f64MaxAngle
: 최대 Rotation 각도 범위bRectMode
: ROI를 사각형으로만 처리할 지에 대한 여부bFitTensor
: 회전하는 이미지 연산 방식 선택f64RotationActivationRate
: Batch 마다 적용되는 Rotation 활성화 비율
-
Scale
EnableScale(bool)
SetScaleParam(double f64MinScaleRatioX = 0.8, double f64MaxScaleRatioX = 1.2, double f64MinScaleRatioY = 0.8, double f64MaxScaleRatioY = 1.2, bool bPreservingScaleRatio = false, double f64ScaleActivationRate = 1.)
f64MinScaleRatioX
: 너비 Scale Ratio의 최소f64MaxScaleRatioX
: 너비 Scale Ratio의 최대f64MinScaleRatioY
: 높이 Scale Ratio의 최소f64MaxScaleRatioY
: 높이 Scale Ratio의 최대bPreservingScaleRatio
: 늘리는 축의 비율 유지 여부f64ScaleActivationRate
: Batch 마다 적용되는 Scale 활성화 비율
-
Translation
EnableTranslation(bool)
SetTranslationParam(double f64MinTranslationRatioX = -0.1, double f64MaxTranslationRatioX = 0.1, double f64MinTranslationRatioY = -0.1, double f64MaxTranslationRatioY = 0.1, double f64TranslationActivationRate = 1.)
f64MinTranslationRatioX
: X 방향으로의 최소 이동 비율f64MaxTranslationRatioX
: X 방향으로의 최대 이동 비율f64MinTranslationRatioY
: Y 방향으로의 최소 이동 비율f64MaxTranslationRatioY
: Y 방향으로의 최대 이동 비율f64TranslationActivationRate
: Batch 마다 적용되는 Translation 활성화 비율
-
Cutout
EnableCutout(bool)
SetCutoutParam(double f64MinCutoutRatioX = 0.05, double f64MaxCutoutRatioX = .1, double f64MinCutoutRatioY = 0.05, double f64MaxCutoutRatioY = .1, double f64CutoutActivationRate = .5, int64_t i64MinCutoutCount = 1, int64_t i64MaxCutoutCount = 2)
f64CutoutActivationRate
: Cutout 활성화 비율f64MinCutoutRatioX
: X 방향으로의 최소 cutout되는 비율f64MaxCutoutRatioX
: X 방향으로의 최대 cutout되는 비율f64MinCutoutRatioY
: Y 방향으로의 최소 cutout되는 비율f64MaxCutoutRatioY
: Y 방향으로의 최대 cutout되는 비율i64MinCutoutCount
: 최소 cutout 개수i64MaxCutoutCount
: 최대 cutout 개수
-
- 모든 옵션을 활성화 시 Augmentation 동작 순서는 아래와 같습니다.
- Mix Method
- Resized Crop
- Horizontal Flip
- Vertical Flip
- Adjustment
- Intensity
- Gradation
- Emphasize
- Gaussian Blur
- Gaussian Noise
- Alpha Blend Mask
- Perspective
- Quarter Rotation
- Rotation
- Scale
- Translation
- Cutout
2.4.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
CAugmentationSpec augSpec;
augSpec.SetCommonActivationRate(0.5);
augSpec.SetCommonInterpolationMethod(FLImaging::ImageProcessing::EInterpolationMethod_Bilinear);
augSpec.EnableRotation(true);
augSpec.SetRotationParam(-45.0, 45.0, false, true, 1.0);
augSpec.EnableHorizontalFlip(true);
augSpec.EnableVerticalFlip(true);
semanticSegmentationDL.SetLearningAugmentationSpec(&augSpec);
2.4.4 GUI에서 설정 방법

Fig. Augmentation 설정
3 선택 옵션
3.1 모델/메모리 초기화
3.1.1 개요
- 학습 데이터 및 관련 메모리를 초기화합니다.
- 모델이나 모델의 버전을 바꿔야 할 때, 또는 사용 후 메모리를 반환하여야 할 때 사용합니다.
3.1.2 API
ClearLearnedData()
3.1.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
///////////////////////////////////
// 필수 or 선택 옵션 설정
///////////////////////////////////
semanticSegmentationDL.Learn();
semanticSegmentationDL.Stop();
// 학습 종료 후, 학습 데이터 ClearLearnedData 함수로 초기화
semanticSegmentationDL.ClearLearnedData();
3.1.4 GUI에서 실행 방법

Fig. 모델/메모리 초기화 버튼
3.2 Interpolation 설정
3.2.1 개요
- 입력 이미지를 학습용 Tensor로 변환하는 과정에서 Scale 연산 시 Interpolation 처리방법을 설정합니다.
3.2.2 API
SetInterpolationMethod(ImageProcessing::EInterpolationMethod eInterpolationMethod = ImageProcessing::EInterpolationMethod_Bilinear)
3.2.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.SetInterpolationMethod(FLImaging::ImageProcessing::EInterpolationMethod_Bilinear);
3.2.4 GUI에서 설정 방법

Fig. Interpolation 방식 설정
3.3 Memory Saving Mode 설정
3.3.1 개요
- 입력 이미지 셋이 매우 많을 경우 학습용 Tensor로 모두 변환할 메모리 용량이 부족한 경우에 사용합니다.
- 학습/추론 중 Mini Batch 단위로 Tensor를 생성합니다.
- 메모리가 여유로운 케이스에서 사용하여도 무관합니다.
3.3.2 API
EnableMemorySavingMode(bool bEnable = false)
3.3.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.EnableMemorySavingMode(true);
3.3.4 GUI에서 설정 방법

Fig. Memory Saving Mode 설정
3.4 Save/Load
3.4.1 개요
- 학습 결과를 저장 및 로드합니다.
- 저장 시 현재 설정하였던 파라미터 정보들이 모두 저장됩니다.
- 로드 시 저장하였던 파라미터 정보들이 모두 업데이트 되므로, 추가적인 설정이 필요 없습니다.
3.4.2 API
Load(const Base::CFLString<wchar_t>& strFilePath)
Save(const Base::CFLString<wchar_t>& strFilePath)
strFilePath
: 저장하거나 로드하려는 파일의 경로
3.4.3 예제 코드
- Save
CSemanticSegmentationDL semanticSegmentationDL;
///////////////////////////////////
// 필수 or 선택 옵션 설정
///////////////////////////////////
semanticSegmentationDL.Learn();
semanticSegmentationDL.Stop();
semanticSegmentationDL.Save(L"FL SS 512 B3.flss");
- Load
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.Load(L"FL SS 512 B3.flss");
semanticSegmentationDL.Execute();
3.4.4 GUI에서 설정 방법
- Save
- 학습 후 GUI의 Save 버튼을 클릭하여 Dialog를 통해 원하는 위치에 모델을 저장합니다.
- 확장자는 각 모델별로 상이합니다.
- 학습 후 GUI의 Save 버튼을 클릭하여 Dialog를 통해 원하는 위치에 모델을 저장합니다.

Fig. Save 버튼

Fig. 모델 Save를 위한 Dialog
- Load
- 저장한 모델을 Load 버튼을 클릭하여 모델 파일을 불러옵니다.
- Load가 성공되었다면, 바로 추론 동작을 실행할 수 있습니다.
- 저장한 모델을 Load 버튼을 클릭하여 모델 파일을 불러옵니다.

Fig. Load 버튼

Fig. 모델 Load를 위한 Dialog
3.5 Batch Processing 설정
3.5.1 개요
- 추론 시 현재 페이지의 이미지만 처리할 지 전체 페이지의 이미지를 설정할 지 선택할 수 있습니다.
- 기본 옵션은 전체 페이지 동작(true)입니다.
3.5.2 API
EnableInferenceBatchProcessing(bool bBatchProcessing = true)
3.5.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.EnableInferenceBatchProcessing(false);
semanticSegmentationDL.Execute();
3.5.4 GUI에서 설정 방법

Fig. Inference Batch Processing 설정
3.6 Auto Save 설정
3.6.1 개요
- 학습 중 설정한 조건에 맞으면 자동으로 저장하는 기능
- 자동저장을 시작할 조건을 표현식으로 처리합니다.
- 공통적으로 사용가능한 변수로 epoch, cost, validation(accuracy), metric 을 설정할 수 있습니다.
- 대소문자 구분은 무시됩니다.
- Validation은 accuracy와 같습니다.
- Min, max 함수 키워드 지원 가능합니다.
- 각 알고리즘별 특이 키워드
- Classifier
- Metric과 같은 값으로 f1score가 있습니다.
- Semantic Segmentation
- 추가 validation/accuracy 값으로 validation.ze, accuracy.ze가 있습니다.
- Metric은 mIoU로 대체하여 사용할 수 있습니다.
- 추가 metric은 metric.ze, mIou.ze가 있습니다.
- Object Detection
- 추가 cost 값으로 avgcost가 있습니다.
- Metric은 mAP로 대체하여 사용할 수 있습니다.
- Character Based OCR
- Semantic segmentation과 같은 값을 가집니다.
- 추가 validation/accuracy 값으로 validation.ze, accuracy.ze가 있습니다.
- Metric은 mIoU로 대체하여 사용할 수 있습니다.
- 추가 metric은 metric.ze, mIou.ze가 있습니다.
- Semantic segmentation과 같은 값을 가집니다.
- String Based OCR
- Metric과 같은 값으로 (1-NED + mAP) / 2 가 있습니다.
- Anomaly Detection
- 추가 변수 및 변수 대체값 없습니다.
- Generative Adversarial Network
- Metric과 같은 값으로 Validation Epoch * (SSIM + PDV) 가 있습니다.
- Generative Adversarial Network Inpainting
- Metric과 같은 값으로 Validation Epoch * (SSIM + MRQ) 가 있습니다.
- Classifier
3.6.2 API
- 기본 설정
SetLearningAutoSaveSpec(const CAutoSaveSpec&, Base::CFLString<wchar_t>*)
SetLearningAutoSaveSpec(const CAutoSaveSpec*, Base::CFLString<wchar_t>*)
- CAutoSaveSpec 설정
SetAutoSavePath(const Base::CFLString<wchar_t>&)
SetAutoSaveCondition(const Base::CFLString<wchar_t>&)
3.6.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
CAutoSaveSpec autoSave;
CFLString<wchar_t> flsErrorSymbol;
autoSave.EnableAutoSave(true);
autoSave.SetAutoSavePath(L"FL SS.flss");
autoSave.SetAutoSaveCondition(L"epoch >= 100 & (cost < min('cost') | miou.ze > max('miou.ze'))");
// Error Symbol 옵션을 생략 가능
semanticSegmentationDL.SetLearningAutoSaveSpec(autoSave, &flsErrorSymbol);
3.6.4 GUI에서 설정 방법

Fig. Auto Save 환경 설정
3.7 Stop Condition 설정
3.7.1 개요
- 학습 중 특정 조건에 도달 시 학습을 종료하는 기능
- Auto Save와 동일하게 표현식을 사용하여 처리합니다.
3.7.2 API
SetLearningStopCondition(const Base::CFLString<wchar_t>& flsStopConditionExpression, Base::CFLString<wchar_t>*)
3.7.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.SetLearningStopCondition(L"epoch >= 10 & (cost <= 0 | accuracy >= 1 | miou >= 1)");
3.7.4 GUI에서 설정 방법

Fig. Stop Condition 설정
3.8 Optimal State Preservation 설정
3.8.1 개요
- 학습을 종료한 후, 수동으로 Save를 할 때, 어떠한 상태를 저장할 지 설정합니다.
- true라면 최적의 학습 상태가 파일에 저장됩니다.
- Validation Set이 없는 경우엔 cost값이 최소가 된 지점을 저장합니다.
- Validation Set이 있는 경우엔 metric값이 최대가 된 지점을 저장합니다.
- false라면 마지막 학습 상태가 파일에 저장됩니다.
- true라면 최적의 학습 상태가 파일에 저장됩니다.
3.8.2 API
EnableOptimalLearningStatePreservation(bool)
3.8.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.EnableOptimalLearningStatePreservation(false);
3.8.4 GUI에서 설정 방법

Fig. Optimal Learning State Preservation 설정
3.9 Class Equalization 설정
3.9.1 개요
- Batch당 최대한 여러 개의 클래스가 균등하게 들어있도록 하는 class equalization 활성화 여부를 설정합니다.
3.9.2 API
EnableClassEqualization(bool)
3.9.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.EnableClassEqualization(false);
3.9.4 GUI에서 설정 방법

Fig. Class Equalization 설정
3.10 Preprocessing 설정
3.10.1 개요
- Learn dataset에 사용할 전처리 image processing 알고리즘을 선택합니다.
- 현재 Preprocessing에 사용할 수 있는 알고리즘들은 다음과 같습니다.
- Low Luminance Correction Type 2
- Emphasize
- FL Auto Shading Correction
- Contrast Enhancement
- 현재 Preprocessing에 사용할 수 있는 알고리즘들은 다음과 같습니다.
3.10.2 API
SetImagePreprocessingAlgorithm(const Foundation::CAlgorithmFeatureBase* pAlgorithm)
pAlgorithm
: Preprocessing에 사용할 단일 알고리즘 객체 포인터
SetImagePreprocessingAlgorithm(const std::vector< Foundation::CAlgorithmFeatureBase*>& vctAlgorithm)
vctAlgorithm
: Preprocessing에 사용할 복수의 알고리즘 객체들의 포인터 vector
AddImagePreprocessingAlgorithm(const Foundation::CAlgorithmFeatureBase* pAlgorithm)
pAlgorithm
: Preprocessing에 추가할 단일 알고리즘 객체 포인터
AddImagePreprocessingAlgorithm(const std::vector< Foundation::CAlgorithmFeatureBase*>& vctAlgorithm)
vctAlgorithm
: Preprocessing에 추가할 복수의 알고리즘 객체들의 포인터 vector
3.10.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
std::vector<Foundation::CAlgorithmFeatureBase*> vctAlgorithms;
CLowLuminanceCorrectionType2 lowLuminanceCorrectionType2;
vctAlgorithms.push_back(&lowLuminanceCorrectionType2);
CFLAutoShadingCorrection flAutoShadingCorrection;
vctAlgorithms.push_back(&flAutoShadingCorrection);
semanticSegmentationDL.SetImagePreprocessingAlgorithm(vctAlgorithms);
3.10.4 GUI에서 설정 방법

Fig. Preprocessing 설정
3.11 Image Tiling 설정
3.11.1 개요
- 입력받은 학습 이미지를 어떠한 방식으로 분할하여 사용할 지를 선택합니다.
- Instance Segmentation, Semantic Segmentation, Object Detection과 같은 알고리즘에서 사용됩니다.
- 총 5가지 모드를 지원합니다.
ETilingMode_NoTiling_NoFit
: 별도의 Scaling 없이 모델의 크기로 처리합니다.ETilingMode_NoTiling_Fit
: 이미지를 모델의 크기로 Scaling하여 변환합니다.ETilingMode_NoTiling_ProportionalFit
: 정사각형의 비율을 유지하도록 Scaling하여 변환합니다. (기본값)ETilingMode_SingleAxisTiling_ProportionalFit
: 정사각형의 비율을 유지한 채로 더 긴 axis를 기준으로만 이미지를 분할합니다.ETilingMode_BothAxesTiling_NoFit
: 이미지를 모델의 크기로 높이, 너비에 대해 모두 분할합니다.
- SingleAxisTiling, BothAxeTiling의 경우에는 겹치는 비율을 설정 가능합니다.
- 겹치는 비율 범위는 0~0.9입니다.
3.11.2 API
SetImageTilingMode(ETilingMode eImageTilingMode = ETilingMode_NoTiling_ProportionalFit)
SetImageTilingOverlapRatio(double f64OverlpaRatio = .25)
3.11.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.SetImageTilingMode(ETilingMode_SingleAxisTiling_ProportionalFit);
semanticSegmentationDL.SetImageTilingOverlapRatio(0.3);
3.11.4 GUI에서 설정 방법

Fig. Image Tiling 설정
3.12 Reset Best Score 설정
3.12.1 개요
- 현재 저장한 cost, validation과 관련된 최고의 기록들을 초기화합니다.
3.12.2 API
ResetBestScore()
3.12.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.Learn();
semanticSegmentationDL.Stop();
// 학습 종료 후 Best Record 초기화
semanticSegmentationDL.ResetBestScore();
3.12.4 GUI에서 설정 방법

Fig. Best Records Reset
3.13 Pretrained Model 설정
3.13.1 개요
- 학습된 모델을 Pretrained 상태로 만듭니다.
3.13.2 API
MakePretrainedModel()
3.13.3 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
semanticSegmentationDL.Learn();
semanticSegmentationDL.Stop();
// 학습 종료 후 Pretrained Model 생성
semanticSegmentationDL.MakePretrainedModel();
3.13.4 GUI에서 설정 방법

Fig. Make Pretrained Model 설정
3.14 Pretrained Model 사용
3.14.1 개요
- Pretrained Model을 Backbone으로 사용 합니다.
- Pretrained Model은 Classifier 모델 FLNet FPT버전이어야 합니다.
- 지원 모델 및 버전 목록
- Semantic Segmentation
- FLSegNet V1 512 B1~B5 <-> Classifier FLNetFPT FLSegNet V1 B1~B5
- Object Detection DL
- R-FLNet V1 512 -> Classifier FLNetFPT R-FLNet V1
- Instance Segmentation DL
- R-FLSegNet V1 512 -> Classifier FLNetFPT R-FLNet V1
- CharacterBased OCR DL
- R-FLSegNet V1 512 -> Classifier FLNetFPT R-FLNet V1
- String Based OCR DL
- R-FLNet V1 512 -> Classifier FLNetFPT R-FLNet V1
- Semantic Segmentation
3.14.2 API
EnablePretrainedModelFile(bool)
- Pretrain Model File을 사용합니다.
EnableIntrinsicPretrainedModelFile(bool)
- Intrinsic PretrainModel File을 사용합니다.
SetPretrainModelFilePath(CFLString<wchar_t>)
- 지정된 경로에 있는 Pretrain Model File을 사용합니다.
3.14.3 예제 코드
- IntrinsicPretrainedModelFile 사용(반드시 Pretrained Model File Package가 설치되어있어야 합니다.
CSemanticSegmentationDL semanticSegmentationDL;
// Pretrained Model 사용을 위해 FLSegNet으로 모델 설정
semanticSegmentationDL.SetModel(CSemanticSegmentationDL::EModel_FLSegNet);
semanticSegmentationDL.SetModelVersion(CSemanticSegmentationDL::EModelVersion_FLSegNet_V1_512_B3);
semanticSegmentationDL.EnablePretrainedModelFile(true);
semanticSegmentationDL.EnableIntrinsicPretrainedModelFile(true);
//////////////////////////////////////////
//////////////////////////////////////////
// Learn 옵션 셋팅 후 Learn 수행
//////////////////////////////////////////
//////////////////////////////////////////
semanticSegmentationDL.Learn();
- 지정된 경로의 Pretrain Model File Path 사용
CSemanticSegmentationDL semanticSegmentationDL;
// Pretrained Model 사용을 위해 FLSegNet으로 모델 설정
semanticSegmentationDL.SetModel(CSemanticSegmentationDL::EModel_FLSegNet);
semanticSegmentationDL.SetModelVersion(CSemanticSegmentationDL::EModelVersion_FLSegNet_V1_512_B3);
semanticSegmentationDL.EnablePretrainedModelFile(true);
semanticSegmentationDL.EnableIntrinsicPretrainedModelFile(false);
semanticSegmentationDL.SetPretrainModelFilePath(L"C://FLSegNet V1 B3 PT.flcf");
//////////////////////////////////////////
//////////////////////////////////////////
// Learn 옵션 셋팅 후 Learn 수행
//////////////////////////////////////////
//////////////////////////////////////////
semanticSegmentationDL.Learn();
3.14.4 GUI에서 사용하는 법

Fig. Pretrained Model
4 학습 및 추론
4.1 개요
- 앞서 설명한 옵션들에 대한 설정을 완료한 후 동작합니다.
- 모델을 Load 한 경우 Save 당시의 파라미터가 모두 동기화 되므로 Image를 제외한 옵션 입력이 필요 없습니다.
- 추론의 경우 학습이 되어있는 경우에만 활성화되어 학습을 하지 않으면 동작하지 않습니다.
- 학습이 시작되면 설정된 Epoch이나, Stop Condition에 부합할 때까지 진행됩니다. 또는 Dialog 창에서 stop 버튼으로 사용자가 원하는 경우에 학습을 중단할 수 있습니다.
4.2 학습
- 각 모델별 라벨링 방법으로 학습 이미지 및 검증 이미지를 설정합니다.
- 검증 이미지는 오버 피팅 방지를 위해 학습에 사용되지 않은 데이터 셋을 사용하는 것을 권장합니다.
- 학습 이미지, 검증 이미지 비율은 9:1 ~ 8:2 범위로 사용하는 것을 권장합니다.
- 추론할 데이터에 맞게 세부 옵션들을 설정합니다.
- Model 설정
- 검사 대상의 정밀도에 따라 모델을 설정합니다.
- 검사할 이미지의 상태 변화에 따른 Augmentation 기법을 적용합니다.
- 검사할 위치가 이동된다면 Translation, 조명 밝기가 변한다면 Adjustment 또는 Intensity 등 검사 이미지의 상태 변화에 맞는 Augmentation을 적용합니다.
- Tiling Mode
- 검사 대상의 비율 및 크기 변화에 민감한 정도에 따라 Tiling 옵션을 설정합니다.
- 이 외의 선택 옵션들
- Model 설정
- 종료 및 저장 조건을 설정합니다.
- 조건을 설정하지 않을 경우 각 모델별로 설정된 기본값으로 동작합니다.
- 학습을 진행합니다.
- 이미 학습이 진행된 상태에서 학습 진행 시 초기화 되지않고 이전 상태에서 추가적으로 학습이 진행됩니다.
- Load 이후에 학습 시에도 추가 학습으로 진행됩니다.
- 추가 학습 시에는 Model과 Tiling Mode에 대한 옵션을 변경할 수 없습니다.
- 이미 학습이 진행된 상태에서 학습 진행 시 초기화 되지않고 이전 상태에서 추가적으로 학습이 진행됩니다.
4.3 추론
- Learn 또는 Load를 진행합니다.
IsLearned()
함수로 학습 여부를 확인합니다.
- 검사 이미지를 설정합니다.
- 학습된 모델로 추론을 진행합니다.
- 추론 결과는 이미지 형태로 얻을 수 있습니다.
GetInferenceResultImage
로 결과 이미지를 얻습니다.
4.4 API
Learn()
: 학습 동작 함수IsLearned()
: 학습 상태 체크 함수Execute()
: 추론 동작 함수GetInferenceResultImage()
: 추론 결과 이미지
4.5 예제 코드
CSemanticSegmentationDL semanticSegmentationDL;
// 모델 설정
semanticSegmentationDL.SetModel(CSemanticSegmentationDL::EModel_FLSegNet);
semanticSegmentationDL.SetModelVersion(CSemanticSegmentationDL::EModelVersion_FLSegNet_V1_512_B3);
//////////////////////////////////////////
// 학습 옵션 셋팅 후 Learn 수행
//////////////////////////////////////////
semanticSegmentationDL.Learn();
if(!semanticSegmentationDL.IsLearned())
{
// 학습 실패 예외처리
}
//////////////////////////////////////////
// 추론 옵션 셋팅 후 Execute 수행
//////////////////////////////////////////
semanticSegmentationDL.Execute();
// 추론 결과 얻어오기
CFLImage* resultImage = (CFLImage*)semanticSegmentationDL.GetInferenceResultImage();