From 083155413de9eb21f21ed3b5d69340b5d0f1a255 Mon Sep 17 00:00:00 2001 From: RockYang Date: Fri, 6 Oct 2023 22:25:37 +0800 Subject: [PATCH] feat: stable diffusion page function is ready --- api/service/sd/service.go | 6 +- api/service/sd/types.go | 287 +++++++++------------------- web/src/assets/css/image-sd.styl | 132 +++++++++---- web/src/views/ImageSd.vue | 318 +++++++++++++++++++------------ 4 files changed, 391 insertions(+), 352 deletions(-) diff --git a/api/service/sd/service.go b/api/service/sd/service.go index 7fc9943..a95b9cc 100644 --- a/api/service/sd/service.go +++ b/api/service/sd/service.go @@ -114,7 +114,7 @@ func (s *Service) Txt2Img(task types.SdTask) error { TaskId: params.TaskId, Data: data, EventData: nil, - FnIndex: 405, + FnIndex: 232, SessionHash: "ycaxgzm9ah", }, s.httpClient) }() @@ -233,6 +233,8 @@ func (s *Service) runTask(taskInfo TaskInfo, client *req.Client) { } func (s *Service) callback(data CBReq) { + // 释放任务锁 + s.redis.Del(context.Background(), RunningJobKey) client := s.Clients.Get(data.SessionId) if data.Success { // 任务成功 var job model.SdJob @@ -262,6 +264,7 @@ func (s *Service) callback(data CBReq) { job.ImgURL = imageURL } + job.Params = utils.JsonEncode(params) res = s.db.Updates(&job) if res.Error != nil { logger.Error("error with update job: ", res.Error) @@ -276,7 +279,6 @@ func (s *Service) callback(data CBReq) { } if data.Progress < 100 { - logger.Infof(data.ImageData) jobVo.ImgURL = data.ImageData } diff --git a/api/service/sd/types.go b/api/service/sd/types.go index 8a052b1..ec6a33a 100644 --- a/api/service/sd/types.go +++ b/api/service/sd/types.go @@ -45,200 +45,95 @@ var ParamKeys = map[string]int{ } const Text2ImgParamTemplate = `[ -"task(p1lk3n41saygmr8)", -"a tiger sit on the window", -"", -[], -20, -"Euler a", -false, -false, -1, -1, -7, --1, --1, -0, -0, -0, -false, -128, -128, -false, -0.7, -2, -"Latent", -0, -0, -0, -[], -"None", -false, -"MultiDiffusion", -false, -10, -1, -1, -64, -false, -true, -1024, -1024, -96, -96, -48, -1, -"None", -2, -false, -false, -false, -false, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -0.4, -0.4, -0.2, -0.2, -"", -"", -"Background", -0.2, --1, -false, -false, -true, -true, -false, -1536, -96, -false, -false, -"LoRA", -"None", -1, -1, -"LoRA", -"None", -1, -1, -"LoRA", -"None", -1, -1, -"LoRA", -"None", -1, -1, -"LoRA", -"None", -1, -1, -null, -"Refresh models", -null, -null, -null, -null, -false, -false, -"positive", -"comma", -0, -false, -false, -"", -"Seed", -"", -"Nothing", -"", -"Nothing", -"", -true, -false, -false, -false, -0, -null, -false, -null, -false, -null, -false, -null, -false, -50, -[], -"", -"", -"" + "task(6sm0b3j17tag2gd)", + "A beautiful Chinese girl wearing a cheongsam walks on the bluestone street", + "", + [], + 50, + "Euler a", + false, + false, + 1, + 1, + 15, + null, + -1, + 0, + 0, + 0, + false, + 768, + 512, + false, + 0.7, + 2, + "ESRGAN_4x", + 10, + 0, + 0, + "Use same sampler", + "", + "", + [], + "None", + null, + false, + false, + "positive", + "comma", + 0, + false, + false, + "", + "Seed", + "", + [], + "Nothing", + "", + [], + "Nothing", + "", + [], + true, + false, + false, + false, + 0, + "Not set", + true, + true, + "", + "", + "", + "", + "", + 1.3, + "Not set", + "Not set", + 1.3, + "Not set", + 1.3, + "Not set", + 1.3, + 1.3, + "Not set", + 1.3, + "Not set", + 1.3, + "Not set", + 1.3, + "Not set", + 1.3, + "Not set", + 1.3, + "Not set", + false, + "None", + null, + false, + 50, + [], + "", + "", + "" ]` diff --git a/web/src/assets/css/image-sd.styl b/web/src/assets/css/image-sd.styl index 7c740d0..6f5c961 100644 --- a/web/src/assets/css/image-sd.styl +++ b/web/src/assets/css/image-sd.styl @@ -87,31 +87,6 @@ } } - /* 修改滚动条的颜色 */ - - ::-webkit-scrollbar { - width: 10px; /* 滚动条宽度 */ - } - - /* 修改滚动条轨道的背景颜色 */ - - ::-webkit-scrollbar-track { - background-color: #282C34; - } - - /* 修改滚动条的滑块颜色 */ - - ::-webkit-scrollbar-thumb { - background-color: #444444; - border-radius 10px - } - - /* 修改滚动条的滑块的悬停颜色 */ - - ::-webkit-scrollbar-thumb:hover { - background-color: #666666; - } - .task-list-box { width 100% padding 10px @@ -243,13 +218,106 @@ } } + .el-overlay-dialog { + .el-dialog { + background-color #1a1b1e + + .el-dialog__header { + .el-dialog__title { + color #F5F5F5 + } + } + + .el-dialog__body { + padding 0 0 0 15px !important + display flex + height 100% + + .img-container { + display flex + justify-content center + width 100% + } + + .task-info { + max-width 320px + min-width 320px + background-color #25262b + padding 10px 15px + + .info-line { + width 100% + + .prompt { + background-color #35363b + padding 10px + color #999999 + overflow auto + max-height 100px + min-height 50px + } + + .wrapper { + margin-top 10px + display flex + + label { + display flex + width 100px + color #a5a5a5 + } + + .item-value { + display flex + width 100% + background-color #35363b + padding 2px 5px + border-radius 5px + color #F5F5F5 + } + } + + } + } + } + } + } + + .mj-list-item-prompt { + .el-icon { + margin-left 10px + cursor pointer + position relative + top 2px + } + } + } -.mj-list-item-prompt { - .el-icon { - margin-left 10px - cursor pointer - position relative - top 2px +.custom-scroll { + /* 修改滚动条的颜色 */ + + ::-webkit-scrollbar { + width: 10px; /* 滚动条宽度 */ } -} \ No newline at end of file + + /* 修改滚动条轨道的背景颜色 */ + + ::-webkit-scrollbar-track { + background-color: #282C34; + } + + /* 修改滚动条的滑块颜色 */ + + ::-webkit-scrollbar-thumb { + background-color: #444444; + border-radius 10px + } + + /* 修改滚动条的滑块的悬停颜色 */ + + ::-webkit-scrollbar-thumb:hover { + background-color: #666666; + } +} + diff --git a/web/src/views/ImageSd.vue b/web/src/views/ImageSd.vue index e571793..c1d9525 100644 --- a/web/src/views/ImageSd.vue +++ b/web/src/views/ImageSd.vue @@ -1,42 +1,17 @@