Compare commits
9 Commits
feat/dean/
...
7b15e5bb8c
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b15e5bb8c | |||
| 001ad73de7 | |||
| cefacb291b | |||
| 744cbb55a9 | |||
| 4863091406 | |||
| 70c28e0b54 | |||
| 9197819340 | |||
| f2500c33e6 | |||
| 18dc831b05 |
@@ -279,9 +279,7 @@ public class FIleChecker {
|
||||
return true;
|
||||
}
|
||||
|
||||
// kamco-nfs를 확인하는곳이 있어서 파라미터 추가 사용용도확인후 처리
|
||||
public static List<Folder> getFolderAll(
|
||||
String dirPath, String sortType, int maxDepth, String nfsRootDir) {
|
||||
public static List<Folder> getFolderAll(String dirPath, String sortType, int maxDepth) {
|
||||
|
||||
Path startPath = Paths.get(dirPath);
|
||||
|
||||
@@ -310,12 +308,8 @@ public class FIleChecker {
|
||||
String parentPath = path.getParent().toString();
|
||||
String fullPath = path.toAbsolutePath().toString();
|
||||
|
||||
// 이것이 필요한건가?
|
||||
// boolean isShowHide =
|
||||
// !parentFolderNm.equals("kamco-nfs"); // 폴더 리스트에
|
||||
// kamco-nfs 하위만 나오도록 처리
|
||||
boolean isShowHide =
|
||||
!parentFolderNm.equals(nfsRootDir); // 폴더 리스트에 nfsRootDir 하위만 나오도록 처리
|
||||
!parentFolderNm.equals("kamco-nfs"); // 폴더 리스트에 kamco-nfs 하위만 나오도록 처리
|
||||
File file = new File(fullPath);
|
||||
int childCnt = getChildFolderCount(file);
|
||||
String lastModified = getLastModified(file);
|
||||
@@ -363,8 +357,8 @@ public class FIleChecker {
|
||||
return folderList;
|
||||
}
|
||||
|
||||
public static List<Folder> getFolderAll(String dirPath, String nfsRootDir) {
|
||||
return getFolderAll(dirPath, "name", 1, nfsRootDir);
|
||||
public static List<Folder> getFolderAll(String dirPath) {
|
||||
return getFolderAll(dirPath, "name", 1);
|
||||
}
|
||||
|
||||
public static int getChildFolderCount(File directory) {
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ChngDetectMastDto {
|
||||
|
||||
@Schema(
|
||||
description = "탐지결과 절대경로명 /kamco_nas/export/{chnDtctId}",
|
||||
example = "{file.nfs}/dataset/export/D5F192EC76D34F6592035BE63A84F591")
|
||||
example = "/kamco-nfs/dataset/export/D5F192EC76D34F6592035BE63A84F591")
|
||||
private String pathNm;
|
||||
|
||||
@Schema(description = "사원번호", example = "123456")
|
||||
|
||||
@@ -66,11 +66,8 @@ public class GukYuinApiService {
|
||||
@Value("${gukyuin.cdi}")
|
||||
private String gukyuinCdiUrl;
|
||||
|
||||
@Value("${file.nfs}")
|
||||
private String nfs;
|
||||
|
||||
// @Value("${file.dataset-dir}")
|
||||
// private String datasetDir;
|
||||
@Value("${file.dataset-dir}")
|
||||
private String datasetDir;
|
||||
|
||||
@Transactional
|
||||
public ChngDetectMastDto.RegistResDto regist(
|
||||
@@ -456,10 +453,7 @@ public class GukYuinApiService {
|
||||
return new ResponseObj(ApiResponseCode.DUPLICATE_DATA, "이미 국유인 연동을 한 회차입니다.");
|
||||
}
|
||||
|
||||
// String kamconfsDatasetExportPathfsDatasetExportPath = "/kamco-nfs/dataset/export/";
|
||||
String kamconfsDatasetExportPathfsDatasetExportPath =
|
||||
String.format("%s%s", nfs, "/dataset/export/");
|
||||
if (!Files.isDirectory(Path.of(kamconfsDatasetExportPathfsDatasetExportPath + info.getUid()))) {
|
||||
if (!Files.isDirectory(Path.of(datasetDir + info.getUid()))) {
|
||||
return new ResponseObj(
|
||||
ApiResponseCode.NOT_FOUND_DATA, "파일 경로에 회차 실행 파일이 생성되지 않았습니다. 확인 부탁드립니다.");
|
||||
}
|
||||
@@ -474,7 +468,7 @@ public class GukYuinApiService {
|
||||
reqDto.setCrtrYr(String.valueOf(info.getTargetYyyy()));
|
||||
reqDto.setChnDtctSno(String.valueOf(maxStage + 1));
|
||||
reqDto.setChnDtctId(info.getUid());
|
||||
reqDto.setPathNm(kamconfsDatasetExportPathfsDatasetExportPath + info.getUid());
|
||||
reqDto.setPathNm(datasetDir + info.getUid());
|
||||
|
||||
// 1회차를 종료 상태로 처리하고 2회차를 보내야 함
|
||||
// 추론(learn), 학습데이터(inference) 둘 다 종료 처리
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.kamco.cd.kamcoback.inference;
|
||||
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.inference.service.InferenceRunService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.util.UUID;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "추론 실행", description = "추론 실행")
|
||||
@Log4j2
|
||||
@RequestMapping("/api/inference/run")
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class InferenceRunController {
|
||||
|
||||
private final InferenceRunService inferenceRunService;
|
||||
|
||||
@Operation(summary = "추론 진행 여부 확인", description = "어드민 홈 > 추론관리 > 추론관리 > 추론관리 목록")
|
||||
@ApiResponses(
|
||||
value = {
|
||||
@ApiResponse(
|
||||
responseCode = "200",
|
||||
description = "검색 성공",
|
||||
content =
|
||||
@Content(
|
||||
mediaType = "application/json",
|
||||
schema =
|
||||
@Schema(
|
||||
description = "진행 여부 (UUID 있으면 진행중)",
|
||||
type = "UUID",
|
||||
example = "44709877-2e27-4fc5-bacb-8e0328c69b64"))),
|
||||
@ApiResponse(responseCode = "400", description = "잘못된 검색 조건", content = @Content),
|
||||
@ApiResponse(responseCode = "500", description = "서버 오류", content = @Content)
|
||||
})
|
||||
@GetMapping
|
||||
public ApiResponseDto<Void> getProcessing(
|
||||
@Parameter(description = "비교년도", example = "2021") @RequestParam(required = false)
|
||||
Integer compareYear,
|
||||
@Parameter(description = "기준년도", example = "2022") @RequestParam(required = false)
|
||||
Integer targetYear,
|
||||
@Parameter(description = "모델 uuid") @RequestParam(required = false) UUID modelUuid) {
|
||||
|
||||
inferenceRunService.run(compareYear, targetYear, modelUuid);
|
||||
return ApiResponseDto.ok(null);
|
||||
}
|
||||
}
|
||||
@@ -676,4 +676,13 @@ public class InferenceResultDto {
|
||||
private Long m2ModelBatchId;
|
||||
private Long m3ModelBatchId;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MapSheetFallbackYearDto {
|
||||
private String mapSheetNum;
|
||||
private Integer mngYyyy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@ToString
|
||||
public class InferenceSendDto {
|
||||
|
||||
private static final String DEV_PATH_PREFIX = "kamco-nfs";
|
||||
private static final String PROD_PATH_PREFIX = "data";
|
||||
|
||||
private pred_requests_areas pred_requests_areas;
|
||||
private String model_version;
|
||||
private String cd_model_path;
|
||||
@@ -25,6 +28,23 @@ public class InferenceSendDto {
|
||||
private String cd_model_type;
|
||||
private Double priority;
|
||||
|
||||
// 프로덕션은 경로가 바뀜
|
||||
public void changeValForProd() {
|
||||
if (pred_requests_areas != null) {
|
||||
pred_requests_areas.changeValForProd();
|
||||
log.info("[CHANGE]pred_requests_areas={}", pred_requests_areas);
|
||||
}
|
||||
if (this.cd_model_path != null) {
|
||||
this.cd_model_path = this.cd_model_path.replace(DEV_PATH_PREFIX, PROD_PATH_PREFIX);
|
||||
}
|
||||
if (this.cls_model_path != null) {
|
||||
this.cls_model_path = this.cls_model_path.replace(DEV_PATH_PREFIX, PROD_PATH_PREFIX);
|
||||
}
|
||||
if (this.cd_model_config != null) {
|
||||
this.cd_model_config = this.cd_model_config.replace(DEV_PATH_PREFIX, PROD_PATH_PREFIX);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@@ -36,5 +56,19 @@ public class InferenceSendDto {
|
||||
private Integer input2_year;
|
||||
private String input1_scene_path;
|
||||
private String input2_scene_path;
|
||||
|
||||
public void changeValForProd() {
|
||||
// ai팀에서 kamco-nfs를 data로 세팅했음
|
||||
if (this.input1_scene_path != null) {
|
||||
this.input1_scene_path =
|
||||
this.input1_scene_path.replace(
|
||||
InferenceSendDto.DEV_PATH_PREFIX, InferenceSendDto.PROD_PATH_PREFIX);
|
||||
}
|
||||
if (this.input2_scene_path != null) {
|
||||
this.input2_scene_path =
|
||||
this.input2_scene_path.replace(
|
||||
InferenceSendDto.DEV_PATH_PREFIX, InferenceSendDto.PROD_PATH_PREFIX);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ public class InferenceManualService {
|
||||
|
||||
if (resultList.isEmpty()) {}
|
||||
|
||||
for (InferenceResultsTestingDto.Basic result : resultList) {}
|
||||
for (InferenceResultsTestingDto.Basic result : resultList) {
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.DetectOption;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceLearnDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceServerStatusDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.InferenceStatusDetailDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetNumDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.ResultList;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.SaveInferenceAiDto;
|
||||
@@ -46,12 +47,14 @@ import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
@@ -119,92 +122,223 @@ public class InferenceResultService {
|
||||
|
||||
@Transactional
|
||||
public UUID run(InferenceResultDto.RegReq req) {
|
||||
if (req.getDetectOption().equals(DetectOption.EXCL.getId())) {
|
||||
return runExcl(req);
|
||||
}
|
||||
return runPrev(req);
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 옵션 추론제외 실행
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
public UUID runExcl(InferenceResultDto.RegReq req) {
|
||||
// target 도엽 조회
|
||||
List<MngListDto> targetDtoList = mapSheetMngCoreService.getHstMapSheetList(req);
|
||||
List<String> compareList = mapSheetMngCoreService.getMapSheetMngHst(req.getCompareYyyy());
|
||||
|
||||
// target 리스트 추출 (null 제거 + 중복 제거)
|
||||
List<String> targetList =
|
||||
mapSheetMngCoreService.getHstMapSheetList(req).stream()
|
||||
targetDtoList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
log.info(
|
||||
"hst list count compareList = {}, targetList = {}", compareList.size(), targetList.size());
|
||||
|
||||
Set<String> compareSet = new HashSet<>(compareList);
|
||||
Set<String> targetSet = new HashSet<>(targetList);
|
||||
|
||||
long intersectionCount =
|
||||
targetSet.stream()
|
||||
// compare 도엽번호 리스트 조회 (null 제거 + 중복 제거)
|
||||
List<String> compareList =
|
||||
mapSheetMngCoreService.getMapSheetNumByHst(req.getCompareYyyy()).stream()
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.filter(compareSet::contains)
|
||||
.count(); // compare와 target에 공통으로 존재하는 도협 수
|
||||
|
||||
long excludedTargetCount =
|
||||
targetSet.stream()
|
||||
.distinct()
|
||||
.filter(s -> !compareSet.contains(s))
|
||||
.count(); // target 에만 존재하는 도협 수 (compare 에는 없음)
|
||||
|
||||
long onlyCompareCount =
|
||||
compareSet.stream()
|
||||
.distinct()
|
||||
.filter(s -> !targetSet.contains(s))
|
||||
.count(); // compare 에만 존재하는 도협 수 (target 에는 없음)
|
||||
|
||||
log.info(
|
||||
"""
|
||||
===== MapSheet Year Comparison =====
|
||||
target Total: {}
|
||||
compare Total: {}
|
||||
Intersection: {}
|
||||
target Only (Excluded from compare): {}
|
||||
compare Only: {}
|
||||
====================================
|
||||
""",
|
||||
targetSet.size(),
|
||||
compareSet.size(),
|
||||
intersectionCount,
|
||||
excludedTargetCount,
|
||||
onlyCompareCount);
|
||||
|
||||
List<String> filteredTargetList =
|
||||
targetSet.stream() // target 기준으로
|
||||
.filter(compareSet::contains) // compare에 있는 도협만 남김
|
||||
.toList();
|
||||
|
||||
Scene modelComparePath =
|
||||
getSceneInference(req.getCompareYyyy().toString(), filteredTargetList, "", "");
|
||||
// compare 기준
|
||||
Set<String> compareSet = new HashSet<>(compareList);
|
||||
|
||||
Scene modelTargetPath =
|
||||
getSceneInference(req.getTargetYyyy().toString(), filteredTargetList, "", "");
|
||||
// target 기준으로 compare에 존재하는 도엽만 필터링
|
||||
List<String> filteredTargetList = targetList.stream().filter(compareSet::contains).toList();
|
||||
|
||||
// 작은 쪽 기준으로 탐지건수/파일생성 리스트 결정
|
||||
List<ImageFeature> imageFeatureList;
|
||||
if (modelComparePath.getFeatures().size() <= modelTargetPath.getFeatures().size()) {
|
||||
imageFeatureList = modelComparePath.getFeatures();
|
||||
} else {
|
||||
imageFeatureList = modelTargetPath.getFeatures();
|
||||
}
|
||||
// 도엽 비교 로그 출력
|
||||
logYearComparison(targetList, compareList, filteredTargetList);
|
||||
|
||||
// imageFeatureList 기준 sceneId Set
|
||||
Set<String> sceneIdSet =
|
||||
imageFeatureList.stream()
|
||||
.map(ImageFeature::getSceneId)
|
||||
// compare geojson 파일 생성
|
||||
Scene compareScene =
|
||||
getSceneInference(
|
||||
req.getCompareYyyy().toString(), // 기준년도
|
||||
filteredTargetList, // 교집합 도엽
|
||||
req.getMapSheetScope(), // ALL / 부분
|
||||
req.getDetectOption()); // EXCL / PREV
|
||||
|
||||
// target geojson 파일 생성
|
||||
Scene targetScene =
|
||||
getSceneInference(
|
||||
req.getTargetYyyy().toString(), // 대상년도
|
||||
filteredTargetList, // 교집합 도엽
|
||||
req.getMapSheetScope(),
|
||||
req.getDetectOption());
|
||||
|
||||
// 추론 실행
|
||||
return executeInference(
|
||||
req,
|
||||
targetDtoList, // 전체 target 목록
|
||||
filteredTargetList, // 최종 추론 대상
|
||||
compareScene, // compare geojson
|
||||
targetScene // target geojson
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 옵션 이전 년도 도엽 사용 실행
|
||||
*
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@Transactional
|
||||
public UUID runPrev(InferenceResultDto.RegReq req) {
|
||||
// target 목록 조회
|
||||
List<MngListDto> targetDtoList = mapSheetMngCoreService.getHstMapSheetList(req);
|
||||
|
||||
// target 도엽번호 리스트 추출
|
||||
List<String> targetList =
|
||||
targetDtoList.stream()
|
||||
.map(MngListDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
// target 포함 여부 판단
|
||||
Set<String> targetSet = new HashSet<>(targetList);
|
||||
|
||||
// compare 목록 조회
|
||||
List<MapSheetFallbackYearDto> compareDtoList =
|
||||
new ArrayList<>(mapSheetMngCoreService.getMapSheetNumDtoByHst(req.getCompareYyyy()));
|
||||
|
||||
// compare 도엽번호 Set 구성
|
||||
Set<String> compareSet =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// targetList(List<MngListDto>) 리턴용으로 필터링
|
||||
// arget에는 있으나 compare에는 없는 도엽 추출
|
||||
List<String> remainingTargetList =
|
||||
targetList.stream().filter(s -> !compareSet.contains(s)).toList();
|
||||
|
||||
// fallback년도 도엽 조회
|
||||
List<MapSheetFallbackYearDto> fallbackYearDtoList =
|
||||
mapSheetMngCoreService.findFallbackCompareYearByMapSheets(
|
||||
req.getTargetYyyy(), // 대상년도 기준
|
||||
remainingTargetList // compare에 없는 도엽들
|
||||
);
|
||||
|
||||
// 기존 compare , fallback 합치기
|
||||
compareDtoList.addAll(fallbackYearDtoList);
|
||||
|
||||
// mapSheetNum 기준 중복 제거 (기존 compare 우선 유지)
|
||||
compareDtoList =
|
||||
new ArrayList<>(
|
||||
compareDtoList.stream()
|
||||
.filter(d -> d.getMapSheetNum() != null)
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
MapSheetFallbackYearDto::getMapSheetNum,
|
||||
Function.identity(),
|
||||
(existing, replacement) -> existing, // 기존 우선
|
||||
LinkedHashMap::new))
|
||||
.values());
|
||||
|
||||
// 최종 compare 도엽 Set 구성
|
||||
Set<String> availableCompareSheets =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 최종 추론 대상 도엽
|
||||
// target 중 compare(fallback)에 존재하는 도엽만 추출
|
||||
List<String> filteredTargetList =
|
||||
targetList.stream().filter(availableCompareSheets::contains).toList();
|
||||
|
||||
// compare only 계산 (target에는 없는 compare 도엽 수)
|
||||
long compareOnlyCount =
|
||||
compareDtoList.stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(s -> s != null && !targetSet.contains(s))
|
||||
.count();
|
||||
|
||||
// 연도별 도엽 비교 로그 출력
|
||||
log.info(
|
||||
"""
|
||||
===== MapSheet Year Comparison =====
|
||||
target Total: {}
|
||||
compare Total: {}
|
||||
Intersection: {}
|
||||
target Only (Excluded): {}
|
||||
compare Only: {}
|
||||
====================================
|
||||
""",
|
||||
targetList.size(), // target count
|
||||
compareDtoList.size(), // compare count
|
||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
||||
|
||||
// compareDtoList도 최종 교집합 기준으로 필터
|
||||
Set<String> filteredTargetSet = new HashSet<>(filteredTargetList);
|
||||
|
||||
List<MapSheetFallbackYearDto> filteredCompareDtoList =
|
||||
compareDtoList.stream()
|
||||
.filter(d -> d.getMapSheetNum() != null)
|
||||
.filter(d -> filteredTargetSet.contains(d.getMapSheetNum()))
|
||||
.toList();
|
||||
|
||||
// compare 기준 geojson 생성 (년도 fallback 반영)
|
||||
Scene compareScene =
|
||||
getSceneInference(
|
||||
filteredCompareDtoList,
|
||||
req.getCompareYyyy().toString(),
|
||||
req.getMapSheetScope(),
|
||||
req.getDetectOption());
|
||||
|
||||
// target 기준 geojson 생성
|
||||
Scene targetScene =
|
||||
getSceneInference(
|
||||
req.getTargetYyyy().toString(),
|
||||
filteredTargetList,
|
||||
req.getMapSheetScope(),
|
||||
req.getDetectOption());
|
||||
|
||||
// AI 추론 실행
|
||||
return executeInference(req, targetDtoList, filteredTargetList, compareScene, targetScene);
|
||||
}
|
||||
|
||||
/**
|
||||
* learn 테이블 저장 및 AI 추론 API 호출
|
||||
*
|
||||
* @param req
|
||||
* @param targetDtoList
|
||||
* @param filteredTargetList
|
||||
* @param modelComparePath
|
||||
* @param modelTargetPath
|
||||
* @return
|
||||
*/
|
||||
private UUID executeInference(
|
||||
InferenceResultDto.RegReq req,
|
||||
List<MngListDto> targetDtoList,
|
||||
List<String> filteredTargetList,
|
||||
Scene modelComparePath,
|
||||
Scene modelTargetPath) {
|
||||
Set<String> filteredSet = new HashSet<>(filteredTargetList);
|
||||
|
||||
List<MngListDto> newTargetList =
|
||||
targetDtoList.stream()
|
||||
.filter(m -> m.getMapSheetNum() != null)
|
||||
.filter(m -> sceneIdSet.contains(m.getMapSheetNum()))
|
||||
.filter(m -> filteredSet.contains(m.getMapSheetNum()))
|
||||
.toList();
|
||||
|
||||
// 목록 및 추론 대상 도엽정보 저장
|
||||
UUID uuid = inferenceResultCoreService.saveInferenceInfo(req, newTargetList);
|
||||
|
||||
// ai 서버에 전달할 파라미터 생성
|
||||
pred_requests_areas predRequestsAreas = new pred_requests_areas();
|
||||
predRequestsAreas.setInput1_year(req.getCompareYyyy());
|
||||
predRequestsAreas.setInput2_year(req.getTargetYyyy());
|
||||
@@ -215,12 +349,9 @@ public class InferenceResultService {
|
||||
m1.setPred_requests_areas(predRequestsAreas);
|
||||
|
||||
log.info("[INFERENCE] Start m1 = {}", m1);
|
||||
m1.setPred_requests_areas(predRequestsAreas);
|
||||
|
||||
// ai 추론 실행 api 호출
|
||||
Long batchId = ensureAccepted(m1);
|
||||
|
||||
// ai 추론 실행후 응답값 update
|
||||
SaveInferenceAiDto saveInferenceAiDto = new SaveInferenceAiDto();
|
||||
saveInferenceAiDto.setUuid(uuid);
|
||||
saveInferenceAiDto.setBatchId(batchId);
|
||||
@@ -230,11 +361,42 @@ public class InferenceResultService {
|
||||
saveInferenceAiDto.setModelComparePath(modelComparePath.getFilePath());
|
||||
saveInferenceAiDto.setModelTargetPath(modelTargetPath.getFilePath());
|
||||
saveInferenceAiDto.setModelStartDttm(ZonedDateTime.now());
|
||||
|
||||
inferenceResultCoreService.update(saveInferenceAiDto);
|
||||
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* EXCL 로그
|
||||
*
|
||||
* @param targetList
|
||||
* @param compareList
|
||||
* @param filteredTargetList
|
||||
*/
|
||||
private void logYearComparison(
|
||||
List<String> targetList, List<String> compareList, List<String> filteredTargetList) {
|
||||
Set<String> targetSet = new HashSet<>(targetList);
|
||||
|
||||
long compareOnlyCount = compareList.stream().filter(s -> !targetSet.contains(s)).count();
|
||||
|
||||
log.info(
|
||||
"""
|
||||
===== MapSheet Year Comparison =====
|
||||
target Total: {}
|
||||
compare Total: {}
|
||||
Intersection: {}
|
||||
target Only (Excluded): {}
|
||||
compare Only: {}
|
||||
====================================
|
||||
""",
|
||||
targetList.size(), // target count
|
||||
compareList.size(), // compare count
|
||||
filteredTargetList.size(), // target 기준으로 compare 비교하여 최종 추론할 도엽 count
|
||||
targetList.size() - filteredTargetList.size(), // compare에 존재하지 않는 target 도엽 수
|
||||
compareOnlyCount); // target 에 존재하지 않는 compare 도엽수
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 실행 정보 생성
|
||||
*
|
||||
@@ -265,31 +427,31 @@ public class InferenceResultService {
|
||||
|
||||
List<TotalListDto> totalNumList = new ArrayList<>();
|
||||
|
||||
// if (DetectOption.EXCL.getId().equals(req.getDetectOption())) {
|
||||
// // "추론제외" 일때 전년도 이전 값이 있어도 전년도 도엽이 없으면 비교 안함
|
||||
// for (MngListCompareDto dto : compareList) {
|
||||
// if (Objects.equals(dto.getBeforeYear(), req.getCompareYyyy())) {
|
||||
// TotalListDto totalDto = new TotalListDto();
|
||||
// totalDto.setBeforeYear(dto.getBeforeYear() == null ? 0 : dto.getBeforeYear());
|
||||
// totalDto.setMapSheetNum(dto.getMapSheetNum());
|
||||
// totalNumList.add(totalDto);
|
||||
// }
|
||||
// }
|
||||
// } else if (DetectOption.PREV.getId().equals(req.getDetectOption())) {
|
||||
// // "이전 년도 도엽 사용" 이면 전년도 이전 도엽도 사용
|
||||
// for (MngListCompareDto dto : compareList) {
|
||||
// if (dto.getBeforeYear() != 0) {
|
||||
// TotalListDto totalDto = new TotalListDto();
|
||||
// totalDto.setBeforeYear(dto.getBeforeYear() == null ? 0 : dto.getBeforeYear());
|
||||
// totalDto.setMapSheetNum(dto.getMapSheetNum());
|
||||
// totalNumList.add(totalDto);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (totalNumList.isEmpty()) {
|
||||
// throw new CustomApiException("NOT_FOUND_COMPARE_YEAR", HttpStatus.NOT_FOUND);
|
||||
// }
|
||||
if (DetectOption.EXCL.getId().equals(req.getDetectOption())) {
|
||||
// "추론제외" 일때 전년도 이전 값이 있어도 전년도 도엽이 없으면 비교 안함
|
||||
for (MngListCompareDto dto : compareList) {
|
||||
if (Objects.equals(dto.getBeforeYear(), req.getCompareYyyy())) {
|
||||
TotalListDto totalDto = new TotalListDto();
|
||||
totalDto.setBeforeYear(dto.getBeforeYear() == null ? 0 : dto.getBeforeYear());
|
||||
totalDto.setMapSheetNum(dto.getMapSheetNum());
|
||||
totalNumList.add(totalDto);
|
||||
}
|
||||
}
|
||||
} else if (DetectOption.PREV.getId().equals(req.getDetectOption())) {
|
||||
// "이전 년도 도엽 사용" 이면 전년도 이전 도엽도 사용
|
||||
for (MngListCompareDto dto : compareList) {
|
||||
if (dto.getBeforeYear() != 0) {
|
||||
TotalListDto totalDto = new TotalListDto();
|
||||
totalDto.setBeforeYear(dto.getBeforeYear() == null ? 0 : dto.getBeforeYear());
|
||||
totalDto.setMapSheetNum(dto.getMapSheetNum());
|
||||
totalNumList.add(totalDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalNumList.isEmpty()) {
|
||||
throw new CustomApiException("NOT_FOUND_COMPARE_YEAR", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
// 사용할 영상파일 년도 기록 및 추론에 포함되는지 설정
|
||||
for (MngListDto target : targetList) {
|
||||
@@ -460,6 +622,7 @@ public class InferenceResultService {
|
||||
log.info("[CHANGE INFERENCE] profile = {} Inforence req", profile);
|
||||
log.info("========================================================");
|
||||
log.info("");
|
||||
dto.changeValForProd();
|
||||
}
|
||||
|
||||
// 1) 요청 로그
|
||||
@@ -470,15 +633,13 @@ public class InferenceResultService {
|
||||
}
|
||||
|
||||
// 2) local 환경 임시 처리
|
||||
// if ("local".equals(profile)) {
|
||||
// if (dto.getPred_requests_areas() == null) {
|
||||
// throw new IllegalStateException("pred_requests_areas is null");
|
||||
// }
|
||||
//
|
||||
// dto.getPred_requests_areas().setInput1_scene_path("/kamco-nfs/requests/2023_local.geojson");
|
||||
//
|
||||
// dto.getPred_requests_areas().setInput2_scene_path("/kamco-nfs/requests/2024_local.geojson");
|
||||
// }
|
||||
if ("local".equals(profile)) {
|
||||
if (dto.getPred_requests_areas() == null) {
|
||||
throw new IllegalStateException("pred_requests_areas is null");
|
||||
}
|
||||
dto.getPred_requests_areas().setInput1_scene_path("/kamco-nfs/requests/2023_local.geojson");
|
||||
dto.getPred_requests_areas().setInput2_scene_path("/kamco-nfs/requests/2024_local.geojson");
|
||||
}
|
||||
|
||||
// 3) HTTP 호출
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -580,6 +741,23 @@ public class InferenceResultService {
|
||||
yyyy, mapSheetNums, mapSheetScope, detectOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* 년도 별로 조회하여 geojson 파일 생성
|
||||
*
|
||||
* @param yearDtos
|
||||
* @param year
|
||||
* @param mapSheetScope
|
||||
* @param detectOption
|
||||
* @return
|
||||
*/
|
||||
private Scene getSceneInference(
|
||||
List<MapSheetFallbackYearDto> yearDtos,
|
||||
String year,
|
||||
String mapSheetScope,
|
||||
String detectOption) {
|
||||
return mapSheetMngCoreService.getSceneInference(yearDtos, year, mapSheetScope, detectOption);
|
||||
}
|
||||
|
||||
/**
|
||||
* 분석결과 요약정보
|
||||
*
|
||||
|
||||
@@ -47,9 +47,6 @@ public class MapSheetMngService {
|
||||
private final UploadService uploadService;
|
||||
private final UserUtil userUtil = new UserUtil();
|
||||
|
||||
@Value("${file.root}")
|
||||
private String nfsRootDir;
|
||||
|
||||
@Value("${file.sync-root-dir}")
|
||||
private String syncRootDir;
|
||||
|
||||
@@ -114,6 +111,7 @@ public class MapSheetMngService {
|
||||
public DmlReturn uploadPair(
|
||||
MultipartFile tfwFile, String tifFile, Long hstUid, Long tifFileSize) {
|
||||
|
||||
String rootPath = syncRootDir;
|
||||
String tmpPath = syncTmpDir;
|
||||
|
||||
DmlReturn dmlReturn = new DmlReturn("success", "UPLOAD COMPLETE");
|
||||
@@ -135,7 +133,6 @@ public class MapSheetMngService {
|
||||
return dmlReturn;
|
||||
}
|
||||
|
||||
// TODO 삭제?
|
||||
MngDto mngDto = mapSheetMngCoreService.findMapSheetMng(errDto.getMngYyyy());
|
||||
|
||||
// 중복체크 -> 도엽50k/uuid 경로에 업로드 할 거라 overwrite 되지 않음
|
||||
@@ -343,7 +340,7 @@ public class MapSheetMngService {
|
||||
|
||||
log.info("[FIND_FOLDER] DIR : {}", dirPath);
|
||||
List<FIleChecker.Folder> folderList =
|
||||
FIleChecker.getFolderAll(dirPath, nfsRootDir).stream()
|
||||
FIleChecker.getFolderAll(dirPath).stream()
|
||||
.filter(dir -> dir.getIsValid().equals(true))
|
||||
.toList();
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.Scene;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.DetectOption;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListCompareDto;
|
||||
@@ -24,13 +25,14 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -233,27 +235,52 @@ public class MapSheetMngCoreService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 추론 실행에 필요한 geojson 파일 생성
|
||||
* geojson 생성
|
||||
*
|
||||
* @param yyyy 영상관리 파일별 년도
|
||||
* @param scenes 5k 도엽 번호 리스트
|
||||
* @param mapSheetScope EXCL : 추론제외, PREV 이전 년도 도엽 사용
|
||||
* @param yyyy
|
||||
* @param scenes
|
||||
* @param mapSheetScope
|
||||
* @param detectOption
|
||||
* @return
|
||||
*/
|
||||
public Scene getSceneInference(
|
||||
String yyyy, List<String> scenes, String mapSheetScope, String detectOption) {
|
||||
List<ImageFeature> features = loadSceneInferenceBySheets(yyyy, scenes);
|
||||
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
/**
|
||||
* geojson 생성
|
||||
*
|
||||
* @param yearDtos
|
||||
* @param yyyy
|
||||
* @param mapSheetScope
|
||||
* @param detectOption
|
||||
* @return
|
||||
*/
|
||||
public Scene getSceneInference(
|
||||
List<MapSheetFallbackYearDto> yearDtos,
|
||||
String yyyy,
|
||||
String mapSheetScope,
|
||||
String detectOption) {
|
||||
List<ImageFeature> features = loadSceneInferenceByFallbackYears(yearDtos);
|
||||
return writeSceneGeoJson(yyyy, mapSheetScope, detectOption, features);
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 경로/이름 , 파일 생성 , 도엽번호 반환
|
||||
*
|
||||
* @param yyyy
|
||||
* @param mapSheetScope
|
||||
* @param detectOption
|
||||
* @param sceneInference
|
||||
* @return Scene
|
||||
*/
|
||||
private Scene writeSceneGeoJson(
|
||||
String yyyy, String mapSheetScope, String detectOption, List<ImageFeature> sceneInference) {
|
||||
boolean isAll = MapSheetScope.ALL.getId().equals(mapSheetScope);
|
||||
String optionSuffix = buildOptionSuffix(detectOption);
|
||||
|
||||
String optionSuffix = "";
|
||||
if (DetectOption.EXCL.getId().equals(detectOption)) {
|
||||
optionSuffix = "_EXCL";
|
||||
} else if (DetectOption.PREV.getId().equals(detectOption)) {
|
||||
optionSuffix = "_PREV";
|
||||
}
|
||||
|
||||
// 1) 경로/파일명 결정
|
||||
String targetDir =
|
||||
"local".equals(activeEnv) ? System.getProperty("user.home") + "/geojson" : inferenceDir;
|
||||
|
||||
@@ -264,24 +291,11 @@ public class MapSheetMngCoreService {
|
||||
|
||||
Path outputPath = Paths.get(targetDir, filename);
|
||||
|
||||
// 2) ALL일 때만 재사용
|
||||
// if (isAll && Files.exists(outputPath)) {
|
||||
// return outputPath.toString();
|
||||
// }
|
||||
|
||||
// 3) 데이터 조회
|
||||
List<ImageFeature> sceneInference = mapSheetMngRepository.getSceneInference(yyyy, scenes);
|
||||
|
||||
if (sceneInference == null || sceneInference.isEmpty()) {
|
||||
log.warn(
|
||||
"NOT_FOUND_TARGET_YEAR: yyyy={}, isAll={}, scenesSize={}",
|
||||
yyyy,
|
||||
isAll,
|
||||
scenes == null ? 0 : scenes.size());
|
||||
log.warn("NOT_FOUND_TARGET_YEAR: yyyy={}, isAll={}, featuresSize={}", yyyy, isAll, 0);
|
||||
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
// 4) 파일 생성
|
||||
try {
|
||||
log.info("create Directories outputPath: {}", outputPath);
|
||||
log.info(
|
||||
@@ -291,15 +305,15 @@ public class MapSheetMngCoreService {
|
||||
targetDir,
|
||||
filename);
|
||||
log.info("outputPath={}, parent={}", outputPath.toAbsolutePath(), outputPath.getParent());
|
||||
|
||||
Files.createDirectories(outputPath.getParent());
|
||||
|
||||
new GeoJsonFileWriter()
|
||||
.exportToFile(sceneInference, "scene_inference_" + yyyy, 5186, outputPath.toString());
|
||||
log.info("GeoJsonFileWriter: {}", "scene_inference_" + yyyy);
|
||||
|
||||
Scene scene = new Scene();
|
||||
scene.setFeatures(sceneInference);
|
||||
scene.setFilePath(outputPath.toString());
|
||||
|
||||
return scene;
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -309,6 +323,77 @@ public class MapSheetMngCoreService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* geojson 파일명 Suffix
|
||||
*
|
||||
* @param detectOption
|
||||
* @return
|
||||
*/
|
||||
private String buildOptionSuffix(String detectOption) {
|
||||
if (DetectOption.EXCL.getId().equals(detectOption)) return "_EXCL";
|
||||
if (DetectOption.PREV.getId().equals(detectOption)) return "_PREV";
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 년도, 도엽번호로 조회
|
||||
*
|
||||
* @param yyyy
|
||||
* @param scenes
|
||||
* @return ImageFeature
|
||||
*/
|
||||
private List<ImageFeature> loadSceneInferenceBySheets(String yyyy, List<String> scenes) {
|
||||
List<ImageFeature> sceneInference = mapSheetMngRepository.getSceneInference(yyyy, scenes);
|
||||
|
||||
if (sceneInference == null || sceneInference.isEmpty()) {
|
||||
log.warn(
|
||||
"NOT_FOUND_TARGET_YEAR: yyyy={}, scenesSize={}",
|
||||
yyyy,
|
||||
scenes == null ? 0 : scenes.size());
|
||||
throw new CustomApiException("NOT_FOUND_TARGET_YEAR", HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return sceneInference;
|
||||
}
|
||||
|
||||
/**
|
||||
* 년도별로 나눠 조회
|
||||
*
|
||||
* @param yearDtos
|
||||
* @return ImageFeature
|
||||
*/
|
||||
private List<ImageFeature> loadSceneInferenceByFallbackYears(
|
||||
List<MapSheetFallbackYearDto> yearDtos) {
|
||||
if (yearDtos == null || yearDtos.isEmpty()) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
Map<Integer, List<MapSheetFallbackYearDto>> groupedByYear =
|
||||
yearDtos.stream()
|
||||
.filter(d -> d.getMngYyyy() != null && d.getMapSheetNum() != null)
|
||||
.collect(Collectors.groupingBy(MapSheetFallbackYearDto::getMngYyyy));
|
||||
|
||||
List<ImageFeature> sceneInference = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<Integer, List<MapSheetFallbackYearDto>> entry : groupedByYear.entrySet()) {
|
||||
Integer year = entry.getKey();
|
||||
|
||||
List<String> sheetNums =
|
||||
entry.getValue().stream()
|
||||
.map(MapSheetFallbackYearDto::getMapSheetNum)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.toList();
|
||||
|
||||
List<ImageFeature> temp = mapSheetMngRepository.getSceneInference(year.toString(), sheetNums);
|
||||
|
||||
if (temp != null && !temp.isEmpty()) {
|
||||
sceneInference.addAll(temp);
|
||||
}
|
||||
}
|
||||
|
||||
return sceneInference;
|
||||
}
|
||||
|
||||
/**
|
||||
* 변화탐지 실행 가능 기준 년도 조회
|
||||
*
|
||||
@@ -343,8 +428,24 @@ public class MapSheetMngCoreService {
|
||||
return mapSheetMngYearRepository.findByHstMapSheetCompareList(mngYyyy, mapId);
|
||||
}
|
||||
|
||||
public List<String> getMapSheetMngHst(Integer year) {
|
||||
public List<String> getMapSheetNumByHst(Integer year) {
|
||||
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
|
||||
return entity.stream().map(MapSheetMngHstEntity::getMapSheetNum).toList();
|
||||
}
|
||||
|
||||
public List<MapSheetFallbackYearDto> getMapSheetNumDtoByHst(Integer year) {
|
||||
List<MapSheetMngHstEntity> entity = mapSheetMngRepository.getMapSheetMngHst(year);
|
||||
return entity.stream()
|
||||
.map(
|
||||
e ->
|
||||
new MapSheetFallbackYearDto(
|
||||
e.getMapSheetNum(), e.getMngYyyy() // 조회 기준 연도
|
||||
))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
||||
Integer year, List<String> mapIds) {
|
||||
return mapSheetMngRepository.findFallbackCompareYearByMapSheets(year, mapIds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.kamco.cd.kamcoback.postgres.repository.mapsheet;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.MngListDto;
|
||||
@@ -82,4 +83,7 @@ public interface MapSheetMngRepositoryCustom {
|
||||
void insertMapSheetMngTile(@Valid AddReq addReq);
|
||||
|
||||
List<MapSheetMngHstEntity> getMapSheetMngHst(Integer year);
|
||||
|
||||
List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
||||
Integer year, List<String> mapIds);
|
||||
}
|
||||
|
||||
@@ -5,12 +5,14 @@ import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngEntity.mapSheet
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngFileEntity.mapSheetMngFileEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngHstEntity.mapSheetMngHstEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngTileEntity.mapSheetMngTileEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QMapSheetMngYearYnEntity.mapSheetMngYearYnEntity;
|
||||
import static com.kamco.cd.kamcoback.postgres.entity.QYearEntity.yearEntity;
|
||||
import static com.querydsl.core.types.dsl.Expressions.nullExpression;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.CommonUseStatus;
|
||||
import com.kamco.cd.kamcoback.common.geometry.GeoJsonFileWriter.ImageFeature;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetFallbackYearDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.MapSheetScope;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto;
|
||||
import com.kamco.cd.kamcoback.mapsheet.dto.MapSheetMngDto.AddReq;
|
||||
@@ -1119,4 +1121,24 @@ public class MapSheetMngRepositoryImpl extends QuerydslRepositorySupport
|
||||
.and(mapSheetMngFileEntity.fileExt.eq("tif")))
|
||||
.fetch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MapSheetFallbackYearDto> findFallbackCompareYearByMapSheets(
|
||||
Integer year, List<String> mapIds) {
|
||||
BooleanBuilder builder = new BooleanBuilder();
|
||||
builder.and(mapSheetMngYearYnEntity.id.mapSheetNum.in(mapIds));
|
||||
builder.and(mapSheetMngYearYnEntity.id.mngYyyy.lt(year));
|
||||
builder.and(mapSheetMngYearYnEntity.yn.eq("Y"));
|
||||
|
||||
return queryFactory
|
||||
.select(
|
||||
Projections.constructor(
|
||||
MapSheetFallbackYearDto.class,
|
||||
mapSheetMngYearYnEntity.id.mapSheetNum,
|
||||
mapSheetMngYearYnEntity.id.mngYyyy.max()))
|
||||
.from(mapSheetMngYearYnEntity)
|
||||
.where(builder)
|
||||
.groupBy(mapSheetMngYearYnEntity.id.mapSheetNum)
|
||||
.fetch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,23 +381,29 @@ public class MapSheetInferenceJobService {
|
||||
log.warn("not InferenceSendDto dto");
|
||||
throw new CustomApiException("BAD_REQUEST", HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
// [중복운영환경일때 경로수정 dean 260226
|
||||
if (profile != null && profile.equals("prod")) {
|
||||
log.info("========================================================");
|
||||
log.info("[CHANGE INFERENCE] profile = {} Inforence req", profile);
|
||||
log.info("========================================================");
|
||||
log.info("");
|
||||
dto.changeValForProd();
|
||||
}
|
||||
|
||||
// 1) 요청 로그
|
||||
log.info("");
|
||||
log.info("========================================================");
|
||||
log.info("[SEND INFERENCE] Inference request dto= {}", dto);
|
||||
log.info("[SEND INFERENCE] Inference request dto={}", dto);
|
||||
log.info("========================================================");
|
||||
log.info("");
|
||||
// 2) local 환경 임시 처리
|
||||
// if ("local".equals(profile)) {
|
||||
// if (dto.getPred_requests_areas() == null) {
|
||||
// throw new IllegalStateException("pred_requests_areas is null");
|
||||
// }
|
||||
//
|
||||
// dto.getPred_requests_areas().setInput1_scene_path("/kamco-nfs/requests/2023_local.geojson");
|
||||
//
|
||||
// dto.getPred_requests_areas().setInput2_scene_path("/kamco-nfs/requests/2024_local.geojson");
|
||||
// }
|
||||
if ("local".equals(profile)) {
|
||||
if (dto.getPred_requests_areas() == null) {
|
||||
throw new IllegalStateException("pred_requests_areas is null");
|
||||
}
|
||||
dto.getPred_requests_areas().setInput1_scene_path("/kamco-nfs/requests/2023_local.geojson");
|
||||
dto.getPred_requests_areas().setInput2_scene_path("/kamco-nfs/requests/2024_local.geojson");
|
||||
}
|
||||
|
||||
// 3) HTTP 호출
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TrainingDataReviewJobService {
|
||||
@Value("${spring.profiles.active}")
|
||||
private String profile;
|
||||
|
||||
@Value("${file.training-data.geojson-dir}")
|
||||
@Value("${training-data.geojson-dir}")
|
||||
private String trainingDataDir;
|
||||
|
||||
private boolean isLocalProfile() {
|
||||
|
||||
@@ -89,17 +89,36 @@ mapsheet:
|
||||
shp:
|
||||
baseurl: /app/tmp/detect/result #현재사용안함
|
||||
|
||||
|
||||
|
||||
file:
|
||||
root: kamco-nfs
|
||||
nfs: /kamco-nfs
|
||||
pt-path: ${file.nfs}/ckpt/model/v6-cls-checkpoints/
|
||||
#sync-root-dir: D:/kamco-nfs/images/
|
||||
sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: /kamco-nfs/requests/temp # image upload temp dir
|
||||
#sync-tmp-dir: ${file.sync-root-dir}/tmp
|
||||
sync-file-extention: tfw,tif
|
||||
# sync-auto-exception-start-year: 2024
|
||||
# sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
#dataset-dir: D:/kamco-nfs/model_output/
|
||||
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
#model-dir: D:/kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
pt-path: /kamco-nfs/ckpt/model/v6-cls-checkpoints/
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
|
||||
dataset-response: /kamco-nfs/dataset/response/
|
||||
|
||||
inference:
|
||||
nfs: /kamco-nfs
|
||||
url: http://192.168.2.183:8000/jobs
|
||||
batch-url: http://192.168.2.183:8000/batches
|
||||
jar-path: ${inference.nfs}/repo/jar/shp-exporter.jar
|
||||
geojson-dir: /kamco-nfs/requests/ # 추론실행을 위한 파일생성경로
|
||||
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
@@ -107,6 +126,9 @@ gukyuin:
|
||||
url: http://192.168.2.129:5301
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/dataset/request/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
wms-path: geoserver/cd
|
||||
|
||||
@@ -67,17 +67,34 @@ mapsheet:
|
||||
shp:
|
||||
baseurl: /Users/bokmin/detect/result
|
||||
|
||||
|
||||
|
||||
file:
|
||||
root: kamco-nfs
|
||||
nfs: C:/Users/gypark/kamco-nfs
|
||||
pt-path: ${file.nfs}/ckpt/classification/
|
||||
sync-root-dir: C:/Users/gypark/kamco-nfs/images/
|
||||
#sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: ${file.sync-root-dir}/tmp/
|
||||
sync-file-extention: tfw,tif
|
||||
# sync-auto-exception-start-year: 2025
|
||||
# sync-auto-exception-before-year-cnt: 3
|
||||
|
||||
dataset-dir: C:/Users/gypark/kamco-nfs/dataset/
|
||||
#dataset-dir: /kamco-nfs/dataset/export/
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
model-dir: C:/Users/gypark/kamco-nfs/ckpt/model/
|
||||
#model-dir: /kamco-nfs/ckpt/model/
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
pt-path: /kamco-nfs/ckpt/classification/
|
||||
pt-FileName: v5-best.pt
|
||||
dataset-response: /kamco-nfs/dataset/response/
|
||||
|
||||
inference:
|
||||
nfs: C:/Users/gyparkkamco-nfs
|
||||
url: http://10.100.0.11:8000/jobs
|
||||
batch-url: http://10.100.0.11:8000/batches
|
||||
jar-path: jar/shp-exporter.jar
|
||||
geojson-dir: /kamco-nfs/requests/
|
||||
jar-path: jar/makeshp-1.0.0.jar
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
@@ -85,6 +102,9 @@ gukyuin:
|
||||
url: http://192.168.2.129:5301
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/model_output/labeling/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
wms-path: geoserver/cd
|
||||
|
||||
@@ -84,23 +84,36 @@ mapsheet:
|
||||
baseurl: /app/detect/result #현재사용안함
|
||||
|
||||
file:
|
||||
root: data
|
||||
nfs: /data
|
||||
pt-path: ${file.nfs}/ckpt/model/v6-cls-checkpoints/
|
||||
sync-root-dir: /kamco-nfs/images/
|
||||
sync-tmp-dir: /kamco-nfs/repo/tmp # image upload temp dir
|
||||
sync-file-extention: tfw,tif
|
||||
|
||||
#dataset-dir: D:/kamco-nfs/model_output/ #변경 model_output
|
||||
dataset-dir: /kamco-nfs/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
|
||||
#model-dir: D:/kamco-nfs/ckpt/model/
|
||||
model-dir: /kamco-nfs/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
|
||||
pt-path: /kamco-nfs/ckpt/v6-cls-checkpoints/
|
||||
pt-FileName: yolov8_6th-6m.pt
|
||||
dataset-response: /kamco-nfs/dataset/response/
|
||||
|
||||
inference:
|
||||
nfs: /data
|
||||
url: http://172.16.4.56:8000/jobs
|
||||
batch-url: http://172.16.4.56:8000/batches
|
||||
jar-path: ${inference.nfs}/repo/jar/shp-exporter.jar
|
||||
url: http://127.0.0.1:8000/jobs
|
||||
batch-url: http://127.0.0.1:8000/batches
|
||||
geojson-dir: /kamco-nfs/requests/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
jar-path: /kamco-nfs/repo/jar/shp-exporter.jar # 추론실행을 위한 파일생성경로
|
||||
inference-server-name: server1,server2,server3,server4
|
||||
|
||||
gukyuin:
|
||||
url: http://127.0.0.1:5301
|
||||
cdi: ${gukyuin.url}/api/kcd/cdi
|
||||
|
||||
|
||||
training-data:
|
||||
geojson-dir: /kamco-nfs/dataset/request/
|
||||
|
||||
layer:
|
||||
geoserver-url: https://kamco.geo-dev.gs.dabeeo.com
|
||||
|
||||
@@ -67,22 +67,3 @@ management:
|
||||
include:
|
||||
- "health"
|
||||
|
||||
file:
|
||||
root: kamco-nfs
|
||||
nfs: /kamco-nfs
|
||||
sync-root-dir: ${file.nfs}/images/
|
||||
sync-tmp-dir: ${file.nfs}/requests/temp # image upload temp dir
|
||||
sync-file-extention: tfw,tif
|
||||
dataset-dir: ${file.nfs}/model_output/export/ # 마운트경로 AI 추론결과
|
||||
dataset-tmp-dir: ${file.dataset-dir}tmp/
|
||||
model-dir: ${file.nfs}/ckpt/model/ # 학습서버에서 트레이닝한 모델업로드경로
|
||||
model-tmp-dir: ${file.model-dir}tmp/
|
||||
model-file-extention: pth,json,py
|
||||
pt-path: ${file.nfs}/ckpt/model/v6-cls-checkpoints/
|
||||
dataset-response: ${file.nfs}/dataset/response/
|
||||
training-data:
|
||||
geojson-dir: ${file.nfs}/dataset/request/
|
||||
inference:
|
||||
nfs: /kamco-nfs
|
||||
geojson-dir: ${inference.nfs}/requests/ # 추론실행을 위한 파일생성경로
|
||||
jar-path: ${inference.nfs}/repo/jar/shp-exporter.jar
|
||||
|
||||
Reference in New Issue
Block a user