Stable Diffusion NSFW: How To Make NSFW Images In Stable Diffusion

share to other networks share to twitter share to facebook
Stable Diffusion NSFW: How To Make NSFW Images In Stable Diffusion
Credit: Stability.ai

Wondering how to make NSFW images in Stable Diffusion? We will show you!

As good as DALL-E and MidJourney are, Stable Diffusion probably ranks among the best AI image generators. Unlike the other two, it is completely free to use. You can play with it as much as you like, generating all your wild ideas, including NSFW ones. There is a catch, however.

If you are accessing Stable Diffusion using Google Colab or the DreamStudio web app, you will not be able to generate NSFW Images as these tools have NSFW filters. So, how do you make NSFW images using Stable Diffusion?

Well, that's exactly what we are going to tell you in this post. Let’s get into it!

Advertisement

How To Make NSFW Images In Stable Diffusion Locally

If you have a GPU with at least 6GB of VRAM, you can make NSFW images in Stable Diffusion locally on your PC. The steps may seem a bit complicated, but it's actually easy to follow and you can get it done with a little effort.

Here is what you need to do.

  1. Download and install the latest Anaconda Distribution here. Also, download and install the latest Git here.
  2. Go to this link and select the Files and versions tab. Download the sd-v1-4.ckpt file. You may need to create a Huggingface account to download it. The file is more than 4GB, so while you wait, go get a coffee or watch the latest TikTok trends.
  3. Download the unfiltered script from this GitHub repository. To download, click on Code (green button) and select Download ZIP.
  4. Open the unzipped file and navigate to stable-diffusion-unfiltered-main/models/ldm. Create a folder called "stable-diffusion-v1" there. Rename sd-v1-4.ckpt file we downloaded to "model.ckpt", and copy it into that folder (stable-diffusion-v1) you've made.
  5. Open up Anaconda cmd prompt and navigate to the "stable-diffusion-unfiltered-main" folder.
  6. Run the following commands:
    1. conda env create -f environment.yaml
    2. conda activate ldm
    3. python scripts/txt2img.py --prompt "Elon Musk as an alien--H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50
  7. For custom images, replace the Elon Musk statement with the image you wish to create.
Advertisement

To create a new image you have to repeat steps 6 through 7. You can adjust the height and width of the image by changing the numbers next to H and W. However, to get higher resolution images, you will need 10 or 12 GB of VRAM.

Read More: How To Use MidJourney AI

How To Make NSFW Images In Stable Diffusion Using Google Colab

If you don't have a powerful GPU, don't worry. You can make NSFW images In Stable Diffusion using Google Colab Pro or Plus.

By default, Colab notebooks rely on the original Stable Diffusion which comes with NSFW filters. By simply replacing all instances linking to the original script with the script that has no safety filters, you can easily achieve generate NSFW images.

Here is how it is done.

  1. Go to this Google Colab Notebook.
  2. Click on the magnifying glass icon in the left pane.
  3. Copy-paste !git clone https://github.com/CompVis/stable-diffusion.git into the Find textbox.
  4. Copy-paste !git clone https://github.com/chemistzombie/stable-diffusion-unfiltered.git into the Replace with textbox.
  5. Click on Replace all and then select Ok to confirm.
Advertisement

That's it! The new script disables the NSFW filter as well as unnecessary watermarking. As a result, GPU memory is conserved by not loading the safety models, and valuable time is saved by not having to scan for NSFW content.