Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After 7.8 - 9.2 Zoom Enhance either doesn't work at all; Doesn't stitch or makes barely any changes #152

Open
Poliveris opened this issue May 15, 2023 · 8 comments

Comments

@Poliveris
Copy link

Poliveris commented May 15, 2023

I've tried 7.8, 7.9, 7.9.1, 8.0, and recently 9.0/9.2

Zoom Enhance no longer works with current A1111 on 7.8 - 7.9.1; no image is generated for zoom enhance.

On 9.0+ it generates 2 images but does not stitch it to original. Looking at another comment it seems you've changed how Zoom enhance works which no longer utilizes img2img, and new non stitch image looks barely different.

Please revert that change back to img2img I used to love this extension; now it doesn't stitch the images together, it doesn't go to %temp% folder, and it barely changes from the original.

I really wish I had never updated my Auto1111 and the extension itself; as now I cannot get older versions of SD a1111 to run properly. And this extension was nearly a MUST for me.

Here is the comment in question "In previous versions (< 8.0.0), [zoom_enhance] would call [img2img] for the upscale, but this was incompatible with extensions that hijack the inference pipeline - ControlNet in particular. Now it uses a monkeypatched process_images_inner() with a clone of the p object, which shouldn't be any slower unless maybe you're running into some memory limitations."

This is not a good change for normal users and even if zoom enhance still worked the stitched image would look barely any different than it did prior. At this point I'd almost like the zoom enhance extension to be on its own so that it doesn't conflict with these.

@Poliveris
Copy link
Author

Poliveris commented May 15, 2023

Running https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases/tag/v1.0.0-pre
and version 7.8 of unprompted.

Tried running newer versions but as I've said they do not stitch the images back together; and barely any changes are made to image. I want to go back to 7.8 -7.9.1

FULL Error message (yes I spelled versions wrong do not care to fix)

Error running postprocess: X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\scripts\unprompted.py
Traceback (most recent call last):
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shortcodes.py", line 117, in render
return str(self.handler(self.token.keyword, self.pargs, self.kwargs, context))
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shared.py", line 61, in handler
return(self.shortcode_objects[f"{keyword}"].run_atomic(pargs, kwargs, context))
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted/shortcodes\stable_diffusion\zoom_enhance.py", line 136, in run_atomic
fixed_image = self.Unprompted.shortcode_objects["img2img"].run_atomic(set_pargs,None,None)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted/shortcodes\stable_diffusion\img2img.py", line 32, in run_atomic
img2img_result = modules.img2img.img2img(
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\modules\img2img.py", line 96, in img2img
assert 0. <= denoising_strength <= 1., 'can only work with strength in [0.0, 1.0]'
TypeError: '<=' not supported between instances of 'float' and 'NoneType'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\modules\scripts.py", line 375, in postprocess
script.postprocess(p, processed, *script_args)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\scripts\unprompted.py", line 455, in postprocess
Unprompted.shortcode_objects[i].after(p,processed)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted/shortcodes\basic\after.py", line 32, in after
self.Unprompted.process_string(self.Unprompted.parse_alt_tags(content,"after"))
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shared.py", line 157, in parse_alt_tags
return(self.shortcode_parser.parse(string,context))
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shortcodes.py", line 219, in parse
return stack.pop().render(context)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shortcodes.py", line 58, in render
return ''.join(child.render(context) for child in self.children)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shortcodes.py", line 58, in
return ''.join(child.render(context) for child in self.children)
File "X:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Verions\extensions\unprompted\lib_unprompted\shortcodes.py", line 121, in render
raise ShortcodeRenderingError(msg) from ex
lib_unprompted.shortcodes.ShortcodeRenderingError: An exception was raised while rendering the 'zoom_enhance' shortcode in line 1.

@Poliveris
Copy link
Author

Poliveris commented May 15, 2023

Update 7.9 - has no error but does not do anything, no images stitch no 2nd image, clipseg model weight gets downloaded; however nothing after.

Update 7.9.1 - Same thing; clipseg downloads 0 errors but nothing is generated aside from original.

Update 7.7.2 - My original extension install errors out and no longer works as well; even with A1111 1.0

Update 7.7.0 - Errors out "Error running postprocess: C:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Versions\extensions\unprompted\scripts\unprompted.py
Traceback (most recent call last):
File "C:\Program Files\AI Tools\AI\Stable Diffusion 2.1\SD OLD Versions\extensions\unprompted\lib_unprompted\shortcodes.py", line 117, in render"

Update** python downgraded to 3.10.8 - Downloads clipseg; no new image generated

Update*** python downgraded to 3.10.6 - Not working at all; no clipseg download

Update**** python upgraded back to 3.10.9 - Clipseg downloads; only original gets generated

Update***** Python to 3.10.6; Using ver 9.2.0 (released yesterday); Makes original + upscaled area but does not stitch the images together. An image appears in temp folder but its the original and not stitched.

UPDATE****** Fixed 9.2.0 w/ old zoom_enhance.py; However the image quality compared to 7.x is worse so hoping Img2img generation is reapplied instead of new method. Also must use FULL shortcode can no longer keep short replacement in []

@balrog69-420
Copy link

had lots of problems with zoom enhance not working too. i havnt updated recently as i actualy got it working a few days ago after the update last week. i had to delete a section in the shortcode. mine looks like this.

[if batch_index=0][after][zoom_enhance show_original mask="face,head" replacement="pretty female face, lora:add_detail:1.0(masterpiece), (best quality), (high quality), (high resolution), (highres), (absurdres), (ultra detailed), (high-quality), (realistic), (amazing digital art), (realistic lighting:1.4), (realistic shadows:1.4), (perfect contrast), (bright, vibrant), " negative_replacement="(bad-hands-5:1.4), (EasyNegative:0.4), (worst quality:1.5), (low quality:1.5), (bad_prompt2:1.1), (depth of field, blurry:1.2), (greyscale, monochrome:1.1), (asymmetrical fine details:1.6), (asymmetrical intricate details:1.6), (jumbled intricate details), (intricate details that don't make sense), (lowres details), (blurry details), (lazy details), (lazy intricate details), (geometrically imperfect details), cropped, lowres, text, jpeg artifacts, signature, username, blurry, artist name, trademark, title, (tan, Reference sheet, (worst quality), (low quality:1.4), (out of focus:1.2), (blurred background), (low detail background), (background has few details), (background undetailed), (out of focus:1.2), helmet, face mask, edge blur, radial blur, mutated, extra limbs, ugly, poorly drawn face, (badly drawn, bad drawing, bad proportions,:1.2), (bad_prompt2:0.5), opening curtain, upside down, inverted, bodysuit, latex, " mask_sort_method="left-to-right" unload_model upscale_method='Bicubic' downscale_method='Lanczos' blur_size=0.02 cfg_scale_min=8 denoising_max=0.52 mask_size_max=0.5 mask_method='clipseg' sharpen_amount=1.1 color_correct_method='none' color_correct_timing='pre' color_correct_strength=1.0 min_area=600.0 contour_padding=0.01 upscale_width=1300.0 upscale_height=1300.0][/after][/if]

works perfectly again for me. deleting a few of the bits at the end was what got it working. obviously change the prompts to what you want but the last section with the settings should work.

@Poliveris
Copy link
Author

Poliveris commented May 15, 2023

Solution for 9.2.0: Use modified Zoom_enhance.py #84 posted by creator. This made a stitch image in %TEMP% and had the modified image displayed in Auto1111 GUI. I had to use FULL shortcode in wizard zoom enhance section;

[if batch_index=0][after][zoom_enhance show_original mask='face' replacement='[insert prompt]' mask_sort_method='left-to-right' upscale_method='Nearest Neighbor' downscale_method='Lanczos' blur_size=0.03 cfg_scale_min=3.0 denoising_max=0.65 mask_size_max=0.3 mask_method='clipseg' sharpen_amount=1.0 color_correct_method='none' color_correct_timing='pre' color_correct_strength=1.0 min_area=50.0 contour_padding=0.0 upscale_width=512.0 upscale_height=512.0 hires_size_max=1024.0][/after][/if]

Issue: 9.2.0: would display 2 images both unmodified in GUI, 1 image in text2img unmodified, 1 image in img2img of upscaled "fix" section (ie face, hands etc), 1 image in %TEMP% unmodified.

I really appreciate this extension, and I get it might be a lot to ask; but a potential future "desire" would be if we could have the option for img2img method again like in 7.x. Might be a lot to ask and I already appreciate this extension greatly. Hope this helps as well

@cian0
Copy link

cian0 commented Jul 1, 2023

When you use debug in the shortcode, it will generate the images correctly at the base folder of your SD installation

@ThereforeGames
Copy link
Owner

Hi folks,

I finally have an update on the issues with [zoom_enhance] - here are the details from the latest announcement:

Over the last few weeks, I have released many improvements to Unprompted's logging capabilities. The motivation for these updates was in part due to a longstanding issue with zoom_enhance that I was having trouble figuring out.

Well, I can say now with reasonable confidence that the problem was related to the way I was copying the WebUI's p object. In recent versions of the WebUI, my shallow copy of p led to numerous problems with image processing. Switching to a deep copy was not a viable alternative, because the object contains custom modules that Python's copy() method doesn't know what to do with.

Now in Unprompted v9.13.2, all processes in the [after] routine will refer to the original p object instead. The reason I didn't do this in the first place is because it means I have to temporarily disable other scripts with compatibility issues, such as ControlNet and Regional Prompter. Some scripts are more difficult to disable than others, but I think I got the major ones sorted out.

Let's go over some other exciting changes to [zoom_enhance]:

If a certain extension isn't playing nice with my bypass rules, you can use the _alt parg to engage alternate image processing. This sends the generation task off to [img2img], which instantiates its own p object and should prove more compatible (at the cost of some performance and overhead.)

In img2img mode, you can now use [zoom_enhance] outside of the [after] block! This means the shortcode will run on your init image before the WebUI has a chance to modify it. Very useful if you just want to enhance an existing image without re-processing the entire thing. Keep in mind that the normal img2img task will still run afterwards and output a second picture. Until I find a way to disable that, you can simply lower the stepcount to 1 to minimize runtime.

You can now chain together multiple [zoom_enhance] blocks which will run independently of each other. Prior to this, you would have to specify multiple masks and replacement rules using the vertical pipe delimiter, e.g. mask="face|hands" replacement="better face|better hands", but this was a bit unintuitive and prone to error on certain kinds of images. (The option is still there if you need it.)

With the longstanding bugs solved, I plan to experiment with other interesting features for [zoom_enhance] as well as the companion template Bodysnatcher. Let me know if you have any ideas you would like to see added, either for this shortcode or Unprompted in general. 🙂

Please try updating to Unprompted v9.13.2 and let me know if you still encounter any problems with [zoom_enhance]. (And don't forget to try the _alt parg as well - it resembles the behavior of Unprompted v7)

Thanks!

@spryroX
Copy link

spryroX commented Aug 17, 2023

Hi folks,

I finally have an update on the issues with [zoom_enhance] - here are the details from the latest announcement:

Over the last few weeks, I have released many improvements to Unprompted's logging capabilities. The motivation for these updates was in part due to a longstanding issue with zoom_enhance that I was having trouble figuring out.
Well, I can say now with reasonable confidence that the problem was related to the way I was copying the WebUI's p object. In recent versions of the WebUI, my shallow copy of p led to numerous problems with image processing. Switching to a deep copy was not a viable alternative, because the object contains custom modules that Python's copy() method doesn't know what to do with.
Now in Unprompted v9.13.2, all processes in the [after] routine will refer to the original p object instead. The reason I didn't do this in the first place is because it means I have to temporarily disable other scripts with compatibility issues, such as ControlNet and Regional Prompter. Some scripts are more difficult to disable than others, but I think I got the major ones sorted out.
Let's go over some other exciting changes to [zoom_enhance]:
If a certain extension isn't playing nice with my bypass rules, you can use the _alt parg to engage alternate image processing. This sends the generation task off to [img2img], which instantiates its own p object and should prove more compatible (at the cost of some performance and overhead.)
In img2img mode, you can now use [zoom_enhance] outside of the [after] block! This means the shortcode will run on your init image before the WebUI has a chance to modify it. Very useful if you just want to enhance an existing image without re-processing the entire thing. Keep in mind that the normal img2img task will still run afterwards and output a second picture. Until I find a way to disable that, you can simply lower the stepcount to 1 to minimize runtime.
You can now chain together multiple [zoom_enhance] blocks which will run independently of each other. Prior to this, you would have to specify multiple masks and replacement rules using the vertical pipe delimiter, e.g. mask="face|hands" replacement="better face|better hands", but this was a bit unintuitive and prone to error on certain kinds of images. (The option is still there if you need it.)
With the longstanding bugs solved, I plan to experiment with other interesting features for [zoom_enhance] as well as the companion template Bodysnatcher. Let me know if you have any ideas you would like to see added, either for this shortcode or Unprompted in general. 🙂

Please try updating to Unprompted v9.13.2 and let me know if you still encounter any problems with [zoom_enhance]. (And don't forget to try the _alt parg as well - it resembles the behavior of Unprompted v7)

Thanks!

I'm using unprompted v9.15.1 with webUI v1.5.1 and for some reason it's not stitching the img2img to the original image.
Since I'm using it for the first time I'm not 100% sure I'm doing it right, here's my steps:

  • Use a normal prompt of a person
  • Unprompted -> Wizard ->ShortCodes -> zoom_enhance
  • Check "🪄 Auto-include this in prompt"
  • Hit generate
  • Notice that it is doing a second step where it does 2 img2img passes on the face (these also show up in the img2img output folder)
  • Original image is generated, nothing is stitched

Enabling the _alt parm doesn't seem to matter.

When I enable the debug parm the stitched image is in my root folder, so it does seem to work (somewhat) with the debug flag enabled. Even with debug flag enabled to image in the txt2image folder is the original unstitched.

@Sporking
Copy link

Sporking commented Aug 23, 2023

This still does not appear to be fixed.

My experience is similar to that of @spryroX. Specifically:

Windows 11 Pro
Updated to the latest of everything (Automatic1111, PyTorch 2, Unprompted 9.15.1) as of a few days ago.
Python 3.10.11
WebUI 1.5.1
I have tried it both with and without the extension renamed to "_unprompted". It does not seem to make a difference.
I have tried it both in txt2img and img2img, and see similar behavior in both places.
I do not have ControlNet installed, or any other plugins.

For my most recent attempts, I was ending my Img2Img prompt with "[after][zoom_enhance allow_dupe_index debug replacement="blue face" denoising_max=1][/after]". (Using _alt or not does not seem to make any difference.)

(Note, by the way, that I was getting warnings when I used batch size=3, telling me that duplicate 'after' code was detected and I should include allow_dupe_index to suppress the warning. My prompt had no use of "|" in it (just words, commas, and parentheses), and nothing else that I could see that should have resulted in this warning. This seems like a bug. Could this be related?)

As @spyrox noted:

  • I can see the clipped faces appear in the WebUI as zoom_enhance kicks in, and I can find the enhanced versions of the faces in my img2img/<date> folder afterwards, but there is no change to the generated image that the faces were clipped from. Stitching is not done.
  • When I include "debug", I can see that the last debug image in the WebUI folder is stitched properly. However, my generated image in the img2img/<date> folder still does not have any stitching done to it.

When I look in the img2img/<date> folder afterwards, I see that the generated image was generated BEFORE the Unprompted plugin showed me the face image it had clipped out of the original generated image. It then enhanced that face image and then saved that face image also in the img2img/<date> folder. The file modification date of the generated image has not been updated after the face image was last saved, as I would have expected it to be if it contained stitched data from the face image. There is no file that has a modification date later than the modification date of the clipped image. This leads me to conclude that Unprompted did not even try to overwrite the originally-generated image with a stitched image. I would have expected that if even if stitching had failed to update the image in memory for some reason, that the file would have still been overwritten after the stitching attempt. This leads me to wonder if Unprompted is trying to save its final results to an illegal file or path name, or is erroring out (silently!) before attempting such a save.

I investigated the possibility that it could be refusing to overwrite the original pre-stitched image with the post-stitched image because the file already exists. I tried deleting the pre-stitched image out of img2img/<date> as it was in the process of updating the clipped face image. Despite the fact that the pre-stitched image no longer existed, no post-stitched image was created after it was done updating the clipped face image.

Question 1: Is it the case that the stitching is done to an image in the $TEMP folder, which is then supposed to be copied/moved over the originally generated image in the img2img/<date> folder afterwards? If so, then perhaps something in this copy/move process is failing. Note, for instance, that Windows file locking is generally more strict than on Unix, and the operating system may refuse to let you move, delete, or rewrite a file which is open (in another process or in the same process). Perhaps errors about this are occurring but are being suppressed and never make it to the console?

Question 2: Are others who are experiencing this problem experiencing it on Windows? I wonder if there could be a file naming issue relating to backslashes. I saw someone report an error message at some point referring to "extensions_unprompted" rather than "extensions\_unprompted" or "extensions\\_unprompted", which might imply that backslashes are getting removed from paths somehow, possibly due to escaping/unescaping or something similar. (See #129 (comment))

My current "Settings" in the WebUI include:
[X] Save text information about generation parameters as chunks to png files
[ ] Create a text file next to every image with generation parameters.
[ ] Save a copy of image before doing face restoration.
[ ] Save a copy of image before applying highres fix.
[X] Save a copy of image before applying color correction to img2img results
[ ] For inpainting, save a copy of the greyscale mask
[X] For inpainting, save a masked composite
[ ] Use original name for output filename during batch process in extras tab
[ ] Use upscaler name as filename suffix in the extras tab
[X] When using 'Save' button, only save a single selected image
[ ] Save init images when using img2img
[left empty] Directory for temporary images; leave empty for default

Perhaps one of these could be confusing Unprompted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants