Kahsolt / stable-diffusion-webui-prompt-travel

Travel between prompts in the latent space to make pseudo-animation, extension script for AUTOMATIC1111/stable-diffusion-webui.
The Unlicense
248 stars 22 forks source link

Working with Inpainting #22

Closed ICYDev closed 1 year ago

ICYDev commented 1 year ago

Got this suggestion from a comment on one of my reddit posts, they asked if it would be possible to have the extension work with inpainting so we can say, mask only the character and travel only that, keeping the background consistent throughout. Currently running the script in the inpainting session throws error(see below) for me, I am assuming this would not be a difficult change since it would effectively work like the 'successive' mode or just normal img2img but with a mask parameter.

The error traceback:

Traceback (most recent call last):
  File "/path/stable-diffusion-webui/modules/call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "/path/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/path/stable-diffusion-webui/modules/img2img.py", line 169, in img2img
    processed = modules.scripts.scripts_img2img.run(p, *args)
  File "/path/stable-diffusion-webui/modules/scripts.py", line 399, in run
    processed = script.run(p, *script_args)
  File "/path/stable-diffusion-webui/extensions/stable-diffusion-webui-prompt-travel/scripts/prompt_travel.py", line 766, in run
    images, info = runner(p)
  File "/path/stable-diffusion-webui/extensions/stable-diffusion-webui-prompt-travel/scripts/prompt_travel.py", line 814, in run_linear
    gen_image(from_pos_hidden, from_neg_hidden, prompts, seeds, subseeds)
  File "/path/stable-diffusion-webui/extensions/stable-diffusion-webui-prompt-travel/scripts/prompt_travel.py", line 799, in gen_image
    proc = process_images_cond_to_image(p, pos_hidden, neg_hidden, prompts, seeds, subseeds)
  File "/path/stable-diffusion-webui/extensions/stable-diffusion-webui-prompt-travel/scripts/prompt_travel.py", line 322, in process_images_cond_to_image
    if opts.save_mask:
  File "/path/stable-diffusion-webui/modules/shared.py", line 552, in __getattr__
    return super(Options, self).__getattribute__(item)
AttributeError: 'Options' object has no attribute 'save_mask'
Kahsolt commented 1 year ago

This seems a small inconsistency with current webui core. No big problem working with masks, I'll check it later.

Kahsolt commented 1 year ago

Checked it out. These opts.save_mask sutff are from this PR caf84e8 dated 23/03, it adding:

if hasattr(p, 'mask_for_overlay') and p.mask_for_overlay:
    image_mask = p.mask_for_overlay.convert('RGB')
    image_mask_composite = Image.composite(image.convert('RGBA').convert('RGBa'), Image.new('RGBa', image.size), p.mask_for_overlay.convert('L')).convert('RGBA')

    if opts.save_mask:
        images.save_image(image_mask, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask")

    if opts.save_mask_composite:
        images.save_image(image_mask_composite, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext(n, i), p=p, suffix="-mask-composite")

    if opts.return_mask:
        output_images.append(image_mask)

    if opts.return_mask_composite:
        output_images.append(image_mask_composite)

On 29/03, ptravel v2.4 synchronized its hack to webui core, also added these. Keep rolling update webui should be a simple fix (

ICYDev commented 1 year ago

Confirmed does indeed work with the latest updates, slightly annoyed since the ui responsiveness tanked with the latest updates for me, but oh well, at least it functions.