55import torch
66
77import PIL
8- from packaging import version
98from transformers import CLIPFeatureExtractor , CLIPTokenizer
109
1110from ...configuration_utils import FrozenDict
@@ -68,6 +67,8 @@ class OnnxStableDiffusionInpaintPipelineLegacy(DiffusionPipeline):
6867 feature_extractor ([`CLIPFeatureExtractor`]):
6968 Model that extracts features from generated images to be used as inputs for the `safety_checker`.
7069 """
70+ _optional_components = ["safety_checker" , "feature_extractor" ]
71+
7172 vae_encoder : OnnxRuntimeModel
7273 vae_decoder : OnnxRuntimeModel
7374 text_encoder : OnnxRuntimeModel
@@ -134,27 +135,6 @@ def __init__(
134135 " checker. If you do not want to use the safety checker, you can pass `'safety_checker=None'` instead."
135136 )
136137
137- is_unet_version_less_0_9_0 = hasattr (unet .config , "_diffusers_version" ) and version .parse (
138- version .parse (unet .config ._diffusers_version ).base_version
139- ) < version .parse ("0.9.0.dev0" )
140- is_unet_sample_size_less_64 = hasattr (unet .config , "sample_size" ) and unet .config .sample_size < 64
141- if is_unet_version_less_0_9_0 and is_unet_sample_size_less_64 :
142- deprecation_message = (
143- "The configuration file of the unet has set the default `sample_size` to smaller than"
144- " 64 which seems highly unlikely .If you're checkpoint is a fine-tuned version of any of the"
145- " following: \n - CompVis/stable-diffusion-v1-4 \n - CompVis/stable-diffusion-v1-3 \n -"
146- " CompVis/stable-diffusion-v1-2 \n - CompVis/stable-diffusion-v1-1 \n - runwayml/stable-diffusion-v1-5"
147- " \n - runwayml/stable-diffusion-inpainting \n you should change 'sample_size' to 64 in the"
148- " configuration file. Please make sure to update the config accordingly as leaving `sample_size=32`"
149- " in the config might lead to incorrect results in future versions. If you have downloaded this"
150- " checkpoint from the Hugging Face Hub, it would be very nice if you could open a Pull request for"
151- " the `unet/config.json` file"
152- )
153- deprecate ("sample_size<64" , "1.0.0" , deprecation_message , standard_warn = False )
154- new_config = dict (unet .config )
155- new_config ["sample_size" ] = 64
156- unet ._internal_dict = FrozenDict (new_config )
157-
158138 self .register_modules (
159139 vae_encoder = vae_encoder ,
160140 vae_decoder = vae_decoder ,
@@ -165,7 +145,6 @@ def __init__(
165145 safety_checker = safety_checker ,
166146 feature_extractor = feature_extractor ,
167147 )
168- self .vae_scale_factor = 2 ** (len (self .vae .config .block_out_channels ) - 1 )
169148 self .register_to_config (requires_safety_checker = requires_safety_checker )
170149
171150 # Copied from diffusers.pipelines.stable_diffusion.pipeline_onnx_stable_diffusion.OnnxStableDiffusionPipeline._encode_prompt
@@ -372,7 +351,7 @@ def __call__(
372351
373352 # preprocess mask
374353 if not isinstance (mask_image , np .ndarray ):
375- mask_image = preprocess_mask (mask_image , self . vae_scale_factor )
354+ mask_image = preprocess_mask (mask_image , 8 )
376355 mask_image = mask_image .astype (latents_dtype )
377356 mask = np .concatenate ([mask_image ] * num_images_per_prompt , axis = 0 )
378357
0 commit comments