huggingface / huggingface/diffusers

Ability to select the strength of the safety_checker

Offen
#9,003 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
stale
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

**Is your feature request related to a problem? Please describe.**
Safety_checker can currently only be turned on/off, and we would like to be able to configure it in more detail.

**Describe alternatives you've considered.**
[I made it based on StableDiffusionPipeline.](https://github.com/suzukimain/diffusers/tree/edit_safety_checker)

**Describe the solution you'd like.**
I would like to be able to specify this in any pipeline using a parameter such as `safety_Level`.

```python
pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
safety_Level="MAX"
).to("cuda")
```

**Additional context.**
```python

git clone https://github.com/suzukimain/diffusers.git -b edit_safety_checker ./diffusers
pip install ./diffusers

import torch
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
).to("cuda")

"""
About safety_Level.
`int` or `float` or one of the following
'WEAK',
'MEDIUM',
'NOMAL',
'STRONG',
'MAX'.
"""

#-------------
#To see the filter strength.
pipe.safety_checker.safety_Level() # 0.0 (default)

#--------------
#If you want to change the intensity.
pipe.safety_checker_Level("STRONG", pipe.safety_checker)
pipe.safety_checker.safety_Level() # 0.1

#--------------
# If numbers are used
pipe.safety_checker_Level(3.0, pipe.safety_checker)
pipe.safety_checker.safety_Level() # 3.0

```

It is related to #5623.

Also, I wasn't sure what range of numbers to put in for `adjustment`, so I put -0.2~0.2 for once.
(If possible, I would appreciate it if someone could tell me about the range of `adjustment`.)

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with StableDiffusionPipeline and its safety_checker, then compare the edit_safety_checker branch linked in the issue. Clarify the accepted named and numeric ranges, including adjustment, before assessing a consistent pipeline parameter; done means a pipeline can configure filter strength beyond simple enable/disable behavior.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python, pytorch
Bereich
ai, machine-learning, security
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.