데이터셋 등록 추가
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
package com.kamco.cd.training.model;
|
||||
|
||||
import com.kamco.cd.training.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDto.Basic;
|
||||
import com.kamco.cd.training.model.service.ModelMngService;
|
||||
import com.kamco.cd.training.model.service.ModelTrainService;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.Basic;
|
||||
import com.kamco.cd.training.model.service.ModelTrainMngService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
@@ -28,9 +27,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "모델학습 관리", description = "어드민 홈 > 모델학습관리 > 모델관리 > 목록")
|
||||
@RequestMapping("/api/models")
|
||||
public class ModelMngApiController {
|
||||
private final ModelMngService modelMngService;
|
||||
private final ModelTrainService modelTrainService;
|
||||
public class ModelTrainMngApiController {
|
||||
private final ModelTrainMngService modelTrainMngService;
|
||||
|
||||
@Operation(summary = "모델학습 목록 조회", description = "모델학습 목록 조회 API")
|
||||
@ApiResponses(
|
||||
@@ -55,8 +53,8 @@ public class ModelMngApiController {
|
||||
String status,
|
||||
@Parameter(description = "페이지 번호") @RequestParam(defaultValue = "0") int page,
|
||||
@Parameter(description = "페이지 크기") @RequestParam(defaultValue = "20") int size) {
|
||||
ModelTrainDto.SearchReq searchReq = new ModelTrainDto.SearchReq(status, page, size);
|
||||
return ApiResponseDto.ok(modelMngService.getModelList(searchReq));
|
||||
ModelTrainMngDto.SearchReq searchReq = new ModelTrainMngDto.SearchReq(status, page, size);
|
||||
return ApiResponseDto.ok(modelTrainMngService.getModelList(searchReq));
|
||||
}
|
||||
|
||||
@Operation(summary = "학습 모델 삭제", description = "학습 모델 삭제 API")
|
||||
@@ -70,7 +68,7 @@ public class ModelMngApiController {
|
||||
@Parameter(description = "학습 모델 uuid", example = "f2b02229-90f2-45f5-92ea-c56cf1c29f79")
|
||||
@PathVariable
|
||||
UUID uuid) {
|
||||
modelMngService.deleteModelTrain(uuid);
|
||||
modelTrainMngService.deleteModelTrain(uuid);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
|
||||
@@ -81,8 +79,9 @@ public class ModelMngApiController {
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@PostMapping
|
||||
public ApiResponseDto<String> createModelTrain(@RequestBody ModelTrainDto.AddReq modelTrainDto) {
|
||||
return ApiResponseDto.ok(null);
|
||||
public ApiResponseDto<String> createModelTrain(@RequestBody ModelTrainMngDto.AddReq req) {
|
||||
modelTrainMngService.createModelTrain(req);
|
||||
return ApiResponseDto.ok("ok");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -104,7 +103,7 @@ public class ModelMngApiController {
|
||||
// @Parameter(description = "모델 UUID", example = "b7e99739-6736-45f9-a224-8161ecddf287")
|
||||
// @PathVariable
|
||||
// String uuid) {
|
||||
// return ApiResponseDto.ok(modelMngService.getModelDetailByUuid(uuid));
|
||||
// return ApiResponseDto.ok(modelTrainMngService.getModelDetailByUuid(uuid));
|
||||
// }
|
||||
//
|
||||
// // ==================== 학습 모델학습관리 API (5종) ====================
|
||||
@@ -1,336 +0,0 @@
|
||||
package com.kamco.cd.training.model.dto;
|
||||
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.common.enums.TrainType;
|
||||
import com.kamco.cd.training.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public class ModelTrainDto {
|
||||
@Schema(name = "모델학습관리 목록", description = "모델학습관리 목록")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Basic {
|
||||
|
||||
private Long id;
|
||||
private UUID uuid;
|
||||
private String modelVer;
|
||||
@JsonFormatDttm private ZonedDateTime startDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1EndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2EndDttm;
|
||||
private String step1Status;
|
||||
private String step2Status;
|
||||
private String statusCd;
|
||||
private String trainType;
|
||||
|
||||
public String getStatusName() {
|
||||
if (this.statusCd == null || this.statusCd.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.statusCd).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.statusCd; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep1StatusName() {
|
||||
if (this.step1Status == null || this.step1Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step1Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step1Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep2StatusNAme() {
|
||||
if (this.step2Status == null || this.step2Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step2Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step2Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getTrainTypeName() {
|
||||
if (this.trainType == null || this.trainType.isBlank()) return null;
|
||||
try {
|
||||
return TrainType.valueOf(this.trainType).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.trainType; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDuration(ZonedDateTime start, ZonedDateTime end) {
|
||||
if (start == null || end == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long totalSeconds = Math.abs(Duration.between(start, end).getSeconds());
|
||||
|
||||
long hours = totalSeconds / 3600;
|
||||
long minutes = (totalSeconds % 3600) / 60;
|
||||
long seconds = totalSeconds % 60;
|
||||
|
||||
return String.format("%d시간 %d분 %d초", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public String getStep1Duration() {
|
||||
return formatDuration(this.step1StrtDttm, this.step1EndDttm);
|
||||
}
|
||||
|
||||
public String getStep2Duration() {
|
||||
return formatDuration(this.step2StrtDttm, this.step2EndDttm);
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "searchReq", description = "모델학습 관리 목록조회 파라미터")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SearchReq {
|
||||
|
||||
private String status;
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
|
||||
public Pageable toPageable() {
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "addReq", description = "모델학습 관리 등록 파라미터")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class AddReq {
|
||||
HyperParamDto hyperParam;
|
||||
TrainingDataConfigDto trainingDataConfig;
|
||||
EtcConfig etcConfig;
|
||||
}
|
||||
|
||||
/** 학습실행설정 하이퍼파라미터 설정 */
|
||||
@Schema(name = "하이퍼파라미터 설정", description = "학습실행설정 > 하이퍼파라미터 설정")
|
||||
@Getter
|
||||
@Setter
|
||||
public static class HyperParamDto {
|
||||
|
||||
@NotNull
|
||||
@Schema(
|
||||
description = "OPTIMIZED(최적화 파라미터),EXISTING(기존 파라미터),NEW(신규 파라미터)",
|
||||
example = "EXISTING")
|
||||
private String hyperParamType;
|
||||
|
||||
@Schema(description = "기존 파라미터 uuid", example = "57fc9170-64c1-4128-aa7b-0657f08d6d10")
|
||||
private String hyperUuid;
|
||||
|
||||
// -------------------------
|
||||
// Important
|
||||
// -------------------------
|
||||
@Schema(description = "백본 네트워크", example = "large")
|
||||
private String backbone; // backbone
|
||||
|
||||
@Schema(description = "입력 이미지 크기(H,W)", example = "512,512")
|
||||
private String inputSize; // input_size
|
||||
|
||||
@Schema(description = "크롭 크기(H,W 또는 단일값)", example = "256,256")
|
||||
private String cropSize; // crop_size
|
||||
|
||||
@Schema(description = "배치 크기(Per GPU)", example = "16")
|
||||
private Integer batchSize; // batch_size
|
||||
|
||||
// -------------------------
|
||||
// Data
|
||||
// -------------------------
|
||||
@Schema(description = "Train dataloader workers", example = "16")
|
||||
private Integer trainNumWorkers; // train_num_workers
|
||||
|
||||
@Schema(description = "Val dataloader workers", example = "8")
|
||||
private Integer valNumWorkers; // val_num_workers
|
||||
|
||||
@Schema(description = "Test dataloader workers", example = "8")
|
||||
private Integer testNumWorkers; // test_num_workers
|
||||
|
||||
@Schema(description = "Train shuffle 여부", example = "true")
|
||||
private Boolean trainShuffle; // train_shuffle
|
||||
|
||||
@Schema(description = "Train persistent workers 여부", example = "true")
|
||||
private Boolean trainPersistent; // train_persistent
|
||||
|
||||
@Schema(description = "Val persistent workers 여부", example = "true")
|
||||
private Boolean valPersistent; // val_persistent
|
||||
|
||||
// -------------------------
|
||||
// Model Architecture
|
||||
// -------------------------
|
||||
@Schema(description = "Drop Path 비율", example = "0.3")
|
||||
private Double dropPathRate; // drop_path_rate
|
||||
|
||||
@Schema(description = "Freeze 단계(-1:None)", example = "-1")
|
||||
private Integer frozenStages; // frozen_stages
|
||||
|
||||
@Schema(description = "Neck 결합 정책", example = "abs_diff")
|
||||
private String neckPolicy; // neck_policy
|
||||
|
||||
@Schema(description = "디코더 채널 구성", example = "512,256,128,64")
|
||||
private String decoderChannels; // decoder_channels
|
||||
|
||||
@Schema(description = "클래스별 가중치", example = "1,10")
|
||||
private String classWeight; // class_weight
|
||||
|
||||
// -------------------------
|
||||
// Loss & Optimization
|
||||
// -------------------------
|
||||
@Schema(description = "학습률", example = "0.00006")
|
||||
private Double learningRate; // learning_rate
|
||||
|
||||
@Schema(description = "Weight Decay", example = "0.05")
|
||||
private Double weightDecay; // weight_decay
|
||||
|
||||
@Schema(description = "Layer Decay Rate", example = "0.9")
|
||||
private Double layerDecayRate; // layer_decay_rate
|
||||
|
||||
@Schema(description = "DDP unused params 탐색 여부", example = "true")
|
||||
private Boolean ddpFindUnusedParams; // ddp_find_unused_params
|
||||
|
||||
@Schema(description = "Loss 계산 제외 인덱스", example = "255")
|
||||
private Integer ignoreIndex; // ignore_index
|
||||
|
||||
@Schema(description = "레이어 깊이", example = "24")
|
||||
private Integer numLayers; // num_layers
|
||||
|
||||
// -------------------------
|
||||
// Evaluation
|
||||
// -------------------------
|
||||
@Schema(description = "평가 지표 목록", example = "mFscore,mIoU")
|
||||
private String metrics; // metrics
|
||||
|
||||
@Schema(description = "Best 모델 선정 기준 지표", example = "changed_fscore")
|
||||
private String saveBest; // save_best
|
||||
|
||||
@Schema(description = "Best 모델 선정 규칙", example = "less")
|
||||
private String saveBestRule; // save_best_rule
|
||||
|
||||
@Schema(description = "검증 수행 주기(Epoch)", example = "10")
|
||||
private Integer valInterval; // val_interval
|
||||
|
||||
@Schema(description = "로그 기록 주기(Iteration)", example = "400")
|
||||
private Integer logInterval; // log_interval
|
||||
|
||||
@Schema(description = "시각화 저장 주기(Epoch)", example = "1")
|
||||
private Integer visInterval; // vis_interval
|
||||
|
||||
// -------------------------
|
||||
// Augmentation
|
||||
// -------------------------
|
||||
@Schema(description = "회전 적용 확률", example = "0.5")
|
||||
private Double rotProb; // rot_prob
|
||||
|
||||
@Schema(description = "회전 각도 범위(Min,Max)", example = "-20,20")
|
||||
private String rotDegree; // rot_degree
|
||||
|
||||
@Schema(description = "반전 적용 확률", example = "0.5")
|
||||
private Double flipProb; // flip_prob
|
||||
|
||||
@Schema(description = "채널 교환 확률", example = "0.5")
|
||||
private Double exchangeProb; // exchange_prob
|
||||
|
||||
@Schema(description = "밝기 변화량", example = "10")
|
||||
private Integer brightnessDelta; // brightness_delta
|
||||
|
||||
@Schema(description = "대비 범위(Min,Max)", example = "0.8,1.2")
|
||||
private String contrastRange; // contrast_range
|
||||
|
||||
@Schema(description = "채도 범위(Min,Max)", example = "0.8,1.2")
|
||||
private String saturationRange; // saturation_range
|
||||
|
||||
@Schema(description = "색조 변화량", example = "10")
|
||||
private Integer hueDelta; // hue_delta
|
||||
|
||||
// -------------------------
|
||||
// Hardware
|
||||
// -------------------------
|
||||
@Schema(description = "사용 GPU 개수", example = "4")
|
||||
private Integer gpuCnt; // gpu_cnt
|
||||
|
||||
@Schema(description = "사용 GPU ID 목록", example = "0,1,2,3")
|
||||
private String gpuIds; // gpu_ids
|
||||
|
||||
@Schema(description = "분산학습 마스터 포트", example = "1122")
|
||||
private Integer masterPort; // master_port
|
||||
|
||||
// -------------------------
|
||||
// Memo
|
||||
// -------------------------
|
||||
@Schema(description = "메모", example = "하이퍼파라미터 신규등록")
|
||||
private String memo; // memo
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class TrainingDataConfigDto {
|
||||
Summary summary;
|
||||
List<Dataset> datasetList;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Summary {
|
||||
@Schema(description = "건물", example = "0")
|
||||
private Long buildingCnt;
|
||||
|
||||
@Schema(description = "컨테이너", example = "0")
|
||||
private Long containerCnt;
|
||||
|
||||
@Schema(description = "폐기물", example = "0")
|
||||
private Long wasteCnt;
|
||||
|
||||
@Schema(
|
||||
description = "도로, 비닐하우스, 밭, 과수원, 초지, 숲, 물, 모재/자갈, 토분(무덤), 일반토지, 태양광, 기타",
|
||||
example = "0")
|
||||
private Long LandCoverCnt;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Dataset {
|
||||
@Schema(description = "데이터셋 uuid")
|
||||
private UUID uuid;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class EtcConfig {
|
||||
@Schema(description = "에폭 횟수", example = "0")
|
||||
private Long epochCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Training", example = "0")
|
||||
private Integer trainingCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Validation", example = "0")
|
||||
private Integer validationCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Test", example = "0")
|
||||
private Integer testCnt;
|
||||
|
||||
@Schema(description = "메모", example = "메모 입니다.")
|
||||
private String memo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package com.kamco.cd.training.model.dto;
|
||||
|
||||
import com.kamco.cd.training.common.dto.HyperParam;
|
||||
import com.kamco.cd.training.common.enums.TrainStatusType;
|
||||
import com.kamco.cd.training.common.enums.TrainType;
|
||||
import com.kamco.cd.training.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.Duration;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public class ModelTrainMngDto {
|
||||
@Schema(name = "모델학습관리 목록", description = "모델학습관리 목록")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public static class Basic {
|
||||
|
||||
private Long id;
|
||||
private UUID uuid;
|
||||
private String modelVer;
|
||||
@JsonFormatDttm private ZonedDateTime startDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step1EndDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2StrtDttm;
|
||||
@JsonFormatDttm private ZonedDateTime step2EndDttm;
|
||||
private String step1Status;
|
||||
private String step2Status;
|
||||
private String statusCd;
|
||||
private String trainType;
|
||||
|
||||
public String getStatusName() {
|
||||
if (this.statusCd == null || this.statusCd.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.statusCd).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.statusCd; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep1StatusName() {
|
||||
if (this.step1Status == null || this.step1Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step1Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step1Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getStep2StatusNAme() {
|
||||
if (this.step2Status == null || this.step2Status.isBlank()) return null;
|
||||
try {
|
||||
return TrainStatusType.valueOf(this.step2Status).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.step2Status; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
public String getTrainTypeName() {
|
||||
if (this.trainType == null || this.trainType.isBlank()) return null;
|
||||
try {
|
||||
return TrainType.valueOf(this.trainType).getText(); // 또는 getName()
|
||||
} catch (IllegalArgumentException e) {
|
||||
return this.trainType; // 매핑 못하면 코드 그대로 반환(원하면 null 처리)
|
||||
}
|
||||
}
|
||||
|
||||
private String formatDuration(ZonedDateTime start, ZonedDateTime end) {
|
||||
if (start == null || end == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
long totalSeconds = Math.abs(Duration.between(start, end).getSeconds());
|
||||
|
||||
long hours = totalSeconds / 3600;
|
||||
long minutes = (totalSeconds % 3600) / 60;
|
||||
long seconds = totalSeconds % 60;
|
||||
|
||||
return String.format("%d시간 %d분 %d초", hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public String getStep1Duration() {
|
||||
return formatDuration(this.step1StrtDttm, this.step1EndDttm);
|
||||
}
|
||||
|
||||
public String getStep2Duration() {
|
||||
return formatDuration(this.step2StrtDttm, this.step2EndDttm);
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "searchReq", description = "모델학습 관리 목록조회 파라미터")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class SearchReq {
|
||||
|
||||
private String status;
|
||||
// 페이징 파라미터
|
||||
private int page = 0;
|
||||
private int size = 20;
|
||||
|
||||
public Pageable toPageable() {
|
||||
return PageRequest.of(page, size);
|
||||
}
|
||||
}
|
||||
|
||||
@Schema(name = "addReq", description = "모델학습 관리 등록 파라미터")
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class AddReq {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "모델 종류 M1, M2, M3", example = "M1")
|
||||
private String modelNo;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "모델학습 실행 여부", example = "false")
|
||||
private Boolean isStart;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "학습타입 GENERAL(일반), TRANSFER(전이)", example = "GENERAL")
|
||||
private String trainType;
|
||||
|
||||
@NotNull
|
||||
@Schema(
|
||||
description = "하이퍼 파라미터 선택 타입 OPTIMIZED(최적화 파라미터),EXISTING(기존 파라미터),NEW(신규 파라미터)",
|
||||
example = "EXISTING")
|
||||
private String hyperParamType;
|
||||
|
||||
@Schema(description = "하이퍼파라미터 uuid", example = "57fc9170-64c1-4128-aa7b-0657f08d6d10")
|
||||
private UUID hyperUuid;
|
||||
|
||||
HyperParam hyperParam;
|
||||
TrainingDataset trainingDataset;
|
||||
ModelConfig modelConfig;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class TrainingDataset {
|
||||
Summary summary;
|
||||
List<Long> datasetList;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Summary {
|
||||
@Schema(description = "건물", example = "0")
|
||||
private Long buildingCnt;
|
||||
|
||||
@Schema(description = "컨테이너", example = "0")
|
||||
private Long containerCnt;
|
||||
|
||||
@Schema(description = "폐기물", example = "0")
|
||||
private Long wasteCnt;
|
||||
|
||||
@Schema(
|
||||
description = "도로, 비닐하우스, 밭, 과수원, 초지, 숲, 물, 모재/자갈, 토분(무덤), 일반토지, 태양광, 기타",
|
||||
example = "0")
|
||||
private Long LandCoverCnt;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static class ModelConfig {
|
||||
@Schema(description = "에폭 횟수", example = "0")
|
||||
private Integer epochCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Training", example = "0")
|
||||
private Float trainingCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Validation", example = "0")
|
||||
private Float validationCnt;
|
||||
|
||||
@Schema(description = "학습데이터셋 비율 Test", example = "0")
|
||||
private Float testCnt;
|
||||
|
||||
@Schema(description = "메모", example = "메모 입니다.")
|
||||
private String memo;
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.kamco.cd.training.model.service;
|
||||
|
||||
import com.kamco.cd.training.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.core.ModelMngCoreService;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
@Slf4j
|
||||
public class ModelMngService {
|
||||
|
||||
private final ModelMngCoreService modelMngCoreService;
|
||||
|
||||
/**
|
||||
* 모델 목록 조회
|
||||
*
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 모델 목록
|
||||
*/
|
||||
public Page<ModelTrainDto.Basic> getModelList(SearchReq searchReq) {
|
||||
return modelMngCoreService.findByModelList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 학습모델 삭제
|
||||
*
|
||||
* @param uuid
|
||||
*/
|
||||
public void deleteModelTrain(UUID uuid) {
|
||||
modelMngCoreService.deleteModel(uuid);
|
||||
}
|
||||
|
||||
public String createModelTrain(ModelMngDto modelMngDto) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델 상세 조회
|
||||
*
|
||||
* @param modelUid 모델 UID
|
||||
* @return 모델 상세 정보
|
||||
*/
|
||||
public ModelMngDto.Detail getModelDetail(Long modelUid) {
|
||||
return modelMngCoreService.getModelDetail(modelUid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.kamco.cd.training.model.service;
|
||||
|
||||
import com.kamco.cd.training.common.dto.HyperParam;
|
||||
import com.kamco.cd.training.common.enums.HyperParamSelectType;
|
||||
import com.kamco.cd.training.hyperparam.dto.HyperParamDto;
|
||||
import com.kamco.cd.training.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto;
|
||||
import com.kamco.cd.training.model.dto.ModelTrainMngDto.SearchReq;
|
||||
import com.kamco.cd.training.postgres.core.HyperParamCoreService;
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainMngCoreService;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Transactional(readOnly = true)
|
||||
@Slf4j
|
||||
public class ModelTrainMngService {
|
||||
|
||||
private final ModelTrainMngCoreService modelTrainMngCoreService;
|
||||
private final HyperParamCoreService hyperParamCoreService;
|
||||
|
||||
/**
|
||||
* 모델학습 조회
|
||||
*
|
||||
* @param searchReq 검색 조건
|
||||
* @return 페이징 처리된 모델 목록
|
||||
*/
|
||||
public Page<ModelTrainMngDto.Basic> getModelList(SearchReq searchReq) {
|
||||
return modelTrainMngCoreService.findByModelList(searchReq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델학습 삭제
|
||||
*
|
||||
* @param uuid
|
||||
*/
|
||||
public void deleteModelTrain(UUID uuid) {
|
||||
modelTrainMngCoreService.deleteModel(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델학습 등록
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public void createModelTrain(ModelTrainMngDto.AddReq req) {
|
||||
HyperParam hyperParam = req.getHyperParam();
|
||||
HyperParamDto.Basic hyper = new HyperParamDto.Basic();
|
||||
|
||||
/** OPTIMIZED(최적화 파라미터), EXISTING(기존 파라미터), NEW(신규 파라미터) * */
|
||||
if (HyperParamSelectType.NEW.getId().equals(req.getHyperParamType())) {
|
||||
// 하이퍼파라미터 등록
|
||||
hyper = hyperParamCoreService.createHyperParam(hyperParam);
|
||||
req.setHyperUuid(hyper.getUuid());
|
||||
}
|
||||
|
||||
// 모델학습 테이블 저장
|
||||
Long modelId = modelTrainMngCoreService.saveModel(req);
|
||||
|
||||
// 모델학습 데이터셋 저장
|
||||
modelTrainMngCoreService.saveModelDataset(modelId, req);
|
||||
|
||||
// 모델 데이터셋 mapping 저장
|
||||
modelTrainMngCoreService.saveModelDatasetMap(
|
||||
modelId, req.getTrainingDataset().getDatasetList());
|
||||
|
||||
// 모델 config 저장
|
||||
modelTrainMngCoreService.saveModelConfig(modelId, req.getModelConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* 모델학습 상세 조회
|
||||
*
|
||||
* @param modelUid 모델 UID
|
||||
* @return 모델 상세 정보
|
||||
*/
|
||||
public ModelMngDto.Detail getModelDetail(Long modelUid) {
|
||||
return modelTrainMngCoreService.getModelDetail(modelUid);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.kamco.cd.training.common.exception.BadRequestException;
|
||||
import com.kamco.cd.training.common.exception.NotFoundException;
|
||||
import com.kamco.cd.training.model.dto.ModelMngDto;
|
||||
import com.kamco.cd.training.postgres.core.DatasetCoreService;
|
||||
import com.kamco.cd.training.postgres.core.ModelMngCoreService;
|
||||
import com.kamco.cd.training.postgres.core.ModelTrainMngCoreService;
|
||||
import com.kamco.cd.training.postgres.core.SystemMetricsCoreService;
|
||||
import com.kamco.cd.training.postgres.entity.ModelMasterEntity;
|
||||
import java.util.List;
|
||||
@@ -19,7 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@Slf4j
|
||||
public class ModelTrainService {
|
||||
|
||||
private final ModelMngCoreService modelMngCoreService;
|
||||
private final ModelTrainMngCoreService modelMngCoreService;
|
||||
private final DatasetCoreService datasetCoreService;
|
||||
private final SystemMetricsCoreService systemMetricsCoreService;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user