Fix: Stable Diffusion Black Image issue

Stable Diffusion has been serving as a free alternative to Midjourney, which doesn’t always perform better than Midjourney but can be accessed by anyone who wishes to try an AI image generator.

Setting up Stable Diffusion is much of a task, unlike Midjourney, where the services can be enjoyed by joining a Discord server. But, still, it’s a small price to pay rather than buying a subscription based service.

The procedure to create images is effortless as well. But, sometimes, users report an issue where pictures created by Stable Diffusion turn out to be black in color, or you can say just a blank slide.

Well, in this post, we will discuss why this issue occurs in the first place and methods to fix it.


Why does Stable Diffusion show Black Image

Quick Answer: Stable Diffusion shows a black image because GRisk GUI is triggering the NSFW (Not Safe For Work) filter or because of the precision settings in NVIDIA GPUs – GTX 1600 series.

Reason #1: Wrong NSFW tag

Stable Diffusion has banned the use of words that might create images considered NSFW or Not Safe For Work. Images that are deemed disrespectful, aggressive, or otherwise abusive must not be produced on Stable Diffusion.

That’s why the Stable Diffusion shows a black image instead of Midjourney’s approach, which shows a pop-up informing users that the procedure can’t be resumed because the text inputs that have the tendency to create NSFW images. Midjourney doesn’t proceed if someone uses banned words as direct or indirect prompts.

But the problem arises when Stable Diffusion GRisk GUI triggers the NSFW filter even when no unsafe image was being created on the platform. The tagging of wrong images or prompts as NSFW creates the issue, and the output comes out to a black image on Stable Diffusion.

Reason #2: Precision settings issue

Another reason for the black image issue is the precision settings for NVIDIA GPUs. Before you react, not all GPU models show signs of this issue. Only GTX 1650 and other models in the 1600 series show issues.

These GPU models do not support half-precision floating-point numbers, leading to issues with image generation, and that’s why you see a black image as output.

Now that you have understood the reasons causing the issue. Let us see the methods to fix this issue.


Fix: Stable Diffusion Black Image

1. Override NSFW Filter:

The first solution for fixing the black image issue in Stable Diffusion is to override the NSFW filter code. But, to override the filter, you will be required to make some changes to the code, which can affect the intended use and safety of the tool.

And if you have decided to take the risk, let us dive into the details.

Before you start, you must know that the code we are about to provide you works for Stable Diffusion 1.4 only. The configurations for version 1.5 and above are different.

Follow this GitHub post and use the code to override the NSFW filter.


2. Switch to Webui version

The first method we discussed above includes overriding the NSFW filter on version 1.4 of Stable Diffusion. But, another way exists to fix the black image error on Stable Diffusion. This doesn’t include interfering with any code or overriding of any feature.

You need to switch to the Webui version of Stable Diffusion. And there is no need to worry about the NSFW filter as the Automatic1111 version manages things well.

Switching to the Webui version is easier if you are not interested in altering the code.


3. Fixing Precision Settings for NVIDIA GPUs:

To fix the precision settings issue you just need to correct command line arguments. Simply, modify the webui-user.bat file.

Follow these steps provided below –

  • Step 1: Open the webui-user.bat file using a text editor.
  • Step 2: Locate the line “set COMMANDLINE_ARGS=” in the file.
  • Step 3: Add--precision full --no-half after  set COMMANDLINE_ARGS= without any spaces.
  • Step 4: Save the file and replace the original webui-user.bat with the modified version.

Using this method you will be able to fix the Precision Settings for Nvidia GPUs. The change in configuration forces the application to use full precision floating-point numbers, resolving the black image problem.

This change in the configuration may increase VRAM usage and require --medvram in some cases.

If the above solutions do not work, it’s essential to check the compatibility of the code changes with your version of Stable Diffusion GRisk GUI.

The code snippets in the shared link are confirmed to work with Version 1.4 of Stable Diffusion, but newer versions may have different filter implementations. Therefore, refer to the official documentation and GitHub repository to ensure compatibility.


Conclusion

That’s pretty much all, ladies and gentlemen. Hope you understand the real behind the black image generation issue in Stable Diffusion as well as the solutions to fix it.

In most of the cases you will be able to fix the problem by implementing first method discussed in this post.

As a mechanical engineer I did not get much time to indulge into TV, but it had always been my love for technology, that allowed me to stay updated. My love for technology has helped me gather every required knowledge about SEO. I am still in the learning process and would continue to be so till I master it.

Leave a comment