| @@ -54,6 +54,7 @@ type AiModelManageConvert struct { | |||||
| InputShape string `xorm:"varchar(2000)"` | InputShape string `xorm:"varchar(2000)"` | ||||
| InputDataFormat string `xorm:"NOT NULL"` | InputDataFormat string `xorm:"NOT NULL"` | ||||
| Description string `xorm:"varchar(2000)"` | Description string `xorm:"varchar(2000)"` | ||||
| Path string `xorm:"varchar(400) NOT NULL"` | |||||
| CreatedUnix timeutil.TimeStamp `xorm:"created"` | CreatedUnix timeutil.TimeStamp `xorm:"created"` | ||||
| UpdatedUnix timeutil.TimeStamp `xorm:"updated"` | UpdatedUnix timeutil.TimeStamp `xorm:"updated"` | ||||
| UserName string | UserName string | ||||
| @@ -25,6 +25,7 @@ const ( | |||||
| tplModelManageConvertIndex = "repo/modelmanage/convertIndex" | tplModelManageConvertIndex = "repo/modelmanage/convertIndex" | ||||
| tplModelManageDownload = "repo/modelmanage/download" | tplModelManageDownload = "repo/modelmanage/download" | ||||
| tplModelInfo = "repo/modelmanage/showinfo" | tplModelInfo = "repo/modelmanage/showinfo" | ||||
| tplModelConvertInfo = "repo/modelmanage/convertshowinfo" | |||||
| MODEL_LATEST = 1 | MODEL_LATEST = 1 | ||||
| MODEL_NOT_LATEST = 0 | MODEL_NOT_LATEST = 0 | ||||
| ) | ) | ||||
| @@ -146,6 +147,39 @@ func SaveNewNameModel(ctx *context.Context) { | |||||
| log.Info("save model end.") | log.Info("save model end.") | ||||
| } | } | ||||
| func SaveModelConvert(ctx *context.Context) { | |||||
| log.Info("save model start.") | |||||
| if !ctx.Repo.CanWrite(models.UnitTypeModelManage) { | |||||
| ctx.JSON(403, ctx.Tr("repo.model_noright")) | |||||
| return | |||||
| } | |||||
| name := ctx.Query("name") | |||||
| desc := ctx.Query("desc") | |||||
| modelId := ctx.Query("modelId") | |||||
| SrcEngine := ctx.QueryInt("SrcEngine") | |||||
| InputShape := ctx.Query("inputshape") | |||||
| InputDataFormat := ctx.Query("inputdataformat") | |||||
| DestFormat := ctx.QueryInt("DestFormat") | |||||
| NetOutputFormat := ctx.QueryInt("NetOutputFormat") | |||||
| uuid := uuid.NewV4() | |||||
| id := uuid.String() | |||||
| modelConvert := &models.AiModelManageConvert{ | |||||
| ID: id, | |||||
| Name: name, | |||||
| Description: desc, | |||||
| SrcEngine: SrcEngine, | |||||
| RepoId: ctx.Repo.Repository.ID, | |||||
| ModelId: modelId, | |||||
| DestFormat: DestFormat, | |||||
| NetOutputFormat: NetOutputFormat, | |||||
| InputShape: InputShape, | |||||
| InputDataFormat: InputDataFormat, | |||||
| UserId: ctx.User.ID, | |||||
| } | |||||
| models.SaveModelConvert(modelConvert) | |||||
| } | |||||
| func SaveModel(ctx *context.Context) { | func SaveModel(ctx *context.Context) { | ||||
| log.Info("save model start.") | log.Info("save model start.") | ||||
| JobId := ctx.Query("JobId") | JobId := ctx.Query("JobId") | ||||
| @@ -226,6 +260,19 @@ func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir | |||||
| } | } | ||||
| } | } | ||||
| func DeleteModelConvert(ctx *context.Context) { | |||||
| log.Info("delete model convert start.") | |||||
| id := ctx.Query("ID") | |||||
| err := models.DeleteModelConvertById(id) | |||||
| if err != nil { | |||||
| ctx.JSON(500, err.Error()) | |||||
| } else { | |||||
| ctx.JSON(200, map[string]string{ | |||||
| "result_code": "0", | |||||
| }) | |||||
| } | |||||
| } | |||||
| func DeleteModel(ctx *context.Context) { | func DeleteModel(ctx *context.Context) { | ||||
| log.Info("delete model start.") | log.Info("delete model start.") | ||||
| id := ctx.Query("ID") | id := ctx.Query("ID") | ||||
| @@ -520,6 +567,15 @@ func ShowModelInfo(ctx *context.Context) { | |||||
| ctx.HTML(200, tplModelInfo) | ctx.HTML(200, tplModelInfo) | ||||
| } | } | ||||
| func ShowModelConvertInfo(ctx *context.Context) { | |||||
| ctx.Data["ID"] = ctx.Query("ID") | |||||
| ctx.Data["name"] = ctx.Query("name") | |||||
| ctx.Data["isModelManage"] = true | |||||
| ctx.Data["ModelManageAccess"] = ctx.Repo.CanWrite(models.UnitTypeModelManage) | |||||
| ctx.HTML(200, tplModelConvertInfo) | |||||
| } | |||||
| func ShowSingleModel(ctx *context.Context) { | func ShowSingleModel(ctx *context.Context) { | ||||
| name := ctx.Query("name") | name := ctx.Query("name") | ||||
| @@ -623,6 +679,7 @@ func ConvertModelTemplate(ctx *context.Context) { | |||||
| ctx.Data["MODEL_COUNT"] = 0 | ctx.Data["MODEL_COUNT"] = 0 | ||||
| ctx.Data["ModelManageAccess"] = ctx.Repo.CanWrite(models.UnitTypeModelManage) | ctx.Data["ModelManageAccess"] = ctx.Repo.CanWrite(models.UnitTypeModelManage) | ||||
| ctx.Data["TRAIN_COUNT"] = 0 | ctx.Data["TRAIN_COUNT"] = 0 | ||||
| ctx.HTML(200, tplModelManageConvertIndex) | ctx.HTML(200, tplModelManageConvertIndex) | ||||
| } | } | ||||
| @@ -660,6 +717,50 @@ func isOper(ctx *context.Context, modelUserId int64) bool { | |||||
| return false | return false | ||||
| } | } | ||||
| func ShowModelConvertPageInfo(ctx *context.Context) { | |||||
| log.Info("ShowModelConvertInfo start.") | |||||
| if !isQueryRight(ctx) { | |||||
| ctx.NotFound(ctx.Req.URL.RequestURI(), nil) | |||||
| return | |||||
| } | |||||
| page := ctx.QueryInt("page") | |||||
| if page <= 0 { | |||||
| page = 1 | |||||
| } | |||||
| pageSize := ctx.QueryInt("pageSize") | |||||
| if pageSize <= 0 { | |||||
| pageSize = setting.UI.IssuePagingNum | |||||
| } | |||||
| repoId := ctx.Repo.Repository.ID | |||||
| modelResult, count, err := models.QueryModelConvert(&models.AiModelQueryOptions{ | |||||
| ListOptions: models.ListOptions{ | |||||
| Page: page, | |||||
| PageSize: pageSize, | |||||
| }, | |||||
| RepoID: repoId, | |||||
| }) | |||||
| if err != nil { | |||||
| ctx.ServerError("Cloudbrain", err) | |||||
| return | |||||
| } | |||||
| userIds := make([]int64, len(modelResult)) | |||||
| for i, model := range modelResult { | |||||
| model.IsCanOper = isOper(ctx, model.UserId) | |||||
| model.IsCanDelete = isCanDelete(ctx, model.UserId) | |||||
| userIds[i] = model.UserId | |||||
| } | |||||
| userNameMap := queryUserName(userIds) | |||||
| for _, model := range modelResult { | |||||
| value := userNameMap[model.UserId] | |||||
| if value != nil { | |||||
| model.UserName = value.Name | |||||
| model.UserRelAvatarLink = value.RelAvatarLink() | |||||
| } | |||||
| } | |||||
| ctx.Data["Tasks"] = modelResult | |||||
| } | |||||
| func ShowModelPageInfo(ctx *context.Context) { | func ShowModelPageInfo(ctx *context.Context) { | ||||
| log.Info("ShowModelInfo start.") | log.Info("ShowModelInfo start.") | ||||
| if !isQueryRight(ctx) { | if !isQueryRight(ctx) { | ||||
| @@ -1077,12 +1077,15 @@ func RegisterRoutes(m *macaron.Macaron) { | |||||
| }, context.RepoRef()) | }, context.RepoRef()) | ||||
| m.Group("/modelmanage", func() { | m.Group("/modelmanage", func() { | ||||
| m.Post("/create_model", reqRepoModelManageWriter, repo.SaveModel) | m.Post("/create_model", reqRepoModelManageWriter, repo.SaveModel) | ||||
| m.Post("/create_model_convert", reqRepoModelManageWriter, repo.SaveModelConvert) | |||||
| m.Post("/create_new_model", repo.SaveNewNameModel) | m.Post("/create_new_model", repo.SaveNewNameModel) | ||||
| m.Delete("/delete_model", repo.DeleteModel) | m.Delete("/delete_model", repo.DeleteModel) | ||||
| m.Delete("/delete_model_convert", repo.DeleteModelConvert) | |||||
| m.Put("/modify_model", repo.ModifyModelInfo) | m.Put("/modify_model", repo.ModifyModelInfo) | ||||
| m.Get("/show_model", reqRepoModelManageReader, repo.ShowModelTemplate) | m.Get("/show_model", reqRepoModelManageReader, repo.ShowModelTemplate) | ||||
| m.Get("/convert_model", reqRepoModelManageReader, repo.ConvertModelTemplate) | m.Get("/convert_model", reqRepoModelManageReader, repo.ConvertModelTemplate) | ||||
| m.Get("/show_model_info", repo.ShowModelInfo) | m.Get("/show_model_info", repo.ShowModelInfo) | ||||
| m.Get("/show_model_convert_info", repo.ShowModelConvertInfo) | |||||
| m.Get("/show_model_info_api", repo.ShowSingleModel) | m.Get("/show_model_info_api", repo.ShowSingleModel) | ||||
| m.Get("/show_model_api", repo.ShowModelPageInfo) | m.Get("/show_model_api", repo.ShowModelPageInfo) | ||||
| m.Get("/show_model_child_api", repo.ShowOneVersionOtherModel) | m.Get("/show_model_child_api", repo.ShowOneVersionOtherModel) | ||||
| @@ -67,7 +67,7 @@ | |||||
| <div class="dataset list"> | <div class="dataset list"> | ||||
| <!-- 表头 --> | <!-- 表头 --> | ||||
| <div class="ui grid stackable" style="background: #f0f0f0;;"> | |||||
| <div class="ui grid stackable" style="background: #f0f0f0;"> | |||||
| <div class="row"> | <div class="row"> | ||||
| <div class="three wide column padding0"> | <div class="three wide column padding0"> | ||||
| <span style="margin:0 6px">{{$.i18n.Tr "repo.cloudbrain_task"}}</span> | <span style="margin:0 6px">{{$.i18n.Tr "repo.cloudbrain_task"}}</span> | ||||
| @@ -67,6 +67,32 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| {{range .Tasks}} | |||||
| <div class="ui grid stackable item"> | |||||
| <div class="row"> | |||||
| <div class="three wide column padding0"> | |||||
| <a class="title" href="{{$.Link}}/modelmanage/show_model_convert_info?id={{.ID}}" title="{{.Name}}" style="font-size: 14px;"> | |||||
| <span class="fitted" style="width: 90%;vertical-align: middle;">{{.Name}}</span> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| {{end}} | |||||
| <div id="app" style="margin-top: 2rem;"> | |||||
| <div class="center"> | |||||
| <el-pagination | |||||
| background | |||||
| @current-change="handleCurrentChange" | |||||
| :current-page="page" | |||||
| :page-sizes="[10]" | |||||
| :page-size="10" | |||||
| layout="total, sizes, prev, pager, next, jumper" | |||||
| :total="{{.Page.Paginater.Total}}"> | |||||
| </el-pagination> | |||||
| </div> | |||||
| </div> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -198,16 +224,22 @@ | |||||
| var modelData; | var modelData; | ||||
| $('#submitId').click(function(){ | $('#submitId').click(function(){ | ||||
| let name = $('#model_convert_name').val() | |||||
| let desc = $('#Description').val() | |||||
| let modelId = $('#ModelVersion').val() | |||||
| let SrcEngine = $('#SrcEngine').val(); | |||||
| let inputshape = $('#inputshape').val(); | |||||
| let inputdataformat = $('#inputdataformat').val(); | |||||
| let DestFormat = $('#DestFormat').val(); | |||||
| let NetOutputFormat = $('#NetOutputFormat').val(); | |||||
| console.log("name=" + name + " desc=" + desc + " modelId=" + modelId + " SrcEngine=" + SrcEngine); | |||||
| console.log("inputshape=" + inputshape + " inputdataformat=" + inputdataformat + " DestFormat=" + DestFormat + " NetOutputFormat=" + NetOutputFormat); | |||||
| let data={}; | |||||
| data['name']= $('#model_convert_name').val() | |||||
| data['desc']= $('#Description').val() | |||||
| data['modelId'] = $('#ModelVersion').val() | |||||
| data['SrcEngine'] = $('#SrcEngine').val(); | |||||
| data['inputshape']= $('#inputshape').val(); | |||||
| data['inputdataformat']= $('#inputdataformat').val(); | |||||
| data['DestFormat'] = $('#DestFormat').val(); | |||||
| data['NetOutputFormat']= $('#NetOutputFormat').val(); | |||||
| console.log("name=" + data['name'] + " desc=" + data['desc'] + " modelId=" + data['modelId'] + " SrcEngine=" + data['SrcEngine']); | |||||
| console.log("inputshape=" + data['inputshape'] + " inputdataformat=" + data['inputdataformat'] + " DestFormat=" + data['DestFormat'] + " NetOutputFormat=" + data['NetOutputFormat']); | |||||
| $('.ui.modal.second').modal('hide'); | |||||
| $.post(`${repolink}/modelmanage/create_model_convert?repoId=${repoId}`,data,(result) => { | |||||
| console.log("result=" + result); | |||||
| }) | |||||
| }) | }) | ||||
| function createModelName(){ | function createModelName(){ | ||||