You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.1 KiB
34 lines
1.1 KiB
from Util import ConfigUtil
|
|
from Util.CommonUtil import *
|
|
|
|
if __name__ == '__main__':
|
|
# 配置文件
|
|
config = ConfigUtil.getConfig()
|
|
# 图生图服务地址
|
|
img2img_url = config['webui']['img2img_url']
|
|
|
|
# 用户传的源图
|
|
source_img = "../Image/1ae93e2587822c291362abf9504cb49ec.jpeg"
|
|
|
|
# 参照图片路径
|
|
refer_img = "../Image/28/1.jpg"
|
|
|
|
# 生成的JSON文件
|
|
with open("../JSON/28_1.json", 'r', encoding='utf-8') as f:
|
|
v_data = json.load(f)
|
|
|
|
# 源图
|
|
source_image = encode_image(source_img)
|
|
refer_image = encode_image(refer_img)
|
|
# https://blog.csdn.net/wangwenzhe222/article/details/139059131
|
|
# ControlNet
|
|
#v_data['alwayson_scripts']['ControlNet']['args'][0]['image'] = source_image
|
|
#v_data['alwayson_scripts']['ControlNet']['args'][1]['image'] = refer_image
|
|
v_data['init_images'] = [refer_image]
|
|
|
|
#print(json.dumps(v_data, sort_keys=True, ensure_ascii=False,indent=4)) # 生成可以正确显示中文的json格式输出
|
|
|
|
response = submit_post(img2img_url, v_data)
|
|
save_encoded_image(response.json()['images'][0], "../Out/result.png")
|
|
|