feat/training_260202 #128
@@ -65,16 +65,48 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertModelMetricsTest(List<Object[]> batchArgs) {
|
public void insertModelMetricsTest(List<Object[]> batchArgs) {
|
||||||
String sql =
|
// AS-IS
|
||||||
|
// String sql =
|
||||||
|
// """
|
||||||
|
// insert into tb_model_metrics_test
|
||||||
|
// (model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
|
||||||
|
// detection_count, gt_count
|
||||||
|
// )
|
||||||
|
// values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
// """;
|
||||||
|
//
|
||||||
|
// jdbcTemplate.batchUpdate(sql, batchArgs);
|
||||||
|
|
||||||
|
// TO-BE: modelId, model(best_fscore_10) 같은 데이터가 있으면 update, 없으면 insert
|
||||||
|
String updateSql =
|
||||||
"""
|
"""
|
||||||
insert into tb_model_metrics_test
|
UPDATE tb_model_metrics_test
|
||||||
(model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
|
SET tp=?, fp=?, fn=?, precisions=?, recall=?, f1_score=?, accuracy=?, iou=?,
|
||||||
detection_count, gt_count
|
detection_count=?, gt_count=?
|
||||||
)
|
WHERE model_id=? AND model=?
|
||||||
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
||||||
""";
|
""";
|
||||||
|
|
||||||
jdbcTemplate.batchUpdate(sql, batchArgs);
|
String insertSql =
|
||||||
|
"""
|
||||||
|
INSERT INTO tb_model_metrics_test
|
||||||
|
(model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
|
||||||
|
detection_count, gt_count)
|
||||||
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
|
""";
|
||||||
|
|
||||||
|
// row 단위 처리 (batch 안에서 upsert)
|
||||||
|
for (Object[] row : batchArgs) {
|
||||||
|
// row 순서: (model_id, model, tp, fp, fn, precisions, recall, f1_score, accuracy, iou,
|
||||||
|
// detection_count, gt_count)
|
||||||
|
int updated =
|
||||||
|
jdbcTemplate.update(
|
||||||
|
updateSql, row[2], row[3], row[4], row[5], row[6], row[7], row[8], row[9], row[10],
|
||||||
|
row[11], row[0], row[1]);
|
||||||
|
|
||||||
|
if (updated == 0) {
|
||||||
|
jdbcTemplate.update(insertSql, row);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -99,11 +131,9 @@ public class ModelTestMetricsJobRepositoryImpl extends QuerydslRepositorySupport
|
|||||||
.on(
|
.on(
|
||||||
modelMetricsTestEntity.model.eq(modelMetricsTrainEntity.model),
|
modelMetricsTestEntity.model.eq(modelMetricsTrainEntity.model),
|
||||||
modelMasterEntity.bestEpoch.eq(modelMetricsTrainEntity.epoch))
|
modelMasterEntity.bestEpoch.eq(modelMetricsTrainEntity.epoch))
|
||||||
.where(
|
.where(modelMetricsTestEntity.model.id.eq(modelId))
|
||||||
modelMetricsTestEntity.model.id.eq(modelId),
|
.orderBy(modelMetricsTestEntity.createdDttm.desc())
|
||||||
modelMetricsTestEntity.model1.eq(
|
.fetchFirst();
|
||||||
"best_changed_fscore_epoch_" + modelMasterEntity.bestEpoch))
|
|
||||||
.fetchOne();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,10 +26,9 @@ public class TmpDatasetService {
|
|||||||
* @param uid 임시폴더 uuid
|
* @param uid 임시폴더 uuid
|
||||||
* @param type train, val, test
|
* @param type train, val, test
|
||||||
* @param links tif pull path
|
* @param links tif pull path
|
||||||
* @return
|
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public String buildTmpDatasetHardlink(String uid, String type, List<ModelTrainLinkDto> links)
|
public void buildTmpDatasetHardlink(String uid, String type, List<ModelTrainLinkDto> links)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
if (links == null || links.isEmpty()) {
|
if (links == null || links.isEmpty()) {
|
||||||
@@ -71,7 +70,6 @@ public class TmpDatasetService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("tmp dataset created: {}, hardlinksMade={}", tmp, hardlinksMade);
|
log.info("tmp dataset created: {}, hardlinksMade={}", tmp, hardlinksMade);
|
||||||
return uid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long link(Path tmp, String type, String part, String fullPath) throws IOException {
|
private long link(Path tmp, String type, String part, String fullPath) throws IOException {
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class TrainJobWorker {
|
|||||||
evalReq.setTimeoutSeconds(null);
|
evalReq.setTimeoutSeconds(null);
|
||||||
evalReq.setDatasetFolder(datasetFolder);
|
evalReq.setDatasetFolder(datasetFolder);
|
||||||
evalReq.setOutputFolder(outputFolder);
|
evalReq.setOutputFolder(outputFolder);
|
||||||
|
log.info("[JOB] selected test epoch={}", epoch);
|
||||||
result = dockerTrainService.runEvalSync(evalReq, containerName);
|
result = dockerTrainService.runEvalSync(evalReq, containerName);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user