精简表单
This commit is contained in:
		@@ -85,7 +85,20 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// 执行生成任务
 | 
							// 执行生成任务
 | 
				
			||||||
		if model.Image == "" {
 | 
							if model.Image == "" {
 | 
				
			||||||
 | 
								img := image_list[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 发送的参数
 | 
								// 发送的参数
 | 
				
			||||||
 | 
								var datx map[string]interface{} = make(map[string]interface{})
 | 
				
			||||||
 | 
								datx["prompt"] = img.Prompt      // 提示词
 | 
				
			||||||
 | 
								datx["seed"] = img.Seed          // 随机数种子
 | 
				
			||||||
 | 
								datx["n_iter"] = len(image_list) // 生成图像数量
 | 
				
			||||||
 | 
								datx["steps"] = 50               // 迭代步数
 | 
				
			||||||
 | 
								datx["cfg_scale"] = img.CfgScale // 提示词引导系数 (CFG Scale)
 | 
				
			||||||
 | 
								if img.SamplerName == "" {
 | 
				
			||||||
 | 
									datx["sampler_name"] = img.SamplerName // 采样器名称
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								fmt.Println("image_list:", datx)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var data = struct {
 | 
								var data = struct {
 | 
				
			||||||
				//EnableHr                          bool              `json:"enable_hr"`
 | 
									//EnableHr                          bool              `json:"enable_hr"`
 | 
				
			||||||
				//DenoisingStrength                 int               `json:"denoising_strength"`
 | 
									//DenoisingStrength                 int               `json:"denoising_strength"`
 | 
				
			||||||
@@ -179,12 +192,14 @@ func (model *Model) Inference(image_list []Image, callback func(Image)) {
 | 
				
			|||||||
				//SaveImages:                        false,
 | 
									//SaveImages:                        false,
 | 
				
			||||||
				//AlwaysonScripts:                   map[string]string{},
 | 
									//AlwaysonScripts:                   map[string]string{},
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								fmt.Println("data:", data)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// 接收到的图片列表
 | 
								// 接收到的图片列表
 | 
				
			||||||
			var rest = struct {
 | 
								var rest = struct {
 | 
				
			||||||
				Images []string `json:"images"`
 | 
									Images []string `json:"images"`
 | 
				
			||||||
			}{}
 | 
								}{}
 | 
				
			||||||
			var url = fmt.Sprintf("http://%s:%d/sdapi/v1/txt2img", server.IP, server.Port)
 | 
								var url = fmt.Sprintf("http://%s:%d/sdapi/v1/txt2img", server.IP, server.Port)
 | 
				
			||||||
			if err := goreq.Post(url).SetJsonBody(data).Do().BindJSON(&rest); err != nil {
 | 
								if err := goreq.Post(url).SetJsonBody(datx).Do().BindJSON(&rest); err != nil {
 | 
				
			||||||
				log.Println("API 查询失败:", err)
 | 
									log.Println("API 查询失败:", err)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			for index, img := range rest.Images {
 | 
								for index, img := range rest.Images {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,9 +137,6 @@ func ImagesPost(w http.ResponseWriter, r *http.Request) {
 | 
				
			|||||||
			if template.CfgScale > 20 {
 | 
								if template.CfgScale > 20 {
 | 
				
			||||||
				template.CfgScale = 20
 | 
									template.CfgScale = 20
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if template.SamplerName == "" {
 | 
					 | 
				
			||||||
				template.SamplerName = "DDIM"
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			if template.ModelID <= 0 {
 | 
								if template.ModelID <= 0 {
 | 
				
			||||||
				w.WriteHeader(http.StatusBadRequest)
 | 
									w.WriteHeader(http.StatusBadRequest)
 | 
				
			||||||
				w.Write([]byte("model_id 参数不能为空"))
 | 
									w.Write([]byte("model_id 参数不能为空"))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user