2022年8月28日日曜日

Stable Diffusionのblack image(NSFW)を解消する方法

  •    
  •  Stable Diffusionで画像を生成した際、「Potential NSFW content was detected in one or more images. A black image will be returned instead. Try again with a different prompt and/or seed.」というエラーが出て生成できない場合があります。

    NSFWってなんだろう?と調べてみたところ、【Not Safe For Work】 職場閲覧注意の略だそうです。

    これを自己責任で外す方法です。

    前提:ローカル環境に「pip install diffusers」でインストールしていること

    手順:

    ① StableDiffusionのインストール先を探す

    「pip show diffusers」コマンドでインストール先を探します。

    実行結果の「Location:」に記載されています。

    その場所に「diffusers」フォルダがあります。

    ② ソースをコメントにする

                (1) エディターで開く
                    ①のLocationフォルダをエディターで開きます。例はVisualStudioCodeです。

                (2) safety_checker.pyを開きます。

                    \diffusers\pipelines\stable_diffusionフォルダの下にあります。

                (3) 該当箇所をコメント

    以下の部分をコメントにします。先頭に「#」をつければコメントです。




     

                   【変更後】

     

                     

     

     

    4 件のコメント:

    1. This is a helpful walkthrough for users who encounter the black image issue while experimenting with Stable Diffusion in a local environment. Explaining the purpose of the NSFW safety checker and the steps involved in modifying the configuration gives readers a better understanding of how the image generation pipeline works and the importance of making such changes responsibly.


      Since the article focuses on Stable Diffusion and AI-based image synthesis, it aligns well with Generative AI Projects for Final Year. Exploring these projects helps students understand diffusion models, prompt-based content generation, and the practical implementation of modern generative AI applications.

      返信削除
    2. The discussion around Stable Diffusion also makes Image Generation Projects highly relevant for learners interested in text-to-image generation, image synthesis workflows, and optimizing AI models for creative and real-world applications.

      返信削除
    3. As generative AI continues to advance, image synthesis and enhancement techniques are becoming increasingly important across creative, medical, and industrial applications. The resource Image Processing Projects For Final Year is a valuable reference for understanding computer vision concepts, image analysis workflows, and practical implementations that complement modern AI-powered image generation technologies such as Stable Diffusion.

      返信削除