|
|
@ -129,7 +129,7 @@ def runComfyUI(model_id, json_data, input_image, target_folder):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 4、风格转绘
|
|
|
|
# 4、风格转绘
|
|
|
|
def webui_convert(model_id, json_data, input_image, target_folder):
|
|
|
|
def webui_convert(model_id, prompt_id, json_data, input_image, target_folder):
|
|
|
|
# 1、需要反推提示词
|
|
|
|
# 1、需要反推提示词
|
|
|
|
prompt = get_wd_14(wd_url, input_image[0])
|
|
|
|
prompt = get_wd_14(wd_url, input_image[0])
|
|
|
|
|
|
|
|
|
|
|
@ -140,18 +140,21 @@ def webui_convert(model_id, json_data, input_image, target_folder):
|
|
|
|
img.close()
|
|
|
|
img.close()
|
|
|
|
|
|
|
|
|
|
|
|
# 填充反推的提示词,以原图片的宽高为参数
|
|
|
|
# 填充反推的提示词,以原图片的宽高为参数
|
|
|
|
json_data['prompt'] = prompt+json_data['prompt']
|
|
|
|
json_data['prompt'] = prompt + json_data['prompt']
|
|
|
|
json_data['width'] = width
|
|
|
|
json_data['width'] = width
|
|
|
|
json_data['height'] = height
|
|
|
|
json_data['height'] = height
|
|
|
|
|
|
|
|
|
|
|
|
# 图片
|
|
|
|
# 图片
|
|
|
|
args = json_data['alwayson_scripts']['ControlNet']['args']
|
|
|
|
json_data['init_images'] = [encode_image(input_image[0])]
|
|
|
|
args[0]['input_image'] = encode_image(input_image[0])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 开始生成图片
|
|
|
|
# 开始生成图片
|
|
|
|
printf("开始生成图片...")
|
|
|
|
printf("开始生成图片...")
|
|
|
|
# 调用图生图服务
|
|
|
|
# 调用图生图服务
|
|
|
|
response = submit_post(img2img_url, json_data)
|
|
|
|
response = submit_post(img2img_url, json_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if response.status_code == 500:
|
|
|
|
|
|
|
|
print(response.text)
|
|
|
|
|
|
|
|
exit(0)
|
|
|
|
# 创建文件的完整路径
|
|
|
|
# 创建文件的完整路径
|
|
|
|
file_path = os.path.join(target_folder, str(uuid.uuid4()) + '.png')
|
|
|
|
file_path = os.path.join(target_folder, str(uuid.uuid4()) + '.png')
|
|
|
|
save_encoded_image(response.json()['images'][0], file_path)
|
|
|
|
save_encoded_image(response.json()['images'][0], file_path)
|
|
|
|