feat(swapHair): webui_steps参数可外部传入(接口2调试页可调)
- gen_super_image.py: webui_img2img + build_body_v2 接收可选 steps 参数 - run_copy_cost_colorb64.py: swapHair 接口接收 webui_steps,透传给 webui_img2img - 未传时保持环境变量 WEBUI_STEPS 默认(15),向后兼容
This commit is contained in:
@@ -84,13 +84,13 @@ class ControlnetRequestImg2Img:
|
||||
return encoded_image
|
||||
|
||||
|
||||
def build_body_v2(self, dst_width, dst_height, cfg_scale, base_img, denoising_strength=0.7):
|
||||
def build_body_v2(self, dst_width, dst_height, cfg_scale, base_img, denoising_strength=0.7, steps=None):
|
||||
self.body = {
|
||||
"prompt": self.prompt,
|
||||
"negative_prompt": self.neg_prompt,
|
||||
"sampler_name": "DPM++ 2M Karras",
|
||||
"batch_size": 1,
|
||||
"steps": int(os.environ.get("WEBUI_STEPS", "15")),
|
||||
"steps": int(steps) if steps is not None else int(os.environ.get("WEBUI_STEPS", "15")),
|
||||
"width": dst_width,
|
||||
"height": dst_height,
|
||||
"cfg_scale": cfg_scale,
|
||||
@@ -414,7 +414,7 @@ def encode_numpy_to_base64(img):
|
||||
encoded_image = base64.b64encode(bytes).decode('utf-8')
|
||||
return encoded_image
|
||||
|
||||
def webui_img2img(img=None, mask_img=None, in_gender=None, task_id=None, hair_id=None, lora_material_path=None, tag="", is_hr=False, denoising_strength=0.7, inference_port="57860", refiner_switch_at=0.5):
|
||||
def webui_img2img(img=None, mask_img=None, in_gender=None, task_id=None, hair_id=None, lora_material_path=None, tag="", is_hr=False, denoising_strength=0.7, inference_port="57860", refiner_switch_at=0.5, webui_steps=None):
|
||||
# url = "http://hairservice.tslead.net:57860/sdapi/v1/img2img"
|
||||
|
||||
neg_prompt = '(nsfw:1.5), ng_deepnegative_v1_75t, (badhandv4:1.2), (worst quality:2), (low quality:2), (normal quality:2), lowres, bad anatomy, bad hands, ((monochrome)), ((grayscale)) watermark, moles, large breast, big breast, bad_pictures,easynegative'
|
||||
@@ -430,7 +430,7 @@ def webui_img2img(img=None, mask_img=None, in_gender=None, task_id=None, hair_id
|
||||
control_net = ControlnetRequestImg2Img(prompt, neg_prompt, mask_img)
|
||||
# control_net.build_body_hr(dst_width=img.shape[1], dst_height=img.shape[0], cfg_scale=7, base_img=encoded_image, denoising_strength=denoising_strength)
|
||||
if not is_hr:
|
||||
control_net.build_body_v2(dst_width=img.shape[1], dst_height=img.shape[0], cfg_scale=7, base_img=encoded_image, denoising_strength=denoising_strength)
|
||||
control_net.build_body_v2(dst_width=img.shape[1], dst_height=img.shape[0], cfg_scale=7, base_img=encoded_image, denoising_strength=denoising_strength, steps=webui_steps)
|
||||
else:
|
||||
control_net.build_body_hr(dst_width=img.shape[1], dst_height=img.shape[0], cfg_scale=7, base_img=encoded_image, denoising_strength=denoising_strength, refiner_switch_at=refiner_switch_at)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user