diffusers
diffusers copied to clipboard
safety_checker and pipe checking and how to disable warning safety checker
Describe the bug
When disabling safety checker, diffusers spits out a wall of text, every time. This is an annoyance. We get it, you don't want people making boobies and stuff. Turn it off.
Additionally, when using non-standard safety checker class for better functionality, I get
You have passed a non-standard module <function dummy_checker at 0x7fb6a4447950>. We cannot verify whether it has the correct type
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
[<ipython-input-13-f14a2d10e2b7>](https://localhost:8080/#) in <module>
53 safety_checker=gaussian_safety_checker,
54 torch_dtype=torch.float16,
---> 55 use_auth_token=token
56 )
57 pipe=pipe.to("cuda")
2 frames
[/usr/local/lib/python3.7/dist-packages/diffusers/pipeline_utils.py](https://localhost:8080/#) in register_modules(self, **kwargs)
123
124 # check if the module is a pipeline module
--> 125 pipeline_dir = module.__module__.split(".")[-2]
126 path = module.__module__.split(".")
127 is_pipeline_module = pipeline_dir in path and hasattr(pipelines, pipeline_dir)
IndexError: list index out of range
And the program fails.
Why are you checking pipe types and stuff? What real purpose does this serve besides getting in the way of API use development? I want to be able to customize this system to my needs, there shouldn't be stuff like this that I need to disable.
Additionally, if disabling the safety_checker is going to cause issues, you should adjust your game plan for development. 99% of us are disabling it, it's basically inherently broken with what it flags.
Reproduction
No response
Logs
No response
System Info
diffusersversion: 0.6.0- Platform: Linux-5.10.133+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.15
- PyTorch version (GPU?): 1.12.1+cu113 (True)
- Huggingface_hub version: 0.10.1
- Transformers version: 4.23.1
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
Thanks for the issue.
Two things in this issue:
- Remove the logger warning. We won't do this for now as we consider the potential upsides (warning people of problems) to outweigh the downsides. You can however simple disable the warning yourself if you want - it's as easy as setting the logging level to the highest "error" level as explained here: https://huggingface.co/docs/diffusers/api/logging
import torch
from diffusers import StableDiffusionPipeline
from diffusers import logging
logging.set_verbosity_error()
pipe = StableDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
revision="fp16",
torch_dtype=torch.float16,
device_map="auto",
safety_checker=None,
)
- Passing a costum safety checker. Here I will need a complete code sample to reproduce the error. Could you add a code snippet that leads to your error message?
from diffusers import logging logging.set_verbosity_error()
This only seems to stop one of the safety checker warnings, others and futurewarning are still coming through such as:
/usr/local/lib/python3.7/dist-packages/huggingface_hub/file_download.py:591: FutureWarning: `cached_download` is the legacy way to download files from the HF hub, please consider upgrading to `hf_hub_download`
FutureWarning,
WARNING:diffusers_modules.git.lpw_stable_diffusion:You have disabled the safety checker for <class 'diffusers_modules.git.lpw_stable_diffusion.StableDiffusionLongPromptWeightingPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
Perhaps inconsistent logging usage or labelling warnings.
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.