Stable Diffusion NSFW - how to generate NSFW images (2024)

With this trick, bypass the safety filters and make NSFW images in Stable Diffusion.

Stable Diffusion NSFW - how to generate NSFW images (1)

Credit: Stability.ai

Wondering how to generate 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 via Hugging Face 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?

Stable Diffusion NSFW - how to generate NSFW images (2)

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

Generate NSFW images with the Stable Diffusion NSFW filter off

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.

  • Download and install the latest Anaconda Distributionhere. Also,download and install the latest Git here.
  • 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.
  • Download the unfiltered script from this GitHub repository. To download, click onCode(green button) and selectDownload ZIP.
  • Open the unzipped file and navigate to stable-diffusion-unfiltered-main/models/ldm. Create a folder called "stable-diffusion-v1" there. Renamesd-v1-4.ckpt file we downloaded to "model.ckpt", and copy it into the folder (stable-diffusion-v1) you've made.
  • Open up the Anaconda cmd prompt and navigate to the "stable-diffusion-unfiltered-main" folder.

Advertisem*nt

  • Run the following commands:
    • conda env create -f environment.yaml
    • conda activate ldm
    • python scripts/txt2img.py --prompt "Elon Musk as an alien"--H 512 --W 512 --seed 27 --n_iter 2 --ddim_steps 50
  • For custom images, replace the Elon Musk statement with the image you wish to create.

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

Generate Stable Diffusion NSFW images 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 to generate NSFW images using Google Colab:

Advertisem*nt

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

That's it! Now you can run each block of code to generate images. If you need detailed instructions about that, read how to access Stable Diffusion using Google Colab.

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.

Go ahead, make art! And in case you are hit by the Stable Diffusion runtime error while generating NSFW images, we have some easy fixes for you.

Stable Diffusion NSFW - how to generate NSFW images (2024)
Top Articles
Latest Posts
Article information

Author: Kieth Sipes

Last Updated:

Views: 6076

Rating: 4.7 / 5 (47 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.