后端推理调整
This commit is contained in:
parent
d82e34d803
commit
c78e3be982
@ -2,8 +2,10 @@ package com.yfd.business.css.service;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.yfd.business.css.domain.Scenario;
|
import com.yfd.business.css.domain.Scenario;
|
||||||
import com.yfd.business.css.domain.ScenarioResult;
|
import com.yfd.business.css.domain.ScenarioResult;
|
||||||
|
import com.yfd.business.css.domain.AlgorithmModel;
|
||||||
import com.yfd.business.css.model.DeviceStepInfo;
|
import com.yfd.business.css.model.DeviceStepInfo;
|
||||||
import com.yfd.business.css.model.InferRequest;
|
import com.yfd.business.css.model.InferRequest;
|
||||||
import com.yfd.business.css.model.InferResponse;
|
import com.yfd.business.css.model.InferResponse;
|
||||||
@ -121,15 +123,17 @@ public class DeviceInferService {
|
|||||||
String modelRelPath = model.getModelPath();
|
String modelRelPath = model.getModelPath();
|
||||||
log.debug("modelRelPath={}", modelRelPath);
|
log.debug("modelRelPath={}", modelRelPath);
|
||||||
|
|
||||||
// 解析模型的特征映射(feature_map_snapshot)以进行特征过滤
|
// 解析模型的特征映射(feature_map_snapshot),优先以 input_cols 为准进行特征过滤
|
||||||
List<String> requiredFeatures = new ArrayList<>();
|
List<String> requiredFeatures = new ArrayList<>();
|
||||||
if (model.getFeatureMapSnapshot() != null && !model.getFeatureMapSnapshot().isBlank()) {
|
if (model.getFeatureMapSnapshot() != null && !model.getFeatureMapSnapshot().isBlank()) {
|
||||||
try {
|
try {
|
||||||
// 解析 {"features": ["diameter", "height", ...]} 或者直接是一个 List
|
|
||||||
JsonNode fNode = objectMapper.readTree(model.getFeatureMapSnapshot());
|
JsonNode fNode = objectMapper.readTree(model.getFeatureMapSnapshot());
|
||||||
if (fNode.isArray()) {
|
if (fNode.isArray()) {
|
||||||
for (JsonNode node : fNode) requiredFeatures.add(node.asText());
|
for (JsonNode node : fNode) requiredFeatures.add(node.asText());
|
||||||
|
} else if (fNode.has("input_cols") && fNode.get("input_cols").isArray()) {
|
||||||
|
for (JsonNode node : fNode.get("input_cols")) requiredFeatures.add(node.asText());
|
||||||
} else if (fNode.has("features") && fNode.get("features").isArray()) {
|
} else if (fNode.has("features") && fNode.get("features").isArray()) {
|
||||||
|
// 兼容旧版本
|
||||||
for (JsonNode node : fNode.get("features")) requiredFeatures.add(node.asText());
|
for (JsonNode node : fNode.get("features")) requiredFeatures.add(node.asText());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -41,10 +41,10 @@ import java.util.regex.Pattern;
|
|||||||
@Service
|
@Service
|
||||||
public class ModelTrainServiceImpl extends ServiceImpl<ModelTrainTaskMapper, ModelTrainTask> implements ModelTrainService {
|
public class ModelTrainServiceImpl extends ServiceImpl<ModelTrainTaskMapper, ModelTrainTask> implements ModelTrainService {
|
||||||
|
|
||||||
@Value("${file-space.upload-path:./data/uploads/}")
|
@Value("${file-space.dataset-path:D:/keff_dataSpace/datasets/}")
|
||||||
private String uploadPath;
|
private String uploadPath;
|
||||||
|
|
||||||
@Value("${file-space.model-path:E:/python_coding/keffCenter/models/}")
|
@Value("${file-space.model-path:D:/keff_dataSpace/models/}")
|
||||||
private String modelPath;
|
private String modelPath;
|
||||||
|
|
||||||
@Value("${python.api.url:http://localhost:8000}")
|
@Value("${python.api.url:http://localhost:8000}")
|
||||||
@ -373,7 +373,7 @@ public class ModelTrainServiceImpl extends ServiceImpl<ModelTrainTaskMapper, Mod
|
|||||||
Path extraFileSrc = srcDir.resolve(fileName);
|
Path extraFileSrc = srcDir.resolve(fileName);
|
||||||
if (Files.exists(extraFileSrc) && Files.isRegularFile(extraFileSrc)) {
|
if (Files.exists(extraFileSrc) && Files.isRegularFile(extraFileSrc)) {
|
||||||
Path dest = versionDir.resolve(fileName).normalize();
|
Path dest = versionDir.resolve(fileName).normalize();
|
||||||
Files.copy(extraFileSrc, dest, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
|
Files.copy(extraFileSrc, dest, StandardCopyOption.REPLACE_EXISTING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,11 +466,11 @@ public class ModelTrainServiceImpl extends ServiceImpl<ModelTrainTaskMapper, Mod
|
|||||||
// 如果文件已存在,由于这是在发布新版本目录下,正常不应存在。
|
// 如果文件已存在,由于这是在发布新版本目录下,正常不应存在。
|
||||||
// 如果是重复点击或有历史遗留,这里选择覆盖,或者可以跳过/报错。
|
// 如果是重复点击或有历史遗留,这里选择覆盖,或者可以跳过/报错。
|
||||||
// 为了避免 "目标文件已存在" 报错中断流程,这里改为 REPLACE_EXISTING
|
// 为了避免 "目标文件已存在" 报错中断流程,这里改为 REPLACE_EXISTING
|
||||||
Files.copy(src, dest, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
|
Files.copy(src, dest, StandardCopyOption.REPLACE_EXISTING);
|
||||||
} else {
|
} else {
|
||||||
Files.copy(src, dest, StandardCopyOption.COPY_ATTRIBUTES);
|
Files.copy(src, dest);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
throw new BizException("复制文件失败: " + e.getMessage());
|
throw new BizException("复制文件失败: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,12 @@ file-space:
|
|||||||
security:
|
security:
|
||||||
dev:
|
dev:
|
||||||
permit: true
|
permit: true
|
||||||
logging:
|
# 注释掉这里的 file.name,由 logback-spring.xml 接管,防止覆盖
|
||||||
file:
|
# logging:
|
||||||
name: logs/business-css.log
|
# file:
|
||||||
level:
|
# name: logs/business-css.log
|
||||||
root: INFO
|
# level:
|
||||||
|
# root: INFO
|
||||||
|
|
||||||
python:
|
python:
|
||||||
api:
|
api:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user