Browse Source

修正代码。

Signed-off-by: zouap <zouap@pcl.ac.cn>
tags/v1.22.7.1
zouap 3 years ago
parent
commit
cab30a7640
5 changed files with 35 additions and 43 deletions
  1. +2
    -2
      routers/api/v1/repo/cloudbrain.go
  2. +6
    -2
      routers/api/v1/repo/modelarts.go
  3. +23
    -35
      routers/repo/ai_model_convert.go
  4. +1
    -1
      templates/repo/modelmanage/convertIndex.tmpl
  5. +3
    -3
      templates/repo/modelmanage/index.tmpl

+ 2
- 2
routers/api/v1/repo/cloudbrain.go View File

@@ -161,8 +161,8 @@ func GetCloudbrainModelConvertTask(ctx *context.APIContext) {
}

job.Status = modelarts.TransTrainJobStatus(result.IntStatus)
job.RunTime = result.Duration
job.TrainJobDuration = result.TrainJobDuration
job.RunTime = result.Duration / 1000
job.TrainJobDuration = models.ConvertDurationToStr(job.RunTime)
err = models.UpdateModelConvert(job)
if err != nil {
log.Error("UpdateJob failed:", err)


+ 6
- 2
routers/api/v1/repo/modelarts.go View File

@@ -6,12 +6,14 @@
package repo

import (
"code.gitea.io/gitea/modules/grampus"
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"

"code.gitea.io/gitea/modules/grampus"

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/cloudbrain"
"code.gitea.io/gitea/modules/context"
@@ -300,7 +302,9 @@ func trainJobForModelConvertGetLogContent(jobID string, baseLine string, order s
log.Error("GetTrainJobLogFileNames(%s) failed:%v", task.CloudBrainTaskId, err.Error())
return nil, nil, err
}

for i, file := range resultLogFile.LogFileList {
log.Info("i=" + fmt.Sprint(i) + " log file name=" + file)
}
result, err := modelarts.GetTrainJobLog(task.CloudBrainTaskId, task.ModelArtsVersionId, baseLine, resultLogFile.LogFileList[0], order, lines)
if err != nil {
log.Error("GetTrainJobLog(%s) failed:%v", task.CloudBrainTaskId, err.Error())


+ 23
- 35
routers/repo/ai_model_convert.go View File

@@ -168,33 +168,6 @@ func createNpuTrainJob(modelConvert *models.AiModelConvert, ctx *context.Context
h = intputshape[2]
w = intputshape[3]
}
// param := make([]models.Parameter, 0)
// modelPara := models.Parameter{
// Label: "model",
// Value: modelConvert.ModelPath,
// }
// param = append(param, modelPara)

// batchSizePara := models.Parameter{
// Label: "n",
// Value: fmt.Sprint(n),
// }
// param = append(param, batchSizePara)
// channelSizePara := models.Parameter{
// Label: "c",
// Value: fmt.Sprint(c),
// }
// param = append(param, channelSizePara)
// heightPara := models.Parameter{
// Label: "h",
// Value: fmt.Sprint(h),
// }
// param = append(param, heightPara)
// widthPara := models.Parameter{
// Label: "w",
// Value: fmt.Sprint(w),
// }
// param = append(param, widthPara)

var engineId int64
engineId = int64(NPU_MINDSPORE_IMAGE_ID)
@@ -466,16 +439,16 @@ func createGpuTrainJob(modelConvert *models.AiModelConvert, ctx *context.Context
func getGpuModelConvertCommand(name string, modelFile string, modelConvert *models.AiModelConvert, bootfile string) string {
var command string

intputshape := strings.Split(modelConvert.InputShape, ",")
inputshape := strings.Split(modelConvert.InputShape, ",")
n := "256"
c := "1"
h := "28"
w := "28"
if len(intputshape) == 4 {
n = intputshape[0]
c = intputshape[1]
h = intputshape[2]
w = intputshape[3]
if len(inputshape) == 4 {
n = inputshape[0]
c = inputshape[1]
h = inputshape[2]
w = inputshape[3]
}
command += "python3 /code/" + bootfile + " --model " + modelFile + " --n " + n + " --c " + c + " --h " + h + " --w " + w
if modelConvert.DestFormat == CONVERT_FORMAT_TRT {
@@ -585,11 +558,26 @@ func ShowModelConvertInfo(ctx *context.Context) {
}
}
} else {

result, err := modelarts.GetTrainJob(job.CloudBrainTaskId, job.ModelArtsVersionId)
if err != nil {
log.Info("error:" + err.Error())
ctx.Data["error"] = err.Error()
return
}

job.Status = modelarts.TransTrainJobStatus(result.IntStatus)
job.RunTime = result.Duration / 1000
job.TrainJobDuration = models.ConvertDurationToStr(job.RunTime)
err = models.UpdateModelConvert(job)
if err != nil {
log.Error("UpdateJob failed:", err)
}

ctx.Data["npu_display"] = "block"
ctx.Data["gpu_display"] = "none"
ctx.Data["ExitDiagnostics"] = ""
ctx.Data["AppExitDiagnostics"] = ""

}

ctx.HTML(200, tplModelConvertInfo)
@@ -690,7 +678,7 @@ func ModelConvertDownloadModel(ctx *context.Context) {
//ctx.JSON(200, url)
http.Redirect(ctx.Resp, ctx.Req.Request, url, http.StatusTemporaryRedirect)
} else {
//TODO
}
}



+ 1
- 1
templates/repo/modelmanage/convertIndex.tmpl View File

@@ -503,7 +503,7 @@
$('#SrcEngine').dropdown('clear');
console.log("setEngineValue value=" + value);
let html = ""
html +="<option name=\"Pytorch\" " + getSelected(0,value) + " value=\"0\">Pytorch</option>";
html +="<option name=\"PyTorch\" " + getSelected(0,value) + " value=\"0\">PyTorch</option>";
html +="<option name=\"TensorFlow\" " + getSelected(1,value) + " value=\"1\">TensorFlow</option>";
html +="<option name=\"MindSpore\" " + getSelected(2,value) + " value=\"2\">MindSpore</option>";
$('#SrcEngine').html(html);


+ 3
- 3
templates/repo/modelmanage/index.tmpl View File

@@ -499,9 +499,9 @@
if (modelVersion.EngineName != null && modelVersion.EngineName != "") {
srcEngine = modelVersion.EngineName.split('-')[0]
srcEngine = srcEngine.trim();
let selectedText = "Pytorch";
let selectedText = "PyTorch";
let selectedValue = 0;
let itemHtml = "<option class=\"item\" data-value=\"0\">Pytorch</option>";
let itemHtml = "<option class=\"item\" data-value=\"0\">PyTorch</option>";
if (srcEngine == 'TensorFlow') {
selectedText = "TensorFlow";
selectedValue = 1;
@@ -526,7 +526,7 @@
$("#job-Engine").append(itemHtml);
$("#choice_Engine").addClass('disabled')
} else {
let itemHtml = "<option class=\"active item\" data-value=\"0\">Pytorch</option>";
let itemHtml = "<option class=\"active item\" data-value=\"0\">PyTorch</option>";
itemHtml += "<option class=\"item\" data-value=\"1\">TensorFlow</option>"
itemHtml += "<option class=\"item\" data-value=\"2\">MindSpore</option>"
itemHtml += "<option class=\"item\" data-value=\"4\">PaddlePaddle</option>"


Loading…
Cancel
Save