divamgupta / stable-diffusion-tensorflow

Stable Diffusion in TensorFlow / Keras
Other
1.57k stars 227 forks source link

NSFW filter for results #66

Closed gaurav-95 closed 1 year ago

gaurav-95 commented 1 year ago

Thanks for making this wonderful repo. I was using the video generation function in the given colab file with this prompt.

At least 35 dead from mysterious meningitis outbreak in Mexico

I ended up getting images that had nudity, and genital areas exposed. Is it possible to add some sort of filter to remove such results.

costiash commented 1 year ago

Please correct me if I'm wrong, but I believe this can be fixed to some extent by using the 'negative prompt' input supplied to the stable diffusion model. I haven't included this capability because it was added after I finished the colab. For the time being, you can accomplish it manually by altering the loop that generates the frames:

img = generator.generate(
            prompt,
            negative_prompt="nudity",
            seed=args['seed'],
            num_steps=30,
            unconditional_guidance_scale=7.5,
            temperature=1,
            batch_size=1,
            input_image=prev,
            input_image_strength=0.6,
        )

If that's the case, I'll try to incorporate it into the colab notebook and the related utilities. People are also invited to do this if they have the time.

gaurav-95 commented 1 year ago

This does seem to work. I haven't done multiple runs yet, but so far so good. Changing the code cell under "Frames Creation" in the colab file and adding the negative prompt there seems to work.

Closing this issue. Thank You!