diff --git a/models/Model.go b/models/Model.go index b063171..b429654 100644 --- a/models/Model.go +++ b/models/Model.go @@ -154,12 +154,8 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) { datx["n_iter"] = len(image_list) // 生成图像数量 datx["steps"] = img.Steps // 迭代步数 datx["cfg_scale"] = img.CfgScale // 提示词引导系数 (CFG Scale) - if img.Width > 0 { - datx["width"] = img.Width // 图片宽度 - } - if img.Height > 0 { - datx["height"] = img.Height // 图片高度 - } + datx["width"] = img.Width // 图片宽度 + datx["height"] = img.Height // 图片高度 if img.SamplerName == "" { datx["sampler_name"] = img.SamplerName // 采样器名称 } @@ -186,8 +182,6 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) { image_list[index].Path = "data/images/" + filename + ".webp" image_list[index].Hash = filename image_list[index].Type = "image/webp" - image_list[index].Width = 512 - image_list[index].Height = 512 image_list[index].Format = "webp" image_list[index].Status = "success" image_list[index].Progress = 100 diff --git a/routers/images.go b/routers/images.go index 108516b..21bb4de 100644 --- a/routers/images.go +++ b/routers/images.go @@ -169,6 +169,12 @@ func ImagesPost(w http.ResponseWriter, r *http.Request) { if template.CfgScale > 20 { template.CfgScale = 20 } + if template.Width <= 0 { + template.Width = 512 + } + if template.Height <= 0 { + template.Height = 512 + } if template.ModelID <= 0 { w.WriteHeader(http.StatusBadRequest) w.Write([]byte("model_id 参数不能为空"))