Browse Source

feat: 可辨识性分析优化

WANGKANG 3 months ago
parent
commit
a72d64a4d8
1 changed files with 159 additions and 20 deletions
  1. 159 20
      src/views/demo/trackSequence/index.vue

+ 159 - 20
src/views/demo/trackSequence/index.vue

@@ -9,10 +9,7 @@
     <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listTrackSequenceApi">
       <!-- 表格 header 按钮 -->
       <template #tableHeader="scope">
-        <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="openDialog(1, '注视轨迹序列新增')">
-          新增(MASC)
-        </el-button>
-        <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="addCATDialog()"> 新增(CAT) </el-button>
+        <el-button type="primary" v-auth="['demo:trackSequence:add']" icon="CirclePlus" @click="openDialog(1, '注视轨迹序列新增')"> 新增 </el-button>
         <!-- <el-button type="primary" v-auth="['demo:trackSequence:import']" icon="Upload" plain @click="batchAdd"> 导入 </el-button>
         <el-button type="primary" v-auth="['demo:trackSequence:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
         <el-button
@@ -28,10 +25,11 @@
       </template>
       <!-- 表格操作 -->
       <template #operation="scope">
-        <el-button type="primary" link icon="View" v-if="scope.row.algorithmModelId != null" @click="openModelDialog(scope.row.id)">
+        <el-button type="primary" link icon="View" @click="openDialog(3, '详情', scope.row)">
           <!--@click="openStartDialog(scope.row)"  -->
           详情
         </el-button>
+        <el-button type="primary" link icon="EditPen" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button>
         <el-button
           type="primary"
           link
@@ -116,8 +114,6 @@
         >
           模型
         </el-button>
-        <!-- <el-button type="primary" link icon="View" v-auth="['demo:toInfrared:query']" @click="openDialog(3, '查看', scope.row)"> 查看 </el-button> -->
-        <!-- <el-button type="primary" link icon="EditPen"v-auth="['demo:toInfrared:edit']" @click="openDialog(2, '编辑', scope.row)"> 编辑 </el-button> -->
         <el-button
           type="primary"
           link
@@ -154,9 +150,12 @@
                 <el-link :href="model.url" type="primary" icon="Download" :underline="false" target="_blank" style="margin-right: 20px"
                   >下载
                 </el-link>
-                <el-button type="success" link @click="addModel(model.path, model.name)"
-                  ><el-icon> <Plus /> </el-icon>添加模型</el-button
-                >
+                <el-button type="success" link @click="addModel(model.path, model.name)">
+                  <el-icon>
+                    <Plus />
+                  </el-icon>
+                  添加模型
+                </el-button>
               </el-form-item>
             </el-form>
           </el-card>
@@ -197,7 +196,7 @@ import {
 } from '@/api/modules/demo/trackSequence'
 import { enumAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
 import { getAlgorithmModelTrackApi } from '@/api/modules/demo/AlgorithmModelTrack'
-import { enumAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
+import { enumAlgorithmConfigTrackApi, getAlgorithmConfigTrackApi } from '@/api/modules/demo/AlgorithmConfigTrack'
 
 import { listDataSeqApi } from '@/api/modules/demo/DataSeq'
 import statusEnums from '@/utils/status'
@@ -209,6 +208,7 @@ import { resetHeart } from '@/utils/websocket'
 import PreviewCompareImages from '@/views/demo/components/PreviewCompareImages.vue'
 
 import ShowStatisticResult from '@/views/demo/components/ShowStatisticResult.vue'
+import { getTargetDetectionApi } from '@/api/modules/demo/TargetDetection'
 
 const showStatisticResultRef = ref()
 const showEvaluateResultRef = ref()
@@ -557,10 +557,17 @@ const formDialogRef = ref<InstanceType<typeof FormDialog> | null>(null)
 const openDialog = async (type: number, title: string, row?: any) => {
   let res = { data: {} }
   if (row?.id) {
-    res = await getTrackSequenceApi(row?.id || null)
+    res = await getTrackSequenceApi(row.id || null)
+    const params = JSON.parse(res.data['algorithmParameters'])
+    if (params.otherParams) {
+      res.data = { ...res.data, ...params.otherParams }
+    }
   }
   // 重置表单
   setItemsOptions()
+  if (row?.id) {
+    itemsOptions = await updateItemsOptions(row.algorithmId)
+  }
   const params = {
     title,
     width: 580,
@@ -619,6 +626,14 @@ const columns = reactive<ColumnProps<any>[]>([
     label: '模型名称',
     width: 200
   },
+  {
+    prop: 'algorithmParameters',
+    label: '算法参数',
+    search: {
+      el: 'input'
+    },
+    width: 150
+  },
   // {
   //   prop: 'algorithmModelId',
   //   label: '模型',
@@ -663,6 +678,52 @@ const columns = reactive<ColumnProps<any>[]>([
   { prop: 'operation', label: '操作', width: 230, fixed: 'right' }
 ])
 
+const remove_unnecessary_parameters = (itemsOptions: ProForm.ItemsOptions[]): ProForm.ItemsOptions[] => {
+  try {
+    const endIndex = itemsOptions.findIndex(option => option['label'] === '备注')
+    if (endIndex !== -1) {
+      itemsOptions = itemsOptions.slice(0, endIndex + 1)
+    }
+    return itemsOptions
+  } catch (error) {
+    console.error('移除不必要的参数时出错:', error)
+    // ElMessage.error('移除不必要的参数时出错,请检查!');
+    return itemsOptions // 返回原始选项,避免进一步的问题
+  }
+}
+
+const updateItemsOptions = async (algorithmId: any) => {
+  try {
+    const result = await getAlgorithmConfigTrackApi(algorithmId)
+    if (result.code === 200) {
+      // 处理结果
+      const parameters = JSON.parse(result.data['parameters'])
+      // console.log('parameters: ', parameters)
+
+      const itemsOptions_new = remove_unnecessary_parameters(itemsOptions)
+      for (const item of parameters) {
+        // 添加新的表单项选项
+        itemsOptions_new.push({
+          label: item['name'],
+          prop: item['agName'],
+          rules: [{ required: item['required'], message: item['agName'] + '不能为空', trigger: 'blur' }],
+          tooltip: item['prompt'],
+          compOptions: {
+            elTagName: 'input',
+            placeholder: item['defaultValue']
+            // value: item['defaultValue']
+          }
+        })
+      }
+      formDialogRef.value?.updateItemOptions(itemsOptions_new)
+      return itemsOptions_new
+    }
+  } catch (err) {
+    console.log(err)
+    ElMessage.error('获取算法配置失败,请检查!')
+  }
+}
+
 // 表单配置项
 let itemsOptions: ProForm.ItemsOptions[] = []
 const setItemsOptions = () => {
@@ -697,25 +758,97 @@ const setItemsOptions = () => {
         placeholder: '请上传数据集'
       }
     },
+    {
+      label: '选择算法',
+      prop: 'algorithmId',
+      rules: [{ required: true, message: '算法不能为空', trigger: 'blur' }],
+      compOptions: {
+        elTagName: 'select',
+        placeholder: '请选择算法',
+        enum: enumsAlgorithmConfigTrack,
+        clearable: true,
+        onChange: async (value: any) => {
+          if (value != undefined && value != null && value != '') {
+            await updateItemsOptions(value)
+          }
+        }
+      }
+    },
+    {
+      label: '任务类型',
+      prop: 'type',
+      rules: [{ required: true, message: '任务类型不能为空', trigger: 'blur' }],
+      compOptions: {
+        disabled: true,
+        elTagName: 'select',
+        placeholder: '请选择模任务类型',
+        enum: enumsAlgorithmType,
+        clearable: true,
+        value: ''
+      },
+      show: params => {
+        if (params.value.algorithmId != undefined) {
+          for (let i = 0; i < enumsAlgorithmConfigTrack.value.length; i++) {
+            if (enumsAlgorithmConfigTrack.value[i]['value'] === params.value.algorithmId) {
+              params.value.type = enumsAlgorithmConfigTrack.value[i]['type']
+              return true
+            }
+          }
+        }
+        return false
+      }
+    },
     {
       label: '选择模型',
       prop: 'algorithmModelId',
       rules: [{ required: true, message: '模型不能为空', trigger: 'blur' }],
+      show: params => {
+        if (params.value.type == AlgorithmType2['预测/推理']) {
+          return true
+        }
+        params.value.algorithmModelId = ''
+        return false
+      },
       compOptions: {
         elTagName: 'select',
         placeholder: '请选择模型',
-        enum: enumsAlgorithmModelTrack
+        enum: enumsAlgorithmModelTrack,
+        clearable: true
       }
     },
     {
-      label: '选择算法',
-      prop: 'algorithmId',
-      rules: [{ required: true, message: '请选择算法', trigger: 'blur' }],
+      label: '选择目标检测模型',
+      prop: 'algorithmModelTargetDetectionId',
+      rules: [{ required: false, message: '目标检测模型不能为空', trigger: 'blur' }],
+      show: params => {
+        if (params.value.type == AlgorithmType2['预测/推理']) {
+          return true
+        }
+        params.value.algorithmModelTargetDetectionId = ''
+        return false
+      },
       compOptions: {
-        disabled: false,
         elTagName: 'select',
-        placeholder: '请输入算法',
-        enum: enumsAlgorithmConfigTrack
+        placeholder: '请选择目标检测模型',
+        enum: enumsAlgorithmModelTrack_TD,
+        clearable: true
+      }
+    },
+    {
+      label: '上传标签',
+      prop: 'inputLabelOssId',
+      rules: [{ required: true, message: '标签不能为空', trigger: 'blur' }],
+      show: params => {
+        if (params.value.type == AlgorithmType2['测试']) {
+          return true
+        }
+        return false
+      },
+      compOptions: {
+        elTagName: 'file-upload',
+        fileSize: 4096,
+        fileType: ['txt'],
+        placeholder: '请上传标签'
       }
     },
     {
@@ -819,6 +952,7 @@ onMounted(async () => {
 })
 
 const enumsAlgorithmModelTrack = ref<any>([])
+const enumsAlgorithmModelTrack_TD = ref<any>([])
 
 const updateEnumsAlgorithmModelTrack = async () => {
   const result: any = await enumAlgorithmModelTrackApi()
@@ -829,11 +963,16 @@ const updateEnumsAlgorithmModelTrack = async () => {
     if (item.type !== AlgorithmType2['预测/推理']) {
       continue
     }
-    if (SubSystem[item['subsystem']] === '注释轨迹序列' || SubSystem[item['subsystem']] === '目标检测') {
+    if (SubSystem[item['subsystem']] === '注释轨迹序列') {
       item['label'] =
         item['value'] + '_' + item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
       enumsAlgorithmModelTrack.value.push(item)
     }
+    if (SubSystem[item['subsystem']] === '目标检测') {
+      item['label'] =
+        item['value'] + '_' + item['label'] + '-' + SubSystem[item['subsystem']] + '-' + AlgorithmType[item['type']] + '-' + item['algorithmName']
+      enumsAlgorithmModelTrack_TD.value.push(item)
+    }
   }
 }