增加模型推理置信度阈值

This commit is contained in:
weiweiw 2024-12-20 11:26:58 +08:00
parent 9cef487401
commit b79163cf0c
6 changed files with 14 additions and 8 deletions

View File

@ -20,7 +20,7 @@ public class AnnotationRequest {
private List<String> targetLabels; private List<String> targetLabels;
@JsonProperty("conf_threshold") @JsonProperty("conf_threshold")
private Double confThreshold; private Float confThreshold;
public static AnnotationRequest fromJson(String json) throws JsonProcessingException { public static AnnotationRequest fromJson(String json) throws JsonProcessingException {
return new ObjectMapper().readValue(json, AnnotationRequest.class); return new ObjectMapper().readValue(json, AnnotationRequest.class);

View File

@ -8,7 +8,7 @@ public class IntelligentAnnotationServiceEntity extends BaseEntity {
private Long serviceId; private Long serviceId;
private String serviceName; private String serviceName;
private String serviceUrl; private String serviceUrl;
private String annotationLabels; private Float confLevel ;
/**删除标志0代表存在 1代表删除 */ /**删除标志0代表存在 1代表删除 */
private String delFlag; private String delFlag;

View File

@ -83,7 +83,7 @@ public class IntelligentAnnotationServiceImpl implements IntelligentAnnotationSe
} }
String serviceUrl = aiAnnotationServiceInfo.getServiceUrl(); String serviceUrl = aiAnnotationServiceInfo.getServiceUrl();
AnnotationRequest request = new AnnotationRequest(); AnnotationRequest request = new AnnotationRequest();
request.setConfThreshold(0.1); request.setConfThreshold(aiAnnotationServiceInfo.getConfLevel());
request.setImageUrls(imageUrls); request.setImageUrls(imageUrls);
request.setTargetLabels(ObjectUtils.isEmpty(taskInfo.getLabels()) ? new ArrayList<>() : Arrays.asList(taskInfo.getLabels().split(","))); request.setTargetLabels(ObjectUtils.isEmpty(taskInfo.getLabels()) ? new ArrayList<>() : Arrays.asList(taskInfo.getLabels().split(",")));
AnnotationResult result = intelligentAnnotationClient.intelligentAnnotation(serviceUrl, request); AnnotationResult result = intelligentAnnotationClient.intelligentAnnotation(serviceUrl, request);

View File

@ -4,6 +4,7 @@ import com.bonus.ai.domain.DataSetBasicFileEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskAnnotatorEntity; import com.bonus.ai.domain.dataset.AnnotationTaskAnnotatorEntity;
import com.bonus.ai.domain.dataset.AnnotationTaskEntity; import com.bonus.ai.domain.dataset.AnnotationTaskEntity;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.*;
@ -53,6 +54,10 @@ public class AverageUtil {
for (DataSetBasicFileEntity file : files) { for (DataSetBasicFileEntity file : files) {
// 跳过空文件因为这些文件与数据集的关系到但文件实体不在
if (ObjectUtils.isEmpty(file)){
continue;
}
// 为文件寻找一个标注人员 // 为文件寻找一个标注人员
AnnotationTaskEntity.UserFileCount annotator = findUserWithQuota(annotators); AnnotationTaskEntity.UserFileCount annotator = findUserWithQuota(annotators);
AnnotationTaskEntity.UserFileCount reviewer = findUserWithQuota(reviewers); AnnotationTaskEntity.UserFileCount reviewer = findUserWithQuota(reviewers);

View File

@ -10,7 +10,7 @@
<id property="serviceId" column="intelligent_annotation_service_id"/> <id property="serviceId" column="intelligent_annotation_service_id"/>
<result property="serviceName" column="intelligent_annotation_service_name"/> <result property="serviceName" column="intelligent_annotation_service_name"/>
<result property="serviceUrl" column="intelligent_annotation_service_url"/> <result property="serviceUrl" column="intelligent_annotation_service_url"/>
<result property="annotationLabels" column="intelligent_annotation_service_labels"/> <result property="confLevel" column="conf_level"/>
<result property="delFlag" column="del_flag"/> <result property="delFlag" column="del_flag"/>
<result property="createBy" column="create_by"/> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
@ -19,7 +19,7 @@
</resultMap> </resultMap>
<sql id="selectIntelligentAnnotationServiceVo"> <sql id="selectIntelligentAnnotationServiceVo">
select intelligent_annotation_service_id, intelligent_annotation_service_name, intelligent_annotation_service_url, del_flag, create_by, create_time, update_by, update_time from ai_intelligent_annotation_service select intelligent_annotation_service_id, intelligent_annotation_service_name, intelligent_annotation_service_url,conf_level, del_flag, create_by, create_time, update_by, update_time from ai_intelligent_annotation_service
</sql> </sql>
<!-- 查询所有有效记录 --> <!-- 查询所有有效记录 -->
@ -38,7 +38,7 @@
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="serviceName != null and serviceName != ''">intelligent_annotation_service_name,</if> <if test="serviceName != null and serviceName != ''">intelligent_annotation_service_name,</if>
<if test="serviceUrl != null and serviceUrl != ''">intelligent_annotation_service_url,</if> <if test="serviceUrl != null and serviceUrl != ''">intelligent_annotation_service_url,</if>
<if test="annotationLabels != null and annotationLabels != ''">intelligent_annotation_service_labels,</if> <if test="confLevel != null">conf_level,</if>
<if test="delFlag != null">del_flag,</if> <if test="delFlag != null">del_flag,</if>
<if test="createBy != null">create_by,</if> <if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
@ -48,7 +48,7 @@
<trim prefix="VALUES (" suffix=")" suffixOverrides=","> <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="serviceName != null and serviceName != ''">#{serviceName},</if> <if test="serviceName != null and serviceName != ''">#{serviceName},</if>
<if test="serviceUrl != null and serviceUrl != ''">#{serviceUrl},</if> <if test="serviceUrl != null and serviceUrl != ''">#{serviceUrl},</if>
<if test="annotationLabels != null and annotationLabels != ''">#{annotationLabels},</if> <if test="confLevel != null">#{conf_level},</if>
<if test="delFlag != null">#{delFlag},</if> <if test="delFlag != null">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if> <if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
@ -63,6 +63,7 @@
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="serviceName != null and serviceName != ''">intelligent_annotation_service_name = #{serviceName},</if> <if test="serviceName != null and serviceName != ''">intelligent_annotation_service_name = #{serviceName},</if>
<if test="serviceUrl != null and serviceUrl != ''">intelligent_annotation_service_url = #{serviceUrl},</if> <if test="serviceUrl != null and serviceUrl != ''">intelligent_annotation_service_url = #{serviceUrl},</if>
<if test="confLevel != null">conf_level = #{confLevel},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
</trim> </trim>
where intelligent_annotation_service_id = #{serviceId} where intelligent_annotation_service_id = #{serviceId}

View File

@ -243,7 +243,7 @@ create table ai_intelligent_annotation_service
intelligent_annotation_service_id bigint(20) not null auto_increment, intelligent_annotation_service_id bigint(20) not null auto_increment,
intelligent_annotation_service_name varchar(128) default '' comment '智能标注服务名称', intelligent_annotation_service_name varchar(128) default '' comment '智能标注服务名称',
intelligent_annotation_service_url varchar(128) default '' comment '智能标注服务url', intelligent_annotation_service_url varchar(128) default '' comment '智能标注服务url',
intelligent_annotation_service_labels varchar(128) default '' comment '智能标注服务标签', conf_level FLOAT default 0.5 comment '置信度',
del_flag char(1) default '0' comment '是否删除(0代表存在,1代表删除)', del_flag char(1) default '0' comment '是否删除(0代表存在,1代表删除)',
create_by varchar(64) default '' comment '创建者', create_by varchar(64) default '' comment '创建者',
update_by varchar(64) default '' comment '更新者', update_by varchar(64) default '' comment '更新者',