在线标注
This commit is contained in:
parent
3d33a8ce96
commit
1fbbf738b5
|
|
@ -0,0 +1,40 @@
|
|||
package com.bonus.ai.client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class OnlineAnnotateUtil {
|
||||
/**
|
||||
* 替换 View 中的 Label 标签内容
|
||||
* @param template 原始字符串模板
|
||||
* @param labels 要替换的 labels 列表
|
||||
* @return 替换后的字符串
|
||||
*/
|
||||
public static String rectangleImageLabels(String template, List<String> labels) {
|
||||
if (labels == null || labels.isEmpty()){
|
||||
return "";
|
||||
}
|
||||
// 构建新的 Label 标签内容
|
||||
StringBuilder labelBuilder = new StringBuilder();
|
||||
String[] colors = {"#FFA39E", "#D4380D", "#36CFC9", "#FF85C0", "#FFD666"}; // 颜色数组
|
||||
int colorIndex = 0;
|
||||
|
||||
for (String label : labels) {
|
||||
// 循环使用颜色
|
||||
String color = colors[colorIndex % colors.length];
|
||||
labelBuilder.append(" <Label value=\"")
|
||||
.append(label)
|
||||
.append("\" background=\"")
|
||||
.append(color)
|
||||
.append("\"/>\n");
|
||||
colorIndex++;
|
||||
}
|
||||
|
||||
// 替换模板中的内容
|
||||
return template.replaceAll(
|
||||
"<RectangleLabels name=\"label\" toName=\"image\">.*?</RectangleLabels>",
|
||||
"<RectangleLabels name=\"label\" toName=\"image\">\n" + labelBuilder + " </RectangleLabels>"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ public class AnnotationTaskController extends BaseController {
|
|||
/**
|
||||
* 查看由我创建的任务列表和我参与的或全部任务列表
|
||||
* 统一获取文件列表
|
||||
* @param type 参数类型:myCreated - 由我创建的任务列表, myParticipated - 由我参与的任务列表, all - 用户创建和公共文件
|
||||
* @param type 参数类型:myCreated - 由我创建的任务列表, myParticipated - 分配给我的标注任务表, all - 用户创建和公共文件
|
||||
* @return 返回满足条件的任务列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
|
|
@ -61,6 +61,7 @@ public class AnnotationTaskController extends BaseController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据任务编号获取任务详情,如果是标注人员获取分配的文件列表,如果是审核人员获取所有分配的文件列表,如果是管理员获取所有文件列表
|
||||
* @param taskId 任务编号
|
||||
|
|
@ -92,4 +93,6 @@ public class AnnotationTaskController extends BaseController {
|
|||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.bonus.ai.service.Impl.dataset;
|
||||
|
||||
import com.bonus.ai.client.OnlineAnnotateUtil;
|
||||
import com.bonus.ai.client.OnlineAnnotationService;
|
||||
import com.bonus.ai.client.ProjectParam;
|
||||
import com.bonus.ai.client.TaskParam;
|
||||
import com.bonus.ai.config.MinioConfig;
|
||||
import com.bonus.ai.config.OnlineAnnotateConfig;
|
||||
import com.bonus.ai.domain.dataset.AnnotationSubTaskEntity;
|
||||
|
|
@ -28,6 +31,15 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
*/
|
||||
@Override
|
||||
public int createTask(AnnotationTaskEntity task) {
|
||||
// TODO 调用label studio 接口获取其project id
|
||||
ProjectParam lSProject = new ProjectParam();
|
||||
lSProject.setTitle(task.getTaskName());
|
||||
lSProject.setDescription(task.getTaskDesc());
|
||||
//需要将标签转换为json格式
|
||||
lSProject.setLabelConfig(task.getLabels());
|
||||
onlineAnnotationService.createProject(lSProject, onlineAnnotateConfig.getApikey());
|
||||
//TODO 根据标注任务file list 和标注人信息自动分配
|
||||
// 获取project id以后调用AnnotationTaskMapper 和AnnotationTaskAnnotatorMapper 插入数据集
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue