@@ -51,8 +51,12 @@ def __init__(self, config: CLIPConfig):
5151
5252    def  update_safety_checker_Level (self , Level ):
5353        """ 
54-         Args: 
55-             Level (`int` or `float` or one of the following [`WEAK`], [`MEDIUM`], [`NOMAL`], [`STRONG`], [`MAX`]) 
54+         Adjust the safety checker level. 
55+ 
56+         Parameters: 
57+             Level (`int` or `float` or one of the following [`WEAK`], [`MEDIUM`], [`NOMAL`], [`STRONG`], [`MAX`]): 
58+                 The level of safety checker adjustment, either as an integer, a float, or one of the predefined levels. 
59+                 Negative values decrease the filtering strength, while positive values increase it. 
5660        """ 
5761        Level_dict  =  {
5862            "WEAK" : - 0.10 ,
@@ -61,16 +65,22 @@ def update_safety_checker_Level(self, Level):
6165            "STRONG" : 0.01 ,
6266            "MAX" : 0.10 ,
6367            }
68+ 
69+         # If the provided Level is a predefined string, convert it to the corresponding float value 
6470        if  Level  in  Level_dict :
6571            Level  =  Level_dict [Level ]
72+ 
73+         # Check if the Level is a float or an integer 
6674        if  isinstance (Level , (float , int )): 
67-             setattr (self ,"adjustment" ,Level )
75+             setattr (self ,  "adjustment" ,  Level )   # Set the adjustment attribute to the Level value 
6876        else :
77+             # Raise an error if Level is not a valid type or predefined string 
6978            raise  ValueError ("`int` or `float` or one of the following ['WEAK'], ['MEDIUM'], ['NOMAL'], ['STRONG'], ['MAX']" )
70-         
71-         if  self .adjustment < 0 :
79+ 
80+         # Log a warning if the adjustment level is weakened (negative value) 
81+         if  self .adjustment  <  0 :
7282            logger .warning (
73-                 f "You have weakened the filtering strength of safety checker. Ensure"
83+                 "You have weakened the filtering strength of safety checker. Ensure" 
7484                " that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered" 
7585                " results in services or applications open to the public. Both the diffusers team and Hugging Face" 
7686                " strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling" 
0 commit comments