|
|
@@ -20,14 +20,12 @@ import ( |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
const ( |
|
|
const ( |
|
|
Model_prefix = "aimodels/" |
|
|
|
|
|
tplModelManageIndex = "repo/modelmanage/index" |
|
|
|
|
|
tplModelManageConvertIndex = "repo/modelmanage/convertIndex" |
|
|
|
|
|
tplModelManageDownload = "repo/modelmanage/download" |
|
|
|
|
|
tplModelInfo = "repo/modelmanage/showinfo" |
|
|
|
|
|
tplModelConvertInfo = "repo/modelmanage/convertshowinfo" |
|
|
|
|
|
MODEL_LATEST = 1 |
|
|
|
|
|
MODEL_NOT_LATEST = 0 |
|
|
|
|
|
|
|
|
Model_prefix = "aimodels/" |
|
|
|
|
|
tplModelManageIndex = "repo/modelmanage/index" |
|
|
|
|
|
tplModelManageDownload = "repo/modelmanage/download" |
|
|
|
|
|
tplModelInfo = "repo/modelmanage/showinfo" |
|
|
|
|
|
MODEL_LATEST = 1 |
|
|
|
|
|
MODEL_NOT_LATEST = 0 |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, ctx *context.Context) error { |
|
|
func saveModelByParameters(jobId string, versionName string, name string, version string, label string, description string, ctx *context.Context) error { |
|
|
@@ -147,42 +145,6 @@ func SaveNewNameModel(ctx *context.Context) { |
|
|
log.Info("save model end.") |
|
|
log.Info("save model end.") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func SaveModelConvert(ctx *context.Context) { |
|
|
|
|
|
log.Info("save model convert 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.AiModelConvert{ |
|
|
|
|
|
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) |
|
|
|
|
|
ctx.JSON(200, map[string]string{ |
|
|
|
|
|
"result_code": "0", |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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") |
|
|
@@ -263,22 +225,6 @@ func downloadModelFromCloudBrainOne(modelUUID string, jobName string, parentDir |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func DeleteModelConvert(ctx *context.Context) { |
|
|
|
|
|
log.Info("delete model convert start.") |
|
|
|
|
|
id := ctx.Params(":id") |
|
|
|
|
|
err := models.DeleteModelConvertById(id) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
ctx.JSON(500, err.Error()) |
|
|
|
|
|
} else { |
|
|
|
|
|
ctx.Redirect(setting.AppSubURL + ctx.Repo.RepoLink + "/modelmanage/convert_model") |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func StopModelConvert(ctx *context.Context) { |
|
|
|
|
|
id := ctx.Params(":id") |
|
|
|
|
|
log.Info("stop model convert start.id=" + id) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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") |
|
|
@@ -573,15 +519,6 @@ 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") |
|
|
|
|
|
|
|
|
@@ -680,15 +617,6 @@ func ShowModelTemplate(ctx *context.Context) { |
|
|
ctx.HTML(200, tplModelManageIndex) |
|
|
ctx.HTML(200, tplModelManageIndex) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ConvertModelTemplate(ctx *context.Context) { |
|
|
|
|
|
ctx.Data["isModelManage"] = true |
|
|
|
|
|
ctx.Data["MODEL_COUNT"] = 0 |
|
|
|
|
|
ctx.Data["ModelManageAccess"] = ctx.Repo.CanWrite(models.UnitTypeModelManage) |
|
|
|
|
|
ctx.Data["TRAIN_COUNT"] = 0 |
|
|
|
|
|
ShowModelConvertPageInfo(ctx) |
|
|
|
|
|
ctx.HTML(200, tplModelManageConvertIndex) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func isQueryRight(ctx *context.Context) bool { |
|
|
func isQueryRight(ctx *context.Context) bool { |
|
|
if ctx.Repo.Repository.IsPrivate { |
|
|
if ctx.Repo.Repository.IsPrivate { |
|
|
if ctx.Repo.CanRead(models.UnitTypeModelManage) || ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() { |
|
|
if ctx.Repo.CanRead(models.UnitTypeModelManage) || ctx.User.IsAdmin || ctx.Repo.IsAdmin() || ctx.Repo.IsOwner() { |
|
|
@@ -723,54 +651,6 @@ func isOper(ctx *context.Context, modelUserId int64) bool { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func ShowModelConvertPageInfo(ctx *context.Context) { |
|
|
|
|
|
log.Info("ShowModelConvertInfo start.") |
|
|
|
|
|
if !isQueryRight(ctx) { |
|
|
|
|
|
log.Info("no right.") |
|
|
|
|
|
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 { |
|
|
|
|
|
log.Info("query db error." + err.Error()) |
|
|
|
|
|
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() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
pager := context.NewPagination(int(count), page, pageSize, 5) |
|
|
|
|
|
ctx.Data["Page"] = pager |
|
|
|
|
|
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) { |
|
|
|