import webuiapi
from IPython.display import clear_output
import os
import time
from pathlib import Path
from psd_tools import PSDImage
from PIL import Image
# create API client
api = webuiapi.WebUIApi(sampler='Euler a', steps=20)
file_base = "base.psd"
file_prompt = "prompt.txt"
f_base_new = 0
f_prompt_new = 0
while True:
f_base = os.path.getmtime(file_base)
f_prompt = os.path.getmtime(file_prompt)
if f_base == f_base_new and f_prompt==f_prompt_new:
time.sleep(0.5)
else:
f_base_new = f_base
f_prompt_new = f_prompt
prompt_txt = Path(file_prompt).read_text()
psd = PSDImage.open(file_base)
im = psd.composite()
result2 = api.img2img(
images=[im],
prompt=prompt_txt,
negative_prompt = "poorly drawn, photorealistic, watermark, logo, text, bad anatomy, missing fingers,missing body part,mangled hands",
steps=40,
styles=[],
seed=515553,
cfg_scale=7,
width=512,
height=724,
denoising_strength=0.55)
clear_output(wait=False)
display(result2.image)