删除与lable studio service 之间的接口
This commit is contained in:
parent
5609ffe2bd
commit
6e940bafbe
|
|
@ -59,25 +59,6 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
|
||||
int status =0;
|
||||
//1.调用label studio 接口创建project,将projectid 关联到标注任务里
|
||||
/*
|
||||
ProjectInputParam lSProject= new ProjectInputParam();
|
||||
lSProject.setTitle(task.getTaskName());
|
||||
lSProject.setDescription(task.getTaskDesc());
|
||||
//需要将标签转换为json格式
|
||||
String labelConfig = OnlineAnnotateUtil.rectangleImageLabels(task.getLabels());
|
||||
lSProject.setLabelConfig(labelConfig);
|
||||
Long projectId = 0L;
|
||||
try {
|
||||
ProjectParam projectParams = onlineAnnotationService.createProject(lSProject);
|
||||
if (projectParams != null) {
|
||||
projectId = Long.valueOf(projectParams.getId());
|
||||
task.setLabelStudioProjectId(projectId);
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
//2.插入标注任务表
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "");
|
||||
task.setTaskUuid(uuid);
|
||||
|
|
@ -102,46 +83,7 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
//每个文件都需要创建label studio的 task id 与之唯一对应
|
||||
entity.setTaskId(annotationTaskid);
|
||||
}
|
||||
/*
|
||||
// 使用 CountDownLatch 来确保所有任务完成后才执行下一步操作
|
||||
CountDownLatch latch = new CountDownLatch(annotationTaskAnnotatorEntities.size());
|
||||
|
||||
//4. 文件分配后需要调用label studio 接口创建task,将taskid与 文件和标注人表进行关联(因为文件较多启用异步调用)
|
||||
for (AnnotationTaskAnnotatorEntity entity : annotationTaskAnnotatorEntities) {
|
||||
//每个文件都需要创建label studio的 task id 与之唯一对应
|
||||
entity.setTaskId(annotationTaskid);
|
||||
Long finalProjectId = projectId;
|
||||
executorService.execute(()->{
|
||||
TaskInputParam taskParam = new TaskInputParam();
|
||||
TaskInputParam.Data data = new TaskInputParam.Data();
|
||||
String imageUrl = minioConfig.getEndpoint() + "/" + minioConfig.getBucketName() + "/"+ entity.getFileUrl();
|
||||
data.setImage(imageUrl);
|
||||
data.setText("Hello, world!");
|
||||
taskParam.setData(data);
|
||||
taskParam.setProject(finalProjectId);
|
||||
try {
|
||||
|
||||
TaskParam lStask = onlineAnnotationService.createTask(taskParam);
|
||||
synchronized (entity) {
|
||||
entity.setLabelStudioTaskId(lStask.getId());
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
latch.countDown(); // 每个任务完成后减少计数
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 等待所有线程完成
|
||||
try {
|
||||
latch.await(); // 主线程会等待所有子线程完成
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
e.printStackTrace();
|
||||
}
|
||||
*/
|
||||
|
||||
// 5. 将文件和标注人等信息 插入文件和标注人关联表
|
||||
if(status == 1){
|
||||
|
|
@ -192,29 +134,6 @@ public class AnnotationTaskServiceImpl implements AnnotationTaskService {
|
|||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
/*
|
||||
//防止labels信息发生变化,信息也同步更新到label studio studio 对应的project
|
||||
AnnotationTaskEntity newTask = new AnnotationTaskEntity();
|
||||
newTask.setTaskId(task.getTaskId());
|
||||
//处理与label studio 相关的更新
|
||||
List<AnnotationTaskEntity> resultTasks = annotationTaskMapper.selectAnnotationTaskList(newTask);
|
||||
if (!resultTasks.isEmpty()) {
|
||||
Long project = resultTasks.get(0).getLabelStudioProjectId();
|
||||
//调用label studio 接口获取其project id
|
||||
ProjectInputParam lSProject= new ProjectInputParam();
|
||||
lSProject.setTitle(task.getTaskName());
|
||||
lSProject.setDescription(task.getTaskDesc());
|
||||
//需要将标签转换为json格式
|
||||
String labelConfig = OnlineAnnotateUtil.rectangleImageLabels(task.getLabels());
|
||||
lSProject.setLabelConfig(labelConfig);
|
||||
lSProject.setId(project);
|
||||
try {
|
||||
ProjectParam projectParam = onlineAnnotationService.updateProject(lSProject);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue