|
@@ -24,8 +24,8 @@
|
|
|
<el-container>
|
|
|
<span class="span_class">算法任务</span>
|
|
|
<el-checkbox-group v-model="formData.tasks">
|
|
|
- <el-checkbox label="train">训练</el-checkbox>
|
|
|
- <el-checkbox label="test">测试</el-checkbox>
|
|
|
+ <el-checkbox label="1">训练</el-checkbox>
|
|
|
+ <el-checkbox label="2">测试</el-checkbox>
|
|
|
</el-checkbox-group>
|
|
|
</el-container>
|
|
|
|
|
@@ -61,18 +61,38 @@
|
|
|
|
|
|
<el-container style="height: 10px"></el-container>
|
|
|
<el-container>
|
|
|
- <span class="span_class">选择数据</span>
|
|
|
+ <span class="span_class">选择训练数据</span>
|
|
|
<el-container style="display: flex; flex-direction: column">
|
|
|
<el-container v-for="(item, index) in formData.data" :key="index" style="margin-top: 5px">
|
|
|
- <el-button v-show="formData.data" @click="showDataSelectionDialog(index)">
|
|
|
+ <el-button v-show="formData.data" @click="showDataSelectionDialog(index, true)">
|
|
|
选择批次
|
|
|
</el-button>
|
|
|
<span v-if="!item || item.length === 0" class="span_class" style="color: red; font-size: 15px">未完成</span>
|
|
|
<span v-else class="span_class" style="color: greenyellow; font-size: 15px">已选择</span>
|
|
|
- <el-button v-show="formData.data.length>1" style="margin-left: 20px" @click="removeDataItem(index)">
|
|
|
+ <el-button v-show="formData.data.length>1" style="margin-left: 20px" @click="removeDataItem(index, true)">
|
|
|
删除数据
|
|
|
</el-button>
|
|
|
- <el-button v-show="formData.taskType === '2' && index + 1 === formData.data.length" style="margin-left: 20px" @click="appendNewDataItem">
|
|
|
+ <el-button v-show="formData.taskType === '2' && index + 1 === formData.data.length" style="margin-left: 20px" @click="appendNewDataItem(true)">
|
|
|
+ 添加数据
|
|
|
+ </el-button>
|
|
|
+ </el-container>
|
|
|
+ </el-container>
|
|
|
+ </el-container>
|
|
|
+
|
|
|
+ <el-container style="height: 10px"></el-container>
|
|
|
+ <el-container>
|
|
|
+ <span class="span_class">选择测试数据</span>
|
|
|
+ <el-container style="display: flex; flex-direction: column">
|
|
|
+ <el-container v-for="(item, index) in formData.testData" :key="index" style="margin-top: 5px">
|
|
|
+ <el-button v-show="formData.testData" @click="showDataSelectionDialog(index, false)">
|
|
|
+ 选择批次
|
|
|
+ </el-button>
|
|
|
+ <span v-if="!item || item.length === 0" class="span_class" style="color: red; font-size: 15px">未完成</span>
|
|
|
+ <span v-else class="span_class" style="color: greenyellow; font-size: 15px">已选择</span>
|
|
|
+ <el-button v-show="formData.testData.length>1" style="margin-left: 20px" @click="removeDataItem(index, false)">
|
|
|
+ 删除数据
|
|
|
+ </el-button>
|
|
|
+ <el-button v-show="formData.taskType === '2' && index + 1 === formData.testData.length" style="margin-left: 20px" @click="appendNewDataItem(false)">
|
|
|
添加数据
|
|
|
</el-button>
|
|
|
</el-container>
|
|
@@ -248,41 +268,146 @@
|
|
|
<script setup lang="ts">
|
|
|
import {reactive, ref, onMounted, computed} from "vue";
|
|
|
import {addModelApi} from "@/api/modules/ag/model";
|
|
|
-import {getAlgorithmOptionApi} from "@/api/modules/task/task";
|
|
|
+import {createTaskApi, getAlgorithmOptionApi} from "@/api/modules/task/task";
|
|
|
import FormDialog from "@/components/FormDialog/index.vue";
|
|
|
import { useRouter } from 'vue-router'
|
|
|
import {listTaskConfigurationApi} from "@/api/modules/task/taskConfiguration";
|
|
|
import {batchListDataApi} from "@/api/modules/demo/data";
|
|
|
-// TODO: 向后端发送接口
|
|
|
+import {listDataApi} from "@/api/modules/system/dictData";
|
|
|
+import {ElMessage} from "element-plus";
|
|
|
+const valid = data => {
|
|
|
+ let ret = {
|
|
|
+ code: 400,
|
|
|
+ message: 'OK'
|
|
|
+ }
|
|
|
+ if (!data.taskName || data.taskName.length === 0) {
|
|
|
+ ret.message = '任务名称不能为空'
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ if (!data.taskItemList || data.taskItemList.length === 0) {
|
|
|
+ ret.message = '请选择算法任务'
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ data.algTaskList.forEach(obj => {
|
|
|
+ if (!obj || !obj.id) {
|
|
|
+ ret.message = '请选择算法模型'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (ret.message !== 'OK') {
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ if (data.taskItemList.includes('1')) {
|
|
|
+ data.trainBatchNumList.forEach(obj => {
|
|
|
+ if (!obj) {
|
|
|
+ ret.message = '请选择训练数据集'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (ret.message !== 'OK') {
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.taskItemList.includes('2')) {
|
|
|
+ data.testBatchNumList.forEach(obj => {
|
|
|
+ if (!obj) {
|
|
|
+ ret.message = '请选择测试数据集'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (ret.message !== 'OK') {
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.hasTrainAugmentation) {
|
|
|
+ if (!data.trainAugmentationParams || data.trainAugmentationParams.length === 0) {
|
|
|
+ ret.message = '请配置扩增参数'
|
|
|
+ return ret
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ret.code = 200
|
|
|
+ return ret
|
|
|
+}
|
|
|
+
|
|
|
const submit = () => {
|
|
|
- console.log('submit', formData)
|
|
|
+ const params = {
|
|
|
+ taskName: formData.taskName,
|
|
|
+ taskType: formData.taskType,
|
|
|
+ taskItemList: formData.tasks,
|
|
|
+ algTaskList: formData.algorithms,
|
|
|
+ trainBatchNumList: formData.data,
|
|
|
+ testBatchNumList: formData.testData,
|
|
|
+ hasTrainAugmentation: formData.expandData,
|
|
|
+ trainAugmentationParams: formData.expandConfig
|
|
|
+ }
|
|
|
+ let result = valid(params)
|
|
|
+ // console.log(result)
|
|
|
+ if (result.code !== 200) {
|
|
|
+ ElMessage.error(result.message)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ params.algTaskList.forEach(obj => {
|
|
|
+ obj.algorithmId = obj.id;
|
|
|
+ // if (!obj.trainParams) {
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ obj.params = JSON.stringify(JSON.parse(obj.trainParams)) + ";;;" +
|
|
|
+ JSON.stringify(JSON.parse(obj.verifyParams)) + ";;;" +
|
|
|
+ JSON.stringify(JSON.parse(obj.testParams))
|
|
|
+ })
|
|
|
+ // console.log('submit', params)
|
|
|
+
|
|
|
+ createTaskApi(params)
|
|
|
+ .then(res => {
|
|
|
+ // console.log(res)
|
|
|
+ if (res.code !== 200) {
|
|
|
+ ElMessage.error(res.msg)
|
|
|
+ } else {
|
|
|
+ router.push(`/index`)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
}
|
|
|
-// TODO: 数据扩增超参配置,默认数据从哪里来
|
|
|
+
|
|
|
+const loadExpandDataParams = () => {
|
|
|
+ listDataApi({
|
|
|
+ dictType: 'expand_data_params',
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10000
|
|
|
+ })
|
|
|
+ .then(res => {
|
|
|
+ // console.log(res)
|
|
|
+ expandDataConfig.value = reactive([])
|
|
|
+ res.data.list.forEach(obj => {
|
|
|
+ expandDataConfig.value.push({
|
|
|
+ name: obj.dictLabel,
|
|
|
+ defaultValue: obj.dictValue
|
|
|
+ })
|
|
|
+ })
|
|
|
+ expandDataDialogVisible.value = true
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
const showExpandDataSuperParameterConfig = () => {
|
|
|
- expandDataDialogVisible.value = true
|
|
|
+ loadExpandDataParams()
|
|
|
}
|
|
|
// 数据扩增超参修改保存
|
|
|
const submitExpandDataConfigDialog = () => {
|
|
|
// console.log(expandDataConfig)
|
|
|
- formData.expandConfig = JSON.stringify(expandDataConfig)
|
|
|
+ formData.expandConfig = JSON.stringify(expandDataConfig.value)
|
|
|
expandDataDialogVisible.value = false
|
|
|
}
|
|
|
|
|
|
const expandDataDialogVisible = ref(false)
|
|
|
|
|
|
let expandDataConfig = ref(reactive([
|
|
|
- {
|
|
|
- name: 'config1',
|
|
|
- defaultValue: 'a'
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'config2',
|
|
|
- defaultValue: 'b'
|
|
|
- },
|
|
|
- {
|
|
|
- name: 'config3',
|
|
|
- defaultValue: 'c'
|
|
|
- },
|
|
|
+ // {
|
|
|
+ // name: 'config1',
|
|
|
+ // defaultValue: 'a'
|
|
|
+ // }
|
|
|
]))
|
|
|
|
|
|
const submitConfigDialog = () => {
|
|
@@ -298,7 +423,11 @@ const submitDataDialog = () => {
|
|
|
for (let i = 0; i < selectedBatchDataList.value.length; i++) {
|
|
|
val += selectedBatchDataList.value[i].batchNum + ','
|
|
|
}
|
|
|
- formData.data[selectDataIndex] = val.substring(0, val.length - 1)
|
|
|
+ if (bIsTrainData.value) {
|
|
|
+ formData.data[selectDataIndex] = val.substring(0, val.length - 1)
|
|
|
+ } else {
|
|
|
+ formData.testData[selectDataIndex] = val.substring(0, val.length - 1)
|
|
|
+ }
|
|
|
dataDialogVisible.value = false
|
|
|
}
|
|
|
const canSelect = computed(() => {
|
|
@@ -360,6 +489,7 @@ const clickDeselectData = () => {
|
|
|
selectedBatchDataList.value = reactive(newArray)
|
|
|
}
|
|
|
const router = useRouter()
|
|
|
+let bIsTrainData = ref(false)
|
|
|
let dialogVisible = ref(false)
|
|
|
let batchDataList = ref(reactive([]))
|
|
|
let selectedBatchDataList = ref(reactive([]))
|
|
@@ -376,15 +506,21 @@ const formData = reactive({
|
|
|
algoIdx: [
|
|
|
null
|
|
|
],
|
|
|
+ // 训练数据
|
|
|
data: [
|
|
|
null
|
|
|
],
|
|
|
+ // 测试数据
|
|
|
+ testData: [
|
|
|
+ null
|
|
|
+ ],
|
|
|
expandData: false,
|
|
|
expandConfig: ''
|
|
|
})
|
|
|
let selectDataIndex = null
|
|
|
const dataDialogVisible = ref(false)
|
|
|
-const showDataSelectionDialog = index => {
|
|
|
+const showDataSelectionDialog = (index, isTrainData) => {
|
|
|
+ bIsTrainData.value = isTrainData
|
|
|
batchDataList.value = queryBatchData.value
|
|
|
selectedBatchDataList.value = reactive([])
|
|
|
tempSelectedBatchDataList.value = reactive([])
|
|
@@ -487,15 +623,23 @@ const appendNewItem = () => {
|
|
|
formData.algorithms.push({})
|
|
|
formData.algoIdx.push(null)
|
|
|
}
|
|
|
-const appendNewDataItem = () => {
|
|
|
- formData.data.push([])
|
|
|
+const appendNewDataItem = isTrainData => {
|
|
|
+ if (isTrainData) {
|
|
|
+ formData.data.push([])
|
|
|
+ } else {
|
|
|
+ formData.testData.push([])
|
|
|
+ }
|
|
|
}
|
|
|
const removeItem = idx => {
|
|
|
formData.algorithms.splice(idx, 1)
|
|
|
formData.algoIdx.splice(idx, 1)
|
|
|
}
|
|
|
-const removeDataItem = idx => {
|
|
|
- formData.data.splice(idx, 1)
|
|
|
+const removeDataItem = (idx, isTrainData) => {
|
|
|
+ if (isTrainData) {
|
|
|
+ formData.data.splice(idx, 1)
|
|
|
+ } else {
|
|
|
+ formData.testData.splice(idx, 1)
|
|
|
+ }
|
|
|
}
|
|
|
const cancel = () => {
|
|
|
// console.log('cancel')
|