index.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799
  1. <template>
  2. <div class="table-box">
  3. <ProTable ref="proTable" :columns="columns" row-key="id" :request-api="listDataAugmentationApi3">
  4. <!-- 表格 header 按钮 -->
  5. <template #tableHeader="scope">
  6. <el-button type="primary" v-auth="['demo:DataAugmentation:add']" icon="CirclePlus" @click="openDialog(1, '任务新增')"> 新增 </el-button>
  7. <!-- <el-button type="primary" v-auth="['demo:DataAugmentation:import']" icon="Upload" plain @click="batchAdd"> 导入</el-button> -->
  8. <!-- <el-button type="primary" v-auth="['demo:DataAugmentation:export']" icon="Download" plain @click="downloadFile"> 导出 </el-button> -->
  9. <el-button
  10. type="danger"
  11. v-auth="['demo:DataAugmentation:remove']"
  12. icon="Delete"
  13. plain
  14. :disabled="!scope.isSelected"
  15. @click="batchDelete(scope.selectedListIds)"
  16. >
  17. 批量删除
  18. </el-button>
  19. </template>
  20. <!-- 表格操作 -->
  21. <template #operation="scope">
  22. <el-button type="primary" link icon="View" @click="startDataAugmentation(scope.row)" v-if="scope.row.status == '4'"> 继续 </el-button>
  23. <el-button type="primary" link icon="View" @click="startDataAugmentation(scope.row)" v-if="scope.row.status == '0'"> 开始 </el-button>
  24. <el-popconfirm title="确定终止此任务吗?" @confirm="stopDataAugmentation(scope.row)" v-if="scope.row.status == '1'">
  25. <template #reference>
  26. <el-button type="primary" link icon="View"> 终止 </el-button>
  27. </template>
  28. </el-popconfirm>
  29. <el-popconfirm title="确定暂停此任务吗?" @confirm="pauseDataAugmentation(scope.row)" v-if="scope.row.status == '1'">
  30. <template #reference>
  31. <el-button type="primary" link icon="View"> 暂停 </el-button>
  32. </template>
  33. </el-popconfirm>
  34. <el-button type="primary" link icon="View" @click="preview(scope.row)" v-if="scope.row.status == '2'"> 预览 </el-button>
  35. <el-button type="primary" link icon="View" @click="downloadFile(scope.row)" v-if="scope.row.status == '2'"> 导出 </el-button>
  36. <el-button type="primary" link icon="View" @click="openMetricDialog(scope.row.id)" v-if="scope.row.status == '2'"> 指标 </el-button>
  37. <el-button type="primary" link icon="View" v-auth="['demo:DataAugmentation:query']" @click="openDialog(3, '任务查看', scope.row)">
  38. 查看
  39. </el-button>
  40. <el-button
  41. type="primary"
  42. link
  43. icon="View"
  44. v-auth="['demo:DataAugmentation:query']"
  45. @click="viewLogRef.handleOpen(scope.row.id)"
  46. v-if="scope.row.status != '0'"
  47. >
  48. 日志
  49. </el-button>
  50. <el-button type="primary" link icon="Delete" v-auth="['demo:DataAugmentation:remove']" @click="deleteDataAugmentation(scope.row)">
  51. 删除
  52. </el-button>
  53. </template>
  54. </ProTable>
  55. <DataAugmentationFormDialog ref="formDialogRef" />
  56. <ImportExcel ref="dialogRef" />
  57. <!-- <el-dialog v-model="dialogVisible" title="结果预览" width="80%">
  58. <div style="display: flex; text-align: center">
  59. <div style="width: 50%" v-if="inputVideoUrl">
  60. <video controls width="90%">
  61. <source :src="inputVideoUrl" />
  62. Your browser does not support the video tag.
  63. </video>
  64. </div>
  65. <div style="width: 50%" v-if="outputVideoUrl">
  66. <video controls width="90%">
  67. <source :src="outputVideoUrl" />
  68. Your browser does not support the video tag.
  69. </video>
  70. </div>
  71. </div>
  72. </el-dialog> -->
  73. <el-dialog v-model="dialogVisible" :title="dialogTitle" width="80%" @close="handleClose">
  74. <el-select v-model="imageFps" placeholder="选择帧率" style="width: 200px" @change="changeFps">
  75. <el-option label="0" value="0"></el-option>
  76. <el-option label="5" value="5"></el-option>
  77. <el-option label="15" value="15"></el-option>
  78. <el-option label="30" value="30"></el-option>
  79. </el-select>
  80. <div class="image-dialog" v-if="imageIdx >= 0 && cacheImages[imageIdx]">
  81. <div style="width: 50%">
  82. <el-image :src="cacheImages[imageIdx].origin[0]"></el-image>
  83. </div>
  84. <div style="width: 50%">
  85. <el-image :src="cacheImages[imageIdx].stable[0]"></el-image>
  86. </div>
  87. </div>
  88. <div class="image-dialog-btn" v-if="imageFps == 0">
  89. <el-button type="primary" @click="pre_picture" :disabled="imageIdx <= 0">上一个</el-button>
  90. <el-button type="primary" @click="next_picture" :disabled="imageIdx >= fileCount - 1">下一个</el-button>
  91. </div>
  92. </el-dialog>
  93. <ViewLog ref="viewLogRef" :get-log-api="getDialogApi" />
  94. <PreviewCompareImages ref="previewCompareImagesRef" />
  95. <el-dialog v-model="metricDialogVisible" title="算法结果指标" width="500px" style="text-align: center">
  96. <el-table :data="metricList" style="width: 100%; margin-left: 10%; text-align: left">
  97. <el-table-column prop="name" label="name" width="200px" />
  98. <el-table-column prop="value" label="value" width="200px" />
  99. </el-table>
  100. </el-dialog>
  101. </div>
  102. </template>
  103. <script setup lang="tsx" name="DataAugmentation">
  104. import { ref, reactive, onMounted, computed, onUnmounted, onBeforeMount, watch, nextTick } from 'vue'
  105. import { useHandleData } from '@/hooks/useHandleData'
  106. import { useDownload } from '@/hooks/useDownload'
  107. import { ElMessageBox, ElMessage } from 'element-plus'
  108. import ProTable from '@/components/ProTable/index.vue'
  109. import ImportExcel from '@/components/ImportExcel/index.vue'
  110. import ViewLog from '@/views/demo/components/ViewLog.vue'
  111. import PreviewCompareImages from '@/views/demo/components/PreviewCompareImages.vue'
  112. import DataAugmentationFormDialog from '@/components/DataAugmentationFormDialog/index.vue'
  113. import { ProTableInstance, ColumnProps, EnumProps } from '@/components/ProTable/interface'
  114. import {
  115. listDataAugmentationApi3,
  116. delDataAugmentationApi,
  117. addDataAugmentationApi,
  118. updateDataAugmentationApi,
  119. importTemplateApi,
  120. importDataAugmentationDataApi,
  121. exportDataAugmentationApi,
  122. getDataAugmentationApi,
  123. startDataAugmentationApi,
  124. stopDataAugmentationApi,
  125. getCompareImageApi,
  126. getCompareImageCountApi,
  127. getDialogApi,
  128. getTaskDictData,
  129. getMetricApi,
  130. getVideoUrl,
  131. getCompareImageApiNew,
  132. pauseDataAugmentationApi
  133. } from '@/api/modules/demo/dataAugmentation'
  134. import { getDictsApi } from '@/api/modules/system/dictData'
  135. // import { VideoPlayer } from 'vue-video-player'
  136. // import 'vue-video-player/dist/simple.css'
  137. // const playerOptions = ref({})
  138. // const videoPlayer = ref<InstanceType<typeof VideoPlayer> | null>(null);
  139. // const playVideo = () => {
  140. // if (videoPlayer.value) {
  141. // videoPlayer.value.player.play();
  142. // }
  143. // };
  144. // const pauseVideo = () => {
  145. // if (videoPlayer.value) {
  146. // videoPlayer.value.player.pause();
  147. // }
  148. // };
  149. // const onPlay = () => {
  150. // console.log('视频开始播放');
  151. // };
  152. // const onPause = () => {
  153. // console.log('视频暂停播放');
  154. // };
  155. // const setPlayerOptions = (url) => {
  156. // playerOptions.value = {
  157. // sources: [{
  158. // type: "video/mp4",
  159. // src: url
  160. // }],
  161. // poster: "", // 视频封面图
  162. // autoplay: false,
  163. // controls: true,
  164. // fluid: true // 响应式布局
  165. // }
  166. // }
  167. const previewCompareImagesRef = ref()
  168. const preview = async row => {
  169. // console.log(row)
  170. await previewCompareImagesRef.value.handleOpen(getCompareImageApiNew, row.id)
  171. }
  172. const handleClose = () => {
  173. if (intervalChangeFps.value) {
  174. clearInterval(intervalChangeFps.value)
  175. }
  176. }
  177. const changeFps = () => {
  178. console.log('changeFps')
  179. if (intervalChangeFps.value) {
  180. clearInterval(intervalChangeFps.value)
  181. }
  182. if (imageFps.value == 0) {
  183. return
  184. }
  185. imageIdx.value = 1
  186. intervalChangeFps.value = setInterval(() => {
  187. next_picture()
  188. }, 1000 / imageFps.value)
  189. }
  190. const dialogVisible = ref(false)
  191. const taskId = ref('')
  192. const imageIdx = ref(0)
  193. const imageBase64List = ref({
  194. origin: '',
  195. stable: ''
  196. })
  197. const inFileCount = ref(0)
  198. const outFileCount = ref(0)
  199. const cacheImages = ref({})
  200. const dialogTitle = ref('')
  201. const fileCount = ref(0)
  202. const imageFps = ref(0)
  203. const intervalChangeFps: any = ref()
  204. const loadImageData = async (taskId: string, imageIdx: number) => {
  205. const res: any = await getCompareImageApi(taskId, imageIdx)
  206. // imageBase64List.value.origin = res.origin
  207. // imageBase64List.value.stable = res.stable
  208. cacheImages.value[imageIdx].origin = res.origin
  209. cacheImages.value[imageIdx].stable = res.stable
  210. }
  211. const task_type_view = ref('')
  212. const compareDataAugmentation = async (params: any) => {
  213. if (taskId.value !== '' && taskId.value !== null && taskId.value !== undefined && taskId.value == params.id) {
  214. dialogVisible.value = true
  215. return
  216. }
  217. task_type_view.value = params.taskType
  218. taskId.value = params.id
  219. imageIdx.value = 0
  220. cacheImages.value = {}
  221. const resCount: any = await getCompareImageCountApi(params.id)
  222. if (resCount.code === 200) {
  223. inFileCount.value = resCount.data.inFileCount
  224. outFileCount.value = resCount.data.outFileCount
  225. } else {
  226. ElMessage.error('获取图片对比数量失败')
  227. return
  228. }
  229. dialogVisible.value = true
  230. dialogTitle.value = '缓存图片中'
  231. fileCount.value = Math.min(inFileCount.value, outFileCount.value)
  232. const res: any = await getCompareImageApi(taskId.value)
  233. for (let idx = 1; idx <= fileCount.value; idx++) {
  234. dialogTitle.value = '缓存图片中: 第' + idx + '个样本 共' + fileCount.value + '个样本'
  235. if (cacheImages.value[idx - 1]) {
  236. continue
  237. }
  238. //const res: any = await getCompareImageApi(taskId.value, idx - 1)
  239. // console.log(res)
  240. cacheImages.value[idx - 1] = {
  241. origin: res.origin[idx - 1],
  242. stable: res.stable[idx - 1]
  243. }
  244. }
  245. // console.log(cacheImages.value[0])
  246. if (fileCount.value > 0) {
  247. dialogTitle.value = '预览: 第1个样本 共' + fileCount.value + '个样本'
  248. } else {
  249. dialogTitle.value = '无结果预览'
  250. }
  251. // next_picture()
  252. }
  253. const next_picture = async () => {
  254. if (imageIdx.value < fileCount.value - 1) {
  255. if (!cacheImages.value[imageIdx.value + 1]) {
  256. await loadImageData(taskId.value, imageIdx.value + 1)
  257. }
  258. imageIdx.value = imageIdx.value + 1
  259. }
  260. dialogTitle.value = '预览: 第' + (imageIdx.value + 1) + '个样本 共' + fileCount.value + '个样本'
  261. }
  262. const pre_picture = async () => {
  263. if (imageIdx.value > 0) {
  264. if (!cacheImages.value[imageIdx.value - 1]) {
  265. await loadImageData(taskId.value, imageIdx.value - 1)
  266. }
  267. imageIdx.value = imageIdx.value - 1
  268. }
  269. dialogTitle.value = '预览: 第' + (imageIdx.value + 1) + '个样本 共' + fileCount.value + '个样本'
  270. }
  271. //打开指标窗口查看算法指标信息
  272. const metricDialogVisible = ref(false)
  273. const metricList = reactive([])
  274. const openMetricDialog = async (id: string | number) => {
  275. const res: any = await getMetricApi(id)
  276. console.log(res.data)
  277. metricList.splice(0, metricList.length, ...res.data)
  278. metricDialogVisible.value = true
  279. }
  280. // const dialogVisible = ref(false)
  281. const inputVideoUrl = ref()
  282. const outputVideoUrl = ref()
  283. // const openResultDialog = async (id: string | number) => {
  284. // const res: any = await getVideoUrl(id)
  285. // inputVideoUrl.value = res.data.input
  286. // outputVideoUrl.value = res.data.output
  287. // //setPlayerOptions(inputVideoUrl.value)
  288. // // inputVideoUrl.value = '/api/public/video/input/' + id
  289. // // outputVideoUrl.value = '/api/public/video/output/' + id
  290. // console.log(inputVideoUrl)
  291. // dialogVisible.value = true
  292. // }
  293. const taskType = ref([])
  294. const modelType = ref([
  295. {
  296. label: 'yolov8_best.pt',
  297. value: 'yolov8_best.pt'
  298. },
  299. {
  300. label: 'yolov8_best_new.pt',
  301. value: 'yolov8_best_new.pt'
  302. },
  303. {
  304. label: 'yolov8__best.pt',
  305. value: 'yolov8__best.pt'
  306. },
  307. {
  308. label: 'yolov8__best_new.pt',
  309. value: 'yolov8__best_new.pt'
  310. }
  311. ])
  312. const trackingMethod = ref([
  313. {
  314. label: 'botsort',
  315. value: 'botsort'
  316. },
  317. {
  318. label: 'strongsort',
  319. value: 'strongsort'
  320. },
  321. {
  322. label: 'bytetrack',
  323. value: 'bytetrack'
  324. },
  325. {
  326. label: 'ocsort',
  327. value: 'ocsort'
  328. },
  329. {
  330. label: 'imprassoc',
  331. value: 'imprassoc'
  332. },
  333. {
  334. label: 'deepocsort',
  335. value: 'deepocsort'
  336. }
  337. ])
  338. const taskTypeEnums: EnumProps[] = []
  339. const hyperparameterConfiguration = []
  340. const viewLogRef = ref()
  341. const getTaskType = async () => {
  342. const res: any = await getTaskDictData('多目标跟踪')
  343. if (res.data.length != 0) {
  344. taskType.value = res.data
  345. .map(item => {
  346. return {
  347. label: item.taskType,
  348. value: item.taskType
  349. }
  350. })
  351. .filter(item => item !== null)
  352. res.data.forEach(item => {
  353. taskTypeEnums.push({
  354. label: item.taskType,
  355. value: item.taskType,
  356. disabled: false,
  357. tagType: 'default'
  358. })
  359. let obj = {}
  360. obj[item.taskType] = item.hyperparameterConfiguration
  361. hyperparameterConfiguration.push(obj)
  362. })
  363. }
  364. }
  365. let intervalId: NodeJS.Timeout | null = null
  366. onUnmounted(() => {
  367. // 组件卸载时清除定时器
  368. if (intervalId !== null) {
  369. clearInterval(intervalId)
  370. }
  371. })
  372. onMounted(() => {
  373. intervalId = setInterval(async () => {
  374. proTable.value?.getTableList()
  375. }, 5000)
  376. getTaskType()
  377. getZipFileDes()
  378. })
  379. const zipFileDes = ref('')
  380. const getZipFileDes = async () => {
  381. let res = await getDictsApi('zip_file_format_description')
  382. res.data.forEach(item => {
  383. // 检查item对象是否包含dict和des属性
  384. if (item.dictLabel === '多目标追踪') {
  385. zipFileDes.value = item.remark
  386. }
  387. })
  388. }
  389. const startDataAugmentation = async (params: any) => {
  390. const res = await startDataAugmentationApi(params.id)
  391. if (res.code === 200) {
  392. ElMessage.success('任务已经开始,请等待')
  393. } else {
  394. ElMessage.error('任务开始失败,请检查!')
  395. }
  396. proTable.value?.getTableList()
  397. }
  398. const stopDataAugmentation = async (params: any) => {
  399. const res = await stopDataAugmentationApi(params.id)
  400. if (res.code === 200) {
  401. ElMessage.success('任务终止成功')
  402. } else {
  403. ElMessage.error('任务终止失败!')
  404. }
  405. proTable.value?.getTableList()
  406. }
  407. const pauseDataAugmentation = async (params: any) => {
  408. const res = await pauseDataAugmentationApi(params.id)
  409. if (res.code === 200) {
  410. ElMessage.success('任务暂停成功')
  411. } else {
  412. ElMessage.error('任务暂停失败!')
  413. }
  414. proTable.value?.getTableList()
  415. }
  416. // ProTable 实例
  417. const proTable = ref<ProTableInstance>()
  418. // 删除视频去抖动信息
  419. const deleteDataAugmentation = async (params: any) => {
  420. await useHandleData(delDataAugmentationApi, params.id, '删除任务【' + params.name + '】?')
  421. proTable.value?.getTableList()
  422. }
  423. // 批量删除视频去抖动信息
  424. const batchDelete = async (ids: string[]) => {
  425. await useHandleData(delDataAugmentationApi, ids, '删除所选任务?')
  426. proTable.value?.clearSelection()
  427. proTable.value?.getTableList()
  428. }
  429. // 导出视频去抖动列表
  430. const downloadFile = async task => {
  431. ElMessageBox.confirm('确认导出任务数据?', '温馨提示', { type: 'warning' }).then(() =>
  432. useDownload(exportDataAugmentationApi, 'export', task.outputPath)
  433. )
  434. }
  435. // 批量添加视频去抖动
  436. const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
  437. const formDialogRef = ref<InstanceType<typeof DataAugmentationFormDialog> | null>(null)
  438. // 打开弹框的功能
  439. const openDialog = async (type: number, title: string, row?: any) => {
  440. // hyperparameter.value = ''
  441. let res = { data: {} }
  442. if (row?.id) {
  443. res = await getDataAugmentationApi(row?.id || null)
  444. // hyperparameter.value = res.data?.hyperparameterConfiguration
  445. }
  446. // console.log(itemsOptions[1].compOptions?.value)
  447. // 重置表单
  448. // setItemsOptions()
  449. const params = {
  450. title,
  451. width: 580,
  452. isEdit: type !== 3,
  453. itemsOptions: itemsOptions,
  454. model: type == 1 ? model : res.data,
  455. api: type == 1 ? addDataAugmentationApi : updateDataAugmentationApi,
  456. getTableList: proTable.value?.getTableList
  457. }
  458. formDialogRef.value?.openDialog(params)
  459. }
  460. const statusEnums: EnumProps[] = [
  461. {
  462. label: '未开始',
  463. value: '0',
  464. disabled: false,
  465. tagType: 'default'
  466. },
  467. {
  468. label: '进行中',
  469. value: '1',
  470. disabled: false,
  471. tagType: 'primary'
  472. },
  473. {
  474. label: '完成',
  475. value: '2',
  476. disabled: false,
  477. tagType: 'success'
  478. },
  479. {
  480. label: '失败',
  481. value: '3',
  482. disabled: false,
  483. tagType: 'danger'
  484. },
  485. {
  486. label: '已中断',
  487. value: '4',
  488. disabled: false,
  489. tagType: 'default'
  490. }
  491. ]
  492. // 表格配置项
  493. const columns = reactive<ColumnProps<any>[]>([
  494. { type: 'selection', fixed: 'left', width: 70 },
  495. { prop: 'id', label: '主键ID', width: 180 },
  496. {
  497. prop: 'name',
  498. label: '任务名称',
  499. search: {
  500. el: 'input'
  501. },
  502. width: 150
  503. },
  504. {
  505. prop: 'taskType',
  506. label: '任务类型',
  507. search: {
  508. el: 'select'
  509. },
  510. width: 100,
  511. tag: true,
  512. enum: taskTypeEnums
  513. },
  514. {
  515. prop: 'status',
  516. label: '任务状态',
  517. search: {
  518. el: 'select'
  519. },
  520. width: 100,
  521. tag: true,
  522. enum: statusEnums
  523. },
  524. {
  525. prop: 'startTime',
  526. label: '开始时间',
  527. width: 180
  528. },
  529. {
  530. prop: 'endTime',
  531. label: '结束时间',
  532. width: 180
  533. },
  534. {
  535. prop: 'costSecond',
  536. label: '耗时',
  537. search: {
  538. el: 'input'
  539. },
  540. width: 80
  541. },
  542. {
  543. prop: 'log',
  544. label: '日志',
  545. width: 120
  546. },
  547. {
  548. prop: 'algorithmPath',
  549. label: '日志路径',
  550. width: 120
  551. },
  552. {
  553. prop: 'hyperparameterConfiguration',
  554. label: '超参配置',
  555. width: 120
  556. },
  557. {
  558. prop: 'remarks',
  559. label: '备注',
  560. search: {
  561. el: 'input'
  562. },
  563. width: 120
  564. },
  565. {
  566. prop: 'operation',
  567. label: '操作',
  568. width: 230,
  569. fixed: 'right'
  570. }
  571. ])
  572. // 表单配置项
  573. let itemsOptions: ProForm.ItemsOptions[] = [
  574. {
  575. label: '任务名称',
  576. prop: 'name',
  577. rules: [{ required: true, message: '任务名称不能为空', trigger: 'blur' }],
  578. compOptions: {
  579. placeholder: '请输入任务名称'
  580. }
  581. },
  582. {
  583. label: '任务类型',
  584. prop: 'taskType',
  585. rules: [{ required: true, message: '任务类型不能为空', trigger: 'change' }],
  586. compOptions: {
  587. elTagName: 'select', // 指定使用 el-select 组件
  588. placeholder: '请选择任务类型',
  589. enum: taskType,
  590. onChange: (value: string) => {
  591. model.value['taskType'] = value
  592. hyperparameterConfiguration.forEach(obj => {
  593. if (value in obj) {
  594. // console.log(obj[value])
  595. addParams(obj[value], value)
  596. openDialog(1, '任务新增')
  597. }
  598. })
  599. }
  600. }
  601. },
  602. {
  603. label: '图片集压缩包',
  604. prop: 'inputOssId',
  605. tooltip: zipFileDes,
  606. rules: [{ required: true, message: '数据压缩包不能为空', trigger: 'change' }],
  607. compOptions: {
  608. elTagName: 'file-upload',
  609. fileSize: 4096,
  610. fileType: ['zip'],
  611. placeholder: '请上传图片集压缩包'
  612. }
  613. },
  614. {
  615. label: '备注',
  616. prop: 'remarks',
  617. rules: [
  618. {
  619. required: false,
  620. trigger: 'blur'
  621. }
  622. ],
  623. compOptions: {
  624. placeholder: '请输入备注'
  625. }
  626. }
  627. ]
  628. const model = ref({})
  629. const setItemsOptions = () => {
  630. if (itemsOptions.length > 4) {
  631. itemsOptions.splice(4) // 如果里面有新增参数,删除,重新添加
  632. }
  633. }
  634. const addParams = (params, task_Type) => {
  635. setItemsOptions()
  636. if (params == 'null') {
  637. return
  638. }
  639. let validJsonString = params.replace(/'/g, '"')
  640. // if (task_Type === '多目标跟踪') {
  641. // itemsOptions.push({
  642. // label: '模型',
  643. // prop: 'yolo_model',
  644. // rules: [{ trigger: 'blur' }],
  645. // compOptions: {
  646. // elTagName: 'select',
  647. // enum: modelType,
  648. // placeholder: '默认值为' + 'yolov8__best.pt'
  649. // }
  650. // })
  651. // itemsOptions.push({
  652. // label: '跟踪方法',
  653. // prop: 'tracking_method',
  654. // rules: [{ trigger: 'blur' }],
  655. // compOptions: {
  656. // elTagName: 'select',
  657. // enum: trackingMethod,
  658. // placeholder: '默认值为' + 'bytetrack'
  659. // }
  660. // })
  661. // }
  662. // model.value['tracking_method'] = 'bytetrack'
  663. model.value['yolo_model'] = 'yolov8__best.pt'
  664. try {
  665. const obj = JSON.parse(validJsonString)
  666. obj.forEach(param => {
  667. model.value[param.agName] = param.defaultValue
  668. itemsOptions.push({
  669. tooltip: param.prompt,
  670. label: param.name,
  671. prop: param.agName,
  672. rules: [],
  673. compOptions: {
  674. type: 'input',
  675. clearable: true,
  676. placeholder: '默认值为' + param.defaultValue
  677. }
  678. })
  679. })
  680. // const obj: { [key: string]: number } = JSON.parse(validJsonString)
  681. // Object.keys(obj).forEach(key => {
  682. // model.value[key] = obj[key]
  683. // if (key === 'conf' || key === 'iou') {
  684. // itemsOptions.push({
  685. // label: key,
  686. // prop: key,
  687. // rules: [
  688. // {
  689. // trigger: 'change',
  690. // validator: (rule, value, callback) => {
  691. // if (value === '' || value === undefined) {
  692. // return callback()
  693. // }
  694. // if (!value) {
  695. // return callback(new Error('请输入一个0到1之间的浮点数'))
  696. // }
  697. // const regex = /^(0(\.\d+)?|1(\.0+)?)$/
  698. // if (!regex.test(value)) {
  699. // return callback(new Error('请输入一个0到1之间的浮点数'))
  700. // }
  701. // callback()
  702. // }
  703. // }
  704. // ],
  705. // compOptions: {
  706. // type: 'input',
  707. // clearable: true,
  708. // placeholder: '默认值为' + obj[key]
  709. // }
  710. // })
  711. // } else if (key === 'imgsz') {
  712. // itemsOptions.push({
  713. // label: key,
  714. // prop: key,
  715. // rules: [
  716. // {
  717. // trigger: 'change',
  718. // validator: (rule, value, callback) => {
  719. // //console.log(value)
  720. // if (value === '' || value === undefined) {
  721. // return callback()
  722. // }
  723. // if (!value) {
  724. // return callback(new Error('请输入一个大于0的整数'))
  725. // }
  726. // const regex = /^[1-9]\d*$/
  727. // if (!regex.test(value)) {
  728. // return callback(new Error('请输入一个大于0的整数'))
  729. // }
  730. // callback()
  731. // }
  732. // }
  733. // ],
  734. // compOptions: {
  735. // type: 'input',
  736. // clearable: true,
  737. // placeholder: '默认值为' + obj[key]
  738. // }
  739. // })
  740. // }
  741. // })
  742. } catch (error) {
  743. console.error('解析 JSON 字符串时出错:', error)
  744. }
  745. }
  746. </script>
  747. <style lang="scss" scoped>
  748. .image-dialog {
  749. display: flex;
  750. align-items: center;
  751. justify-content: center;
  752. .el-image {
  753. margin-right: 20px;
  754. margin-bottom: 20px;
  755. }
  756. }
  757. .image-dialog-btn {
  758. display: flex;
  759. justify-content: center;
  760. margin-top: 20px;
  761. }
  762. </style>