支持宽高与负面提示词

This commit is contained in:
2023-07-12 15:34:36 +08:00
parent 050637dcd8
commit f090ccd4d4
2 changed files with 14 additions and 0 deletions

View File

@@ -154,9 +154,18 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
datx["n_iter"] = len(image_list) // 生成图像数量 datx["n_iter"] = len(image_list) // 生成图像数量
datx["steps"] = img.Steps // 迭代步数 datx["steps"] = img.Steps // 迭代步数
datx["cfg_scale"] = img.CfgScale // 提示词引导系数 (CFG Scale) datx["cfg_scale"] = img.CfgScale // 提示词引导系数 (CFG Scale)
if img.Width > 0 {
datx["width"] = img.Width // 图片宽度
}
if img.Height > 0 {
datx["height"] = img.Height // 图片高度
}
if img.SamplerName == "" { if img.SamplerName == "" {
datx["sampler_name"] = img.SamplerName // 采样器名称 datx["sampler_name"] = img.SamplerName // 采样器名称
} }
if img.NegativePrompt != "" {
datx["negative_prompt"] = img.NegativePrompt // 负面提示词
}
fmt.Println("image_list:", datx) fmt.Println("image_list:", datx)
// 接收到的图片列表 // 接收到的图片列表

View File

@@ -142,6 +142,8 @@ func ImagesPost(w http.ResponseWriter, r *http.Request) {
Seed int `json:"seed"` // 随机种子(单张图生成时使用) Seed int `json:"seed"` // 随机种子(单张图生成时使用)
NIter int `json:"n_iter"` // 生成数量 NIter int `json:"n_iter"` // 生成数量
ModelID int `json:"model_id"` // 模型ID ModelID int `json:"model_id"` // 模型ID
Width int `json:"width"` // 图片宽度
Height int `json:"height"` // 图片高度
}{} }{}
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
@@ -196,6 +198,9 @@ func ImagesPost(w http.ResponseWriter, r *http.Request) {
image.CfgScale = template.CfgScale image.CfgScale = template.CfgScale
image.SamplerName = template.SamplerName image.SamplerName = template.SamplerName
image.Seed = template.Seed image.Seed = template.Seed
image.ModelID = template.ModelID
image.Width = template.Width
image.Height = template.Height
image_list = append(image_list, image) image_list = append(image_list, image)
} }