Browse Source

Merge branch 'V20211018' of git.openi.org.cn:OpenI/aiforge into repo-statistic

tags/v1.21.10.1^2
lewis 4 years ago
parent
commit
511a981024
3 changed files with 223 additions and 128 deletions
  1. +35
    -0
      models/user_business_analysis.go
  2. +135
    -87
      public/self/labelTaskPage.js
  3. +53
    -41
      templates/repo/datasets/label/index.tmpl

+ 35
- 0
models/user_business_analysis.go View File

@@ -55,6 +55,15 @@ type UserBusinessAnalysis struct {
//user
RegistDate timeutil.TimeStamp `xorm:"NOT NULL"`

//repo
CreateRepoCount int `xorm:"NOT NULL DEFAULT 0"`

//login count, from elk
LoginCount int `xorm:"NOT NULL DEFAULT 0"`

//openi index
OpenIIndex int `xorm:"NOT NULL DEFAULT 0"`

//user
Email string `xorm:"NOT NULL"`

@@ -100,6 +109,7 @@ func CountData(wikiCountMap map[string]int) {
}
CommitDatasetSizeMap := queryDatasetSize(start_unix, end_unix)
SolveIssueCountMap := querySolveIssue(start_unix, end_unix)
CreateRepoCountMap := queryUserCreateRepo(start_unix, end_unix)

for i, userRecord := range userList {
var dateRecord UserBusinessAnalysis
@@ -176,6 +186,12 @@ func CountData(wikiCountMap map[string]int) {
dateRecord.EncyclopediasCount = wikiCountMap[dateRecord.Name]
}

if _, ok := CreateRepoCountMap[dateRecord.ID]; !ok {
dateRecord.CreateRepoCount = 0
} else {
dateRecord.CreateRepoCount = CreateRepoCountMap[dateRecord.ID]
}

dateRecord.CommitModelCount = 0

statictisSess := xStatistic.NewSession()
@@ -322,6 +338,25 @@ func queryDatasetSize(start_unix int64, end_unix int64) map[int64]int {

}

func queryUserCreateRepo(start_unix int64, end_unix int64) map[int64]int {
sess := x.NewSession()
defer sess.Close()
sess.Select("id,owner_id,name").Table("repository").Where(" created_unix>=" + fmt.Sprint(start_unix) + " and created_unix<=" + fmt.Sprint(end_unix))
repoList := make([]*Repository, 0)
sess.Find(&repoList)
resultMap := make(map[int64]int)
log.Info("query Repository size=" + fmt.Sprint(len(repoList)))
for _, repoRecord := range repoList {
if _, ok := resultMap[repoRecord.OwnerID]; !ok {
resultMap[repoRecord.OwnerID] = 1
} else {
resultMap[repoRecord.OwnerID] += 1
}
}
return resultMap

}

func subMonth(t1, t2 time.Time) (month int) {
y1 := t1.Year()
y2 := t2.Year()


+ 135
- 87
public/self/labelTaskPage.js View File

@@ -23,7 +23,7 @@ var pageSize = 10;
var tableData;
var tablePageData;

var preDictTaskData;
var modelListData;
var dataSetTaskData;

var userInfoData;
@@ -35,8 +35,8 @@ console.log("repoId=" + repoId);

function setDataSetTask(){
dataset_task_list();
display_createdatasetlabel(0);
//dataset_task_list();
//display_createdatasetlabel(0);
//getUser();
//dislpayUser();
getLabelPropertyTask();
@@ -121,46 +121,31 @@ function countLabel(){
}

function display_createdatasetlabel(sindex=-1){
var html="";
for (var i=0;i<dataSetTaskData.length;i++){
if (i==sindex){
var row = "<option value=\""+dataSetTaskData[i].id+
"\" selected=\"\">"+dataSetTaskData[i].task_name+
"</option>";
$("#datasetlabeltaskname").attr({value:dataSetTaskData[i].task_name + "-人工标注"});
}else{
var row = "<option value=\""+dataSetTaskData[i].id+
"\">"+dataSetTaskData[i].task_name+
"</option>";
}
html=html+row;
}
console.log(html);
document.getElementById('dataset_list').innerHTML=html;
}



function setPredictTask(){
pre_predict_task_list();
display_createlabel(0);
getUser();
dislpayUser();
getLabelPropertyTask();
displayLabelPropertyTask();
//dataset_task_list();
//display_createdatasetlabel(1);


get_model_list();

displayModelTask();
$(".ui.predict.modal").modal("show");
}

function pre_predict_task_list(){
function get_model_list(){
$.ajax({
type:"GET",
url:ip + "/api/pre-predict-taskforLabel/",
url:ip + "/api/queryAlgModelForAutoLabel/",
headers: {
authorization:token,
},
dataType:"json",
async:false,
success:function(json){
preDictTaskData = json;
modelListData = json;
console.log(json);
// return json.token;
},
@@ -170,12 +155,26 @@ function pre_predict_task_list(){
});
}

function sele_Change(sele){
var predictTaskName = $('#pre_predict_task_for_label option:selected').text();
console.log("select predictTaskName =" + predictTaskName);
$("#labeltaskname").attr({value:predictTaskName+"-人工标注"});
function displayModelTask(){
var html="";
for (var i=0;i<modelListData.length;i++){
if (i==0){
var row = "<option value=\""+modelListData[i].id+
"\" selected=\"\">"+modelListData[i].model_name +
"</option>";
}else{
var row = "<option value=\""+modelListData[i].id+
"\">"+modelListData[i].model_name+
"</option>";
}
html=html+row;
}
console.log(html);

document.getElementById('model_list').innerHTML=html;
}


function sele_export_Change(sele){

var isNeedPicture = $('#isNeedPicture option:selected').val();
@@ -201,27 +200,13 @@ function dataset_sele_Change(sele){
$("#datasetlabeltaskname").attr({value:dataset_listName+"-人工标注"});
}



function display_createlabel(sindex=-1){
var html="";
for (var i=0;i<preDictTaskData.length;i++){
if (i==sindex){
var row = "<option value=\""+preDictTaskData[i].id+
"\" selected=\"\">"+preDictTaskData[i].task_name+
"</option>";
$("#labeltaskname").attr({value:preDictTaskData[i].task_name + "-人工标注"});
}else{
var row = "<option value=\""+preDictTaskData[i].id+
"\">"+preDictTaskData[i].task_name+
"</option>";
}
html=html+row;
}
console.log(html);
document.getElementById('pre_predict_task_for_label').innerHTML=html;
function dataset_auto_sele_Change(sele){
var dataset_listName = $('#dataset_list_auto option:selected').text();
console.log("select dataset_list_auto =" + dataset_listName);
$("#autolabeltaskname").attr({value:dataset_listName+"-自动标注"});
}


var createsucced;

function submit_datasettask(){
@@ -242,7 +227,7 @@ function submit_datasettask(){
}
var labelpropertytaskid = $('#labelpropertytask_dataset option:selected').val();
createsucced = true;
label_task_create(task_name, relate_task_id, 2,assign_user_id,labelpropertytaskid);
label_task_create(task_name, relate_task_id, 2,assign_user_id,labelpropertytaskid,-1);
if(createsucced){
$(".ui.dataset.modal").modal("hide");
//$("#labelDataModal").modal('hide');
@@ -250,25 +235,30 @@ function submit_datasettask(){
page(0,pageSize);
}

function submit_labeltask(){
console.log($('#labeltaskname').val());
var task_name = $('#labeltaskname').val();
function submit_autolabeltask(){
console.log($('#autolabeltaskname').val());
var task_name = $('#autolabeltaskname').val();
if (isEmpty(task_name) || task_name.length > 32){
alert("人工标注任务名称不能为空或者不能超过32个字符。");
alert("自动标注任务名称不能为空或者不能超过32个字符。");
return;
}
var relate_task_id = $('#pre_predict_task_for_label option:selected').val();
var model_id = $('#model_list option:selected').val();
if(isEmpty(model_id)){
alert("标注模型不能为空。");
return;
}
var relate_task_id = $('#dataset_list_auto option:selected').val();
if(isEmpty(relate_task_id)){
alert("关联的自动标注任务不能为空。");
alert("数据集对象不能为空。");
return;
}
var assign_user_id = $('#label_assign_user option:selected').val();
if(isEmpty(assign_user_id)){
assign_user_id = token;
}
var labelpropertytaskid = $('#labelpropertytask_dataset option:selected').val();
var labelpropertytaskid = $('#labelpropertytask_auto option:selected').val();
createsucced = true;
label_task_create(task_name, relate_task_id, 1,assign_user_id,labelpropertytaskid);
label_task_create(task_name, relate_task_id, 1,assign_user_id,labelpropertytaskid,model_id);
if(createsucced){
$("#labelModal").modal('hide');
}
@@ -276,10 +266,10 @@ function submit_labeltask(){
}


function label_task_create(task_name, relate_task_id, taskType,assign_user_id,labelpropertytaskid){
function label_task_create(task_name, relate_task_id, taskType,assign_user_id,labelpropertytaskid,model_id){
var task_flow_type = $('#task_flow_type option:selected').val();
var task_flow_type = $('#task_flow_type option:selected').val();
var relate_other_label_task = [];
if(task_flow_type == 2){
@@ -309,20 +299,21 @@ function label_task_create(task_name, relate_task_id, taskType,assign_user_id,la
'assign_user_id':assign_user_id,
'task_flow_type':task_flow_type,
'relate_task_id':relate_task_id,//task id
'relate_other_label_task': relate_other_label_task_jsonstr,
'relate_other_label_task': relate_other_label_task_jsonstr,
"taskType": taskType,
"appid": repoId,
"createUserName":userName,
"labelPropertyTaskId":labelpropertytaskid
"appid": repoId,
"createUserName":userName,
"labelPropertyTaskId":labelpropertytaskid,
"modelId":model_id
}),
success:function(res){
console.log(res);
if(res.code == 0){
alert("人工标注任务创建成功!");
alert("自动标注任务创建成功!");
createsucced = true;
}
else{
alert("创建人工标注任务失败," + res.message);
alert("创建自动标注任务失败," + res.message);
createsucced = false;
}
},
@@ -433,11 +424,11 @@ function delete_labeltask(){
return;
}
var Check = $("table[id='label_task_list'] input[type=checkbox]:checked");//在table中找input下类型为checkbox属性为选中状态的数据
      Check.each(function () {//遍历
            var row = $(this).parent("td").parent("tr");//获取选中行
            var id = row.find("[id='labeltask_id']").html();//获取name='Sid'的值
            delete_labeltask_byid(id);
        });
Check.each(function () {//遍历
var row = $(this).parent("td").parent("tr");//获取选中行
var id = row.find("[id='labeltask_id']").html();//获取name='Sid'的值
delete_labeltask_byid(id);
});
page(0,pageSize);
}

@@ -480,13 +471,13 @@ function delete_labeltask_byid(label_task_id){

function getTaskTypeDesc(task_type){
if(task_type == 1){
return "自动标注结果";
return "图片-自动标注";
}else if(task_type == 2){
return "原始数据集-图片";
return "图片";
}else if(task_type == 3){
return "原始数据集-CT影像";
return "CT影像";
}else if(task_type == 4){
return "原始数据集-视频";
return "视频";
}
return "其它";
}
@@ -508,6 +499,12 @@ function getTaskSataus(task_status,task_status_desc){
else if(task_status == -1){
return "关联的数据集已经被删除。"
}
else if(task_status == 20){
return "自动标注进行中:" + task_status_desc;
}else if(task_status == 21){
return task_status_desc;
}
return "";
}

function getVerify(task_status,id,task_type){
@@ -522,7 +519,7 @@ function getVerify(task_status,id,task_type){
}

function getLabel(task_status,id,task_type,task_flow_type){
if(task_status == 0 && (userType == 1 || userType == 0)){
if((task_status == 0 || task_status == 21) && (userType == 1 || userType == 0)){
return "<a onclick=\"personLabel(\'" + id + "\'," + task_type + ")\"><b>" + getLabelDesc(task_flow_type) + "标注</b></a><br>";
}else{
return "";
@@ -570,8 +567,59 @@ function display_list(){

$('#label_task_list tr').find('td:eq(1)').hide();
$('#label_task_list tr').find('th:eq(1)').hide();
}
isNeedToRefresh = false;
taskNeedIntervalToRefresh();
}

var isNeedToRefresh;
var refreshTimeId = [];
var refreshCount;
var refreshMaxTime;

function taskNeedIntervalToRefresh(){
var isNeedToSetInterval = false;
refreshMaxTime= 1;
if(!isEmpty(tableData)){
for (var i=0;i<tableData.length;i++){
if(tableData[i].task_status == 20){
console.log("有任务在自动标注中。需要自动刷新。");
isNeedToRefresh = true;//有任务在进行中才刷新,否则不刷新。
refreshMaxTime = 500;
break;
}
}
}
if(!isEmpty(refreshTimeId)){
for(var i =0; i < refreshTimeId.length ;i++){
console.log("清除定时器。refreshTimeId=" + refreshTimeId[i]);
window.clearInterval(refreshTimeId[i]);
}
refreshTimeId = [];
}
if(isNeedToRefresh){
refreshCount = 0;
var tmpTimeId = self.setInterval("clockRefresh('" + refreshMaxTime +"')",5000);//5秒刷新
refreshTimeId.push(tmpTimeId);
console.log("开始刷新。tmpTimeId=" + tmpTimeId);
}

}
function clockRefresh(refreshMaxTime){
refreshCount = refreshCount + 1;
if(refreshCount > refreshMaxTime){
for(var i =0; i < refreshTimeId.length ;i++){
console.log("超过刷新最大次数,清除定时器。timeId=" + refreshTimeId[i]);
window.clearInterval(refreshTimeId[i]);
}
refreshTimeId = [];
return;
}
var current = $('#displayPage1').text();
console.log("开始刷新。current=" + current);
if(current >= 1){
page(current - 1,pageSize);
}
}

function startToLabel(taskid, task_type){//从审核转回标注,标注人不变。
$.ajax({
@@ -692,12 +740,12 @@ function setMultiTaskId(){
return;
}
var taskList = [];
  Check.each(function () {//遍历
      var row = $(this).parent("td").parent("tr");//获取选中行
      var id = row.find("[id='labeltask_id']").html();//获取name='Sid'的值
taskList.push(id);
      //$('#hide_labeltaskid').val(id);
  });
Check.each(function () {//遍历
var row = $(this).parent("td").parent("tr");//获取选中行
var id = row.find("[id='labeltask_id']").html();//获取name='Sid'的值
taskList.push(id);
//$('#hide_labeltaskid').val(id);
});
setTaskId(JSON.stringify(taskList));
}


+ 53
- 41
templates/repo/datasets/label/index.tmpl View File

@@ -17,9 +17,11 @@
<div class="repository dataset dir-list view">
{{template "repo/header" .}}
<input type="hidden" id="repoId" value="{{.repoId}}">

<div class="ui container">
<div class="header">
<h3 class="modal-title">人工标注任务列表</h3>
<h3 class="modal-title">标注任务列表</h3>
</div>
<div class="ui container">
<div class="ui container">
@@ -45,8 +47,8 @@
</div>

<div class="ui container" style="height: 30px;">
<!-- <button type="button" onclick="setPredictTask();" class="ui blue button" style="float:left">新建自动标注结果图片标注</button> -->
<button type="button" onclick="setDataSetTask();" class="ui blue button" style="float:left">新建数据集图片标注</button>
<!--<button type="button" onclick="setPredictTask();" class="ui blue button" style="float:left">新建图片自动标注</button>-->
<button type="button" onclick="setDataSetTask();" class="ui blue button" style="float:left">新建图片人工标注</button>
<button type="button" onclick="setMultiTaskId();" class="ui blue button" style="float:right;margin-left:20px;">导出标注数据</button>
<button type="button" onclick="countLabel();" class="ui blue button" style="float:right;margin-left:20px;">统计所有标注数量</button>
@@ -65,7 +67,11 @@
<div class="field">
<label for="exampleInputPassword1">选择数据集对象<font color=red>*</font></label>
<select name="pre_predict_task" id="dataset_list" onchange="dataset_sele_Change(this)">
<option value="" selected="">请选择</option>
{{if .Attachments}}
{{range .Attachments}}
<option value="{{.UUID}}">{{.Name}}</option>
{{end}}
{{end}}
</select>
</div>

@@ -105,44 +111,50 @@

<div id="labelModal" class="ui predict modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 class="modal-title">新建自动标注结果人工标注</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label for="exampleInputPassword1">关联的自动标注任务<font color=red>*</font></label>
<select class="form-control" name="pre_predict_task" id="pre_predict_task_for_label" onchange="sele_Change(this)">
<option value="" selected="">请选择</option>
</select>
<!-- <input type="" class="form-control" id="prepredtaskid" placeholder="预检任务"> -->
</div>
<div class="form-group" >
<label for="exampleInputEmail2">任务指派给</label>
<select class="form-control" name="任务指派给" id="label_assign_user">
<option value=""> 请选择</option>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail1">人工标注任务名称<font color=red>*</font></label>
<input type="" class="form-control" id="labeltaskname" placeholder="校验标注任务名称,不超过32个字符" maxlength="32">
</div>
<div class="form-group">
<label id = "labelInfo" for="exampleInputFile">标注类别属性,请输入符合格式Json字符串 </label>
<select class="form-control" name="labelpropertytask" id="labelpropertytask_auto">
<option value="" selected="">请选择</option>
</select>
</div>

<i class="close icon"></i>
<div class="header">
<h4 class="modal-title">新建自动标注任务</h4>
</div>
<div class="content">
<div class="ui form">
<div class="field">
<label for="exampleInputPassword1">选择数据集对象<font color=red>*</font></label>
<select name="pre_predict_task" id="dataset_list_auto" onchange="dataset_auto_sele_Change(this)">
{{if .Attachments}}
{{range .Attachments}}
<option value="{{.UUID}}">{{.Name}}</option>
{{end}}
{{end}}
</select>
</div>
<div class="field">
<label for="exampleInputPassword1">选择标注模型<font color=red>*</font></label>
<select name="pre_predict_task" id="model_list">
<option value="" selected="">请选择</option>
</select>
</div>
<div class="field" >
<label for="exampleInputEmail1">自动标注任务名称<font color=red>*</font></label>
<input type="text" id="autolabeltaskname" placeholder="标注任务名称,不超过32个字符">
</div>

<div class="field" style="display:none">
<label for="exampleInputEmail2">任务指派给</label>
<select name="任务指派给" id="label_assign_user">
<option value="">请选择</option>
</select>
</div>

<div class="field" style="display:none">
<label id = "labelInfo" for="exampleInputFile">标注类别(也可以直接在标注界面上进行设置)</label>
<select name="labelpropertytask" id="labelpropertytask_auto" >
<option value="" selected="">请选择</option>
</select>
</div>
<button type="button" onclick="submit_labeltask();">提交</button>
</div>
<button type="button" onclick="submit_autolabeltask();">提交</button>
</div>
</div>
</div> <!-- /.box-body -->


Loading…
Cancel
Save