stable-diffusion-webui
stable-diffusion-webui copied to clipboard
Auto re-render black images
Is your feature request related to a problem? Please describe. I'm running the ui on a Mac and am still getting around 5-10% of the generations as blank black images.
Describe the solution you'd like Hoping it's possible to auto detect after rendering that it is a black image and re-render instead of moving on to the next image. This would help greatly when doing grid generations to test stuff and having black spots dotted all over.
When an output is a black image, running with the exact same parameters always results in a black image in my experience. Have you had a different experience?
Does your model uses a .VAE file?
@asaucedev re-running the same parameters work for me
This would not work as a feature because if this WebUi is ever used by more than one person or ran in an automated fashion it would have a chance of generating forever.
e.g.
render -> 100 successes, 1 black picture -> rerender black picture
infinite loop.
@AlphaJuliettOmega Not too sure why it would be an infinite loop as re-rendering with the same parameters and even seed managed to render the image properly for me. If there was an issue, perhaps it would include an option to re-try black images X number of times perhaps?
@kelvin-zhao that seems quite sensible then, the next problem to solve is this:
How do you detect a black image, is is rgb(0,0,0) on every pixel 100% of the time?
Wouldn't want to accidentally cull views of starry skies or nighttime/dark scenes
@kelvin-zhao that seems quite sensible then, the next problem to solve is this:
How do you detect a black image, is is rgb(0,0,0) on every pixel 100% of the time?
Wouldn't want to accidentally cull views of starry skies or nighttime/dark scenes
As an idea, you can estimate if a PNG is all a single color by file size compared to resolution Or in this kind of case, if there is an error causing the black generation, catching that would also work
@kelvin-zhao I would imagine adding all the rgb of every pixel and if the total is less than perhaps 100, we can determine that the image is black.
Ok, so now try put together a little python script that does that calculation, and if the image is 100% black pixels you're in luck
If there's any amount of noise, it will be harder to 'detect' / would need some slider/setting for a 'tolerance'
On Thu, 20 Oct 2022, 01:39 kelvin-zhao, @.***> wrote:
@kelvin-zhao https://github.com/kelvin-zhao I would imagine adding all the rgb of every pixel and if the total is less than perhaps 100, we can determine that the image is black.
— Reply to this email directly, view it on GitHub https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3074#issuecomment-1284705210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AETJR6UO4BHKWQLO7FEFWITWECBCTANCNFSM6AAAAAARIFHUXE . You are receiving this because you were mentioned.Message ID: @.***>
Ah I don't have any python experience though, I did try something similar in JavaScript before, would anyone be able to help convert that into python that can be implemented?
I know how to detect black reliably, but I am not familiar with this repo's code enough to implement the re-rendering.
for i in response['images']:
image = PIL.Image.open(io.BytesIO(base64.b64decode(i)))
all_black = all([sum(image.getextrema()[channel]) == 0 for channel in range(3)])
https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/23c947ab0374220c39ac54fc00afcb74e809dd95