parent
660aca308e
commit
f581d8e8dd
|
|
@ -129,3 +129,4 @@ dmypy.json
|
||||||
.pyre/
|
.pyre/
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/.vs
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ def do_upscaleImg(curImg, upscale_do, upscaler_name, upscale_by):
|
||||||
return pp.image
|
return pp.image
|
||||||
|
|
||||||
|
|
||||||
def renderTxt2Img(prompt, negative_prompt, sampler, steps, cfg_scale, width, height):
|
def renderTxt2Img(prompt, negative_prompt, sampler, steps, cfg_scale, seed, width, height):
|
||||||
processed = None
|
processed = None
|
||||||
p = StableDiffusionProcessingTxt2Img(
|
p = StableDiffusionProcessingTxt2Img(
|
||||||
sd_model=shared.sd_model,
|
sd_model=shared.sd_model,
|
||||||
|
|
@ -121,7 +121,7 @@ def renderTxt2Img(prompt, negative_prompt, sampler, steps, cfg_scale, width, hei
|
||||||
outpath_grids=shared.opts.outdir_txt2img_grids,
|
outpath_grids=shared.opts.outdir_txt2img_grids,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
negative_prompt=negative_prompt,
|
negative_prompt=negative_prompt,
|
||||||
# seed=-1,
|
seed=seed,
|
||||||
sampler_name=sampler,
|
sampler_name=sampler,
|
||||||
n_iter=1,
|
n_iter=1,
|
||||||
steps=steps,
|
steps=steps,
|
||||||
|
|
@ -130,7 +130,8 @@ def renderTxt2Img(prompt, negative_prompt, sampler, steps, cfg_scale, width, hei
|
||||||
height=height,
|
height=height,
|
||||||
)
|
)
|
||||||
processed = process_images(p)
|
processed = process_images(p)
|
||||||
return processed
|
newseed = p.seed
|
||||||
|
return processed, newseed
|
||||||
|
|
||||||
|
|
||||||
def renderImg2Img(
|
def renderImg2Img(
|
||||||
|
|
@ -139,6 +140,7 @@ def renderImg2Img(
|
||||||
sampler,
|
sampler,
|
||||||
steps,
|
steps,
|
||||||
cfg_scale,
|
cfg_scale,
|
||||||
|
seed,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
init_image,
|
init_image,
|
||||||
|
|
@ -157,7 +159,7 @@ def renderImg2Img(
|
||||||
outpath_grids=shared.opts.outdir_img2img_grids,
|
outpath_grids=shared.opts.outdir_img2img_grids,
|
||||||
prompt=prompt,
|
prompt=prompt,
|
||||||
negative_prompt=negative_prompt,
|
negative_prompt=negative_prompt,
|
||||||
# seed=-1,
|
seed=seed,
|
||||||
sampler_name=sampler,
|
sampler_name=sampler,
|
||||||
n_iter=1,
|
n_iter=1,
|
||||||
steps=steps,
|
steps=steps,
|
||||||
|
|
@ -175,7 +177,8 @@ def renderImg2Img(
|
||||||
# p.latent_mask = Image.new("RGB", (p.width, p.height), "white")
|
# p.latent_mask = Image.new("RGB", (p.width, p.height), "white")
|
||||||
|
|
||||||
processed = process_images(p)
|
processed = process_images(p)
|
||||||
return processed
|
newseed = p.seed
|
||||||
|
return processed, newseed
|
||||||
|
|
||||||
|
|
||||||
def fix_env_Path_ffprobe():
|
def fix_env_Path_ffprobe():
|
||||||
|
|
@ -227,6 +230,7 @@ def create_zoom(
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
zoom_speed,
|
zoom_speed,
|
||||||
|
seed,
|
||||||
outputsizeW,
|
outputsizeW,
|
||||||
outputsizeH,
|
outputsizeH,
|
||||||
batchcount,
|
batchcount,
|
||||||
|
|
@ -257,6 +261,7 @@ def create_zoom(
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
zoom_speed,
|
zoom_speed,
|
||||||
|
seed,
|
||||||
outputsizeW,
|
outputsizeW,
|
||||||
outputsizeH,
|
outputsizeH,
|
||||||
sampler,
|
sampler,
|
||||||
|
|
@ -286,6 +291,7 @@ def create_zoom_single(
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
zoom_speed,
|
zoom_speed,
|
||||||
|
seed,
|
||||||
outputsizeW,
|
outputsizeW,
|
||||||
outputsizeH,
|
outputsizeH,
|
||||||
sampler,
|
sampler,
|
||||||
|
|
@ -319,24 +325,28 @@ def create_zoom_single(
|
||||||
mask_image = np.array(current_image)[:, :, 3]
|
mask_image = np.array(current_image)[:, :, 3]
|
||||||
mask_image = Image.fromarray(255 - mask_image).convert("RGB")
|
mask_image = Image.fromarray(255 - mask_image).convert("RGB")
|
||||||
current_image = current_image.convert("RGB")
|
current_image = current_image.convert("RGB")
|
||||||
|
current_seed = seed
|
||||||
|
|
||||||
if custom_init_image:
|
if custom_init_image:
|
||||||
current_image = custom_init_image.resize(
|
current_image = custom_init_image.resize(
|
||||||
(width, height), resample=Image.LANCZOS
|
(width, height), resample=Image.LANCZOS
|
||||||
)
|
)
|
||||||
|
print("using Custom Initial Image")
|
||||||
else:
|
else:
|
||||||
load_model_from_setting("infzoom_txt2img_model", progress, "Loading Model for txt2img: ")
|
load_model_from_setting("infzoom_txt2img_model", progress, "Loading Model for txt2img: ")
|
||||||
|
|
||||||
processed = renderTxt2Img(
|
processed, newseed = renderTxt2Img(
|
||||||
prompts[min(k for k in prompts.keys() if k >= 0)],
|
prompts[min(k for k in prompts.keys() if k >= 0)],
|
||||||
negative_prompt,
|
negative_prompt,
|
||||||
sampler,
|
sampler,
|
||||||
num_inference_steps,
|
num_inference_steps,
|
||||||
guidance_scale,
|
guidance_scale,
|
||||||
|
current_seed,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
)
|
)
|
||||||
current_image = processed.images[0]
|
current_image = processed.images[0]
|
||||||
|
current_seed = newseed
|
||||||
|
|
||||||
mask_width = math.trunc(width / 4) # was initially 512px => 128px
|
mask_width = math.trunc(width / 4) # was initially 512px => 128px
|
||||||
mask_height = math.trunc(height / 4) # was initially 512px => 128px
|
mask_height = math.trunc(height / 4) # was initially 512px => 128px
|
||||||
|
|
@ -357,7 +367,7 @@ def create_zoom_single(
|
||||||
load_model_from_setting("infzoom_inpainting_model", progress, "Loading Model for inpainting/img2img: " )
|
load_model_from_setting("infzoom_inpainting_model", progress, "Loading Model for inpainting/img2img: " )
|
||||||
|
|
||||||
for i in range(num_outpainting_steps):
|
for i in range(num_outpainting_steps):
|
||||||
print_out = "Outpaint step: " + str(i + 1) + " / " + str(num_outpainting_steps)
|
print_out = "Outpaint step: " + str(i + 1) + " / " + str(num_outpainting_steps) + " Seed: " + str(current_seed)
|
||||||
print(print_out)
|
print(print_out)
|
||||||
if progress:
|
if progress:
|
||||||
progress(((i + 1) / num_outpainting_steps), desc=print_out)
|
progress(((i + 1) / num_outpainting_steps), desc=print_out)
|
||||||
|
|
@ -373,12 +383,19 @@ def create_zoom_single(
|
||||||
# inpainting step
|
# inpainting step
|
||||||
current_image = current_image.convert("RGB")
|
current_image = current_image.convert("RGB")
|
||||||
|
|
||||||
processed = renderImg2Img(
|
if custom_exit_image and ((i + 1) == num_outpainting_steps):
|
||||||
|
current_image = custom_exit_image.resize(
|
||||||
|
(width, height), resample=Image.LANCZOS
|
||||||
|
)
|
||||||
|
print("using Custom Exit Image")
|
||||||
|
else:
|
||||||
|
processed, newseed = renderImg2Img(
|
||||||
prompts[max(k for k in prompts.keys() if k <= i)],
|
prompts[max(k for k in prompts.keys() if k <= i)],
|
||||||
negative_prompt,
|
negative_prompt,
|
||||||
sampler,
|
sampler,
|
||||||
num_inference_steps,
|
num_inference_steps,
|
||||||
guidance_scale,
|
guidance_scale,
|
||||||
|
current_seed,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
current_image,
|
current_image,
|
||||||
|
|
@ -390,6 +407,7 @@ def create_zoom_single(
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
)
|
)
|
||||||
current_image = processed.images[0]
|
current_image = processed.images[0]
|
||||||
|
current_seed = newseed
|
||||||
|
|
||||||
current_image.paste(prev_image, mask=prev_image)
|
current_image.paste(prev_image, mask=prev_image)
|
||||||
|
|
||||||
|
|
@ -614,7 +632,8 @@ def on_ui_tabs():
|
||||||
inputs=[],
|
inputs=[],
|
||||||
outputs=[main_prompts, main_negative_prompt],
|
outputs=[main_prompts, main_negative_prompt],
|
||||||
)
|
)
|
||||||
|
with gr.Row():
|
||||||
|
seed = gr.Number(label="Seed", value=-1, precision=0, interactive=True)
|
||||||
main_sampler = gr.Dropdown(
|
main_sampler = gr.Dropdown(
|
||||||
label="Sampler",
|
label="Sampler",
|
||||||
choices=available_samplers,
|
choices=available_samplers,
|
||||||
|
|
@ -653,9 +672,7 @@ def on_ui_tabs():
|
||||||
)
|
)
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
init_image = gr.Image(type="pil", label="custom initial image")
|
init_image = gr.Image(type="pil", label="custom initial image")
|
||||||
exit_image = gr.Image(
|
exit_image = gr.Image(type="pil", label="custom exit image")
|
||||||
type="pil", label="custom exit image", visible=False
|
|
||||||
) # TODO: implement exit-image rendering
|
|
||||||
|
|
||||||
batchcount_slider = gr.Slider(
|
batchcount_slider = gr.Slider(
|
||||||
minimum=1,
|
minimum=1,
|
||||||
|
|
@ -768,6 +785,7 @@ Our best experience and trade-off is the R-ERSGAn4x upscaler.
|
||||||
inpainting_full_res,
|
inpainting_full_res,
|
||||||
inpainting_padding,
|
inpainting_padding,
|
||||||
video_zoom_speed,
|
video_zoom_speed,
|
||||||
|
seed,
|
||||||
main_width,
|
main_width,
|
||||||
main_height,
|
main_height,
|
||||||
batchcount_slider,
|
batchcount_slider,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue