fix: parser && docker bug
parent
8febfaa79b
commit
415ed64a5d
|
|
@ -5,7 +5,7 @@ import io
|
|||
import base64
|
||||
from gradio.processing_utils import encode_pil_to_base64
|
||||
|
||||
def get_param_value(params_dict, key, defaultValue="false"):
|
||||
def get_param_value(params_dict, key, defaultValue=False):
|
||||
try:
|
||||
param_value = params_dict[key]
|
||||
except Exception as e:
|
||||
|
|
@ -188,8 +188,8 @@ def json_convert_to_payload(params_dict, checkpoint_info, task_type):
|
|||
if lora_name not in prompt:
|
||||
prompt = prompt + f"<lora:{lora_name}:1>"
|
||||
|
||||
contronet_enable = get_param_value(params_dict, f'{param_name}_controlnet_enable')
|
||||
if contronet_enable:
|
||||
controlnet_enable = get_param_value(params_dict, f'{param_name}_controlnet_enable')
|
||||
if controlnet_enable:
|
||||
controlnet_module = get_param_value(params_dict, f'{param_name}_controlnet_preprocessor', defaultValue=None)
|
||||
if len(selected_cn_model) < 1:
|
||||
controlnet_model = "None"
|
||||
|
|
@ -398,7 +398,7 @@ def json_convert_to_payload(params_dict, checkpoint_info, task_type):
|
|||
payload[payload_name]["include_init_images"] = include_init_images
|
||||
|
||||
|
||||
if contronet_enable:
|
||||
if controlnet_enable:
|
||||
print(f'{task_type} with controlnet!!!!!!!!!!')
|
||||
payload[payload_name]["alwayson_scripts"] = {}
|
||||
payload[payload_name]["alwayson_scripts"]["controlnet"] = {}
|
||||
|
|
|
|||
|
|
@ -26,26 +26,27 @@ payload = json_convert_to_payload(params_dict, payload_checkpoint_info, task_typ
|
|||
|
||||
print(payload.keys())
|
||||
|
||||
# # call local api
|
||||
# url = "http://127.0.0.1:8082"
|
||||
# call local api
|
||||
url = "http://127.0.0.1:8082"
|
||||
|
||||
# response = requests.post(url=f'{url}/sdapi/v1/img2img', json=payload['img2img_payload'])
|
||||
response = requests.post(url=f'{url}/invocations', json=payload)
|
||||
|
||||
# print(f"run time is {time.time()-start_time}")
|
||||
print(f"run time is {time.time()-start_time}")
|
||||
|
||||
# print(f"response is {response}")
|
||||
print(f"response is {response}")
|
||||
|
||||
# r = response.json()
|
||||
# id = 0
|
||||
# for i in r['images']:
|
||||
# image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
|
||||
r = response.json()
|
||||
|
||||
# png_payload = {
|
||||
# "image": "data:image/png;base64," + i
|
||||
# }
|
||||
# response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
||||
id = 0
|
||||
for i in r['images']:
|
||||
image = Image.open(io.BytesIO(base64.b64decode(i.split(",",1)[0])))
|
||||
|
||||
# pnginfo = PngImagePlugin.PngInfo()
|
||||
# pnginfo.add_text("parameters", response2.json().get("info"))
|
||||
# image.save('output_%d.png'%id, pnginfo=pnginfo)
|
||||
# id += 1
|
||||
png_payload = {
|
||||
"image": "data:image/png;base64," + i
|
||||
}
|
||||
response2 = requests.post(url=f'{url}/sdapi/v1/png-info', json=png_payload)
|
||||
|
||||
pnginfo = PngImagePlugin.PngInfo()
|
||||
pnginfo.add_text("parameters", response2.json().get("info"))
|
||||
image.save('output_%d.png'%id, pnginfo=pnginfo)
|
||||
id += 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue