|
@@ -1,9 +1,7 @@
|
|
|
package com.taais.biz.controller;
|
|
|
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileInputStream;
|
|
|
-import java.io.IOException;
|
|
|
+import java.io.*;
|
|
|
import java.nio.file.DirectoryStream;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Path;
|
|
@@ -14,11 +12,14 @@ import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.mybatisflex.core.query.QueryWrapper;
|
|
|
import com.taais.biz.domain.DataAugmentation;
|
|
|
import com.taais.biz.domain.bo.DataAugmentationBo;
|
|
|
import com.taais.biz.domain.bo.DataAugmentationResultBo;
|
|
|
import com.taais.biz.domain.bo.VideoStableStartResultBo;
|
|
|
+import com.taais.biz.domain.dto.Metric;
|
|
|
import com.taais.biz.domain.vo.DataAugmentationVo;
|
|
|
import com.taais.biz.domain.vo.TaskDictDataVo;
|
|
|
import com.taais.biz.service.IVideoStableService;
|
|
@@ -80,6 +81,7 @@ public class DataAugmentationController extends BaseController {
|
|
|
try (Stream<Path> paths = Files.list(inputPath)) {
|
|
|
return paths.sorted()
|
|
|
.skip(idx)
|
|
|
+ .filter(path -> !path.toString().toLowerCase().endsWith(".json"))
|
|
|
.findFirst()
|
|
|
.orElseThrow(() -> new IllegalArgumentException("Index " + idx + " is out of bounds for the list of files in " + inputPath));
|
|
|
}
|
|
@@ -167,7 +169,9 @@ public class DataAugmentationController extends BaseController {
|
|
|
Stream<Path> inputFilePathStream = Files.list(imagePath);
|
|
|
inputFileList = inputFilePathStream
|
|
|
.filter(Files::isRegularFile) // 只选择常规文件(排除子目录、排除图像拼接算法_sift输入中的txt文件)
|
|
|
- .filter(path -> !path.toString().toLowerCase().endsWith(".txt")).map(path -> {
|
|
|
+ .filter(path -> !path.toString().toLowerCase().endsWith(".txt"))
|
|
|
+ .filter(path -> !path.toString().toLowerCase().endsWith(".json"))
|
|
|
+ .map(path -> {
|
|
|
return path.getFileName().toString();
|
|
|
}).collect(Collectors.toList());
|
|
|
} else {
|
|
@@ -233,9 +237,28 @@ public class DataAugmentationController extends BaseController {
|
|
|
@SaCheckPermission("demo:dataAugmentation:list")
|
|
|
@GetMapping("/list")
|
|
|
public CommonResult<PageResult<DataAugmentationVo>> list(DataAugmentationBo dataAugmentationBo) {
|
|
|
+ if (dataAugmentationBo.getTaskType() == null) {
|
|
|
+ return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "dataAugmentation"));
|
|
|
+ }
|
|
|
+ return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
|
|
|
+ }
|
|
|
+ @SaCheckPermission("demo:dataAugmentation:list")
|
|
|
+ @GetMapping("/imageMosaicList")
|
|
|
+ public CommonResult<PageResult<DataAugmentationVo>> imageMosaicList(DataAugmentationBo dataAugmentationBo) {
|
|
|
+ if (dataAugmentationBo.getTaskType() == null) {
|
|
|
+ return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "imageMosaic"));
|
|
|
+ }
|
|
|
return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
|
|
|
}
|
|
|
|
|
|
+ @SaCheckPermission("demo:dataAugmentation:list")
|
|
|
+ @GetMapping("/targetDamageAcessList")
|
|
|
+ public CommonResult<PageResult<DataAugmentationVo>> targetDamageAcessList(DataAugmentationBo dataAugmentationBo) {
|
|
|
+ if (dataAugmentationBo.getTaskType() == null) {
|
|
|
+ return CommonResult.success(dataAugmentationService.selectPage1(dataAugmentationBo, "targetDamageAcess"));
|
|
|
+ }
|
|
|
+ return CommonResult.success(dataAugmentationService.selectPage(dataAugmentationBo));
|
|
|
+ }
|
|
|
/**
|
|
|
* 导出数据增强列表
|
|
|
*/
|
|
@@ -341,6 +364,43 @@ public class DataAugmentationController extends BaseController {
|
|
|
return CommonResult.fail("日志文件" + filePath + "读取失败!");
|
|
|
}
|
|
|
}
|
|
|
+ /**
|
|
|
+ * 获取算法结果指标
|
|
|
+ */
|
|
|
+ @SaCheckPermission("demo:dataAugmentation:query")
|
|
|
+ @GetMapping(value = "/metric/{id}")
|
|
|
+ public CommonResult<List<Metric>> getMetric(@PathVariable Long id) {
|
|
|
+ DataAugmentation byId = dataAugmentationService.getById(id);
|
|
|
+ String outputPath = byId.getOutputPath();
|
|
|
+ Path path = Paths.get(outputPath, "result.json");
|
|
|
+ try{
|
|
|
+
|
|
|
+ if (!Files.exists(path)) {
|
|
|
+ return CommonResult.fail( "算法指标文件" + path.toString() + "不存在!");
|
|
|
+ }
|
|
|
+ StringBuilder jsonContent = new StringBuilder();
|
|
|
+ try (BufferedReader reader = new BufferedReader(new FileReader(path.toString()))) {
|
|
|
+ String line;
|
|
|
+ while ((line = reader.readLine()) != null) {
|
|
|
+ jsonContent.append(line);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 解析 JSON 数组
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(jsonContent.toString());
|
|
|
+ List<Metric> metricList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+ Metric metric = new Metric(
|
|
|
+ jsonObject.getString("name"),
|
|
|
+ jsonObject.getString("value")
|
|
|
+ );
|
|
|
+ metricList.add(metric);
|
|
|
+ }
|
|
|
+ return CommonResult.success((metricList), "获取算法指标成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ return CommonResult.fail("算法指标文件" + path.toString() + "读取失败!");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
@SaCheckPermission("demo:dataAugmentation:query")
|
|
|
@GetMapping(value = "/getTaskDictData")
|