



"""simple docstring"""

from typing import Any, Callable, Dict, List, Optional, Union

import PIL.Image
import torch
from transformers import CLIPImageProcessor, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    DiffusionPipeline,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionImgaImgPipeline,
    StableDiffusionInpaintPipelineLegacy,
    StableDiffusionPipeline,
    UNetaDConditionModel,
)
from diffusers.configuration_utils import FrozenDict
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
from diffusers.utils import deprecate, logging


A_	:						Optional[int]				=			logging.get_logger(__name__)  # pylint: disable=invalid-name
class 						lowerCAmelCase__	(  _lowerCamelCase   ):


	'''simple docstring'''







	_SCREAMING_SNAKE_CASE  :		Any     	=   ['''safety_checker''', '''feature_extractor''']





	def __init__(			self							:					Dict    ,					_SCREAMING_SNAKE_CASE							:					AutoencoderKL    ,					_SCREAMING_SNAKE_CASE							:					CLIPTextModel    ,					_SCREAMING_SNAKE_CASE							:					CLIPTokenizer    ,					_SCREAMING_SNAKE_CASE							:					UNetaDConditionModel    ,					_SCREAMING_SNAKE_CASE							:					Union[DDIMScheduler, PNDMScheduler, LMSDiscreteScheduler]    ,					_SCREAMING_SNAKE_CASE							:					StableDiffusionSafetyChecker    ,					_SCREAMING_SNAKE_CASE							:					CLIPImageProcessor    ,					_SCREAMING_SNAKE_CASE							:					bool = True    ,					)	->  List[str]:





					"""simple docstring"""


					super().__init__()
					if hasattr(scheduler.config    ,					'steps_offset'						) and scheduler.config.steps_offset != 1:
									SCREAMING_SNAKE_CASE	:       Optional[int] 							=    (
									    f"""The configuration file of this scheduler: {scheduler} is outdated. `steps_offset`"""
									    f""" should be set to 1 instead of {scheduler.config.steps_offset}. Please make sure """
									    'to update the config accordingly as leaving `steps_offset` might led to incorrect results'
									    ' in future versions. If you have downloaded this checkpoint from the Hugging Face Hub,'
									    ' it would be very nice if you could open a Pull request for the `scheduler/scheduler_config.json`'
									    ' file'
									)
									deprecate('steps_offset!=1'    ,					'1.0.0'    ,					_SCREAMING_SNAKE_CASE    ,					standard_warn=_SCREAMING_SNAKE_CASE						)
									SCREAMING_SNAKE_CASE	:       List[Any] 							=    dict(scheduler.config						)
									SCREAMING_SNAKE_CASE	:       Optional[Any] 							=    1
									SCREAMING_SNAKE_CASE	:       Dict 							=    FrozenDict(_SCREAMING_SNAKE_CASE						)

					self.register_modules(
					    vae=_SCREAMING_SNAKE_CASE    ,					text_encoder=_SCREAMING_SNAKE_CASE    ,					tokenizer=_SCREAMING_SNAKE_CASE    ,					unet=_SCREAMING_SNAKE_CASE    ,					scheduler=_SCREAMING_SNAKE_CASE    ,					safety_checker=_SCREAMING_SNAKE_CASE    ,					feature_extractor=_SCREAMING_SNAKE_CASE    ,					)
					self.register_to_config(requires_safety_checker=_SCREAMING_SNAKE_CASE						)





	@property
	def  _lowerCAmelCase    (			self							:					int						)	->  Dict[str, Any]:





					"""simple docstring"""


					return {k: getattr(self    ,					_SCREAMING_SNAKE_CASE						) for k in self.config.keys() if not k.startswith('_'						)}





	def  _lowerCAmelCase    (			self							:					int    ,					_SCREAMING_SNAKE_CASE							:					Optional[Union[str, int]] = "auto"						)	->  Optional[int]:





					"""simple docstring"""


					if slice_size == "auto":
									# half the attention head size is usually a good trade-off between
									# speed and memory
									SCREAMING_SNAKE_CASE	:       Any 							=    self.unet.config.attention_head_dim // 2
					self.unet.set_attention_slice(_SCREAMING_SNAKE_CASE						)





	def  _lowerCAmelCase    (			self							:					Any						)	->  str:





					"""simple docstring"""


					self.enable_attention_slicing(_SCREAMING_SNAKE_CASE						)





	@torch.no_grad()
	def  _lowerCAmelCase    (			self							:					Optional[Any]    ,					_SCREAMING_SNAKE_CASE							:					Union[str, List[str]]    ,					_SCREAMING_SNAKE_CASE							:					Union[torch.FloatTensor, PIL.Image.Image]    ,					_SCREAMING_SNAKE_CASE							:					Union[torch.FloatTensor, PIL.Image.Image]    ,					_SCREAMING_SNAKE_CASE							:					float = 0.8    ,					_SCREAMING_SNAKE_CASE							:					Optional[int] = 50    ,					_SCREAMING_SNAKE_CASE							:					Optional[float] = 7.5    ,					_SCREAMING_SNAKE_CASE							:					Optional[Union[str, List[str]]] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[int] = 1    ,					_SCREAMING_SNAKE_CASE							:					Optional[float] = 0.0    ,					_SCREAMING_SNAKE_CASE							:					Optional[torch.Generator] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[str] = "pil"    ,					_SCREAMING_SNAKE_CASE							:					bool = True    ,					_SCREAMING_SNAKE_CASE							:					Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,					_SCREAMING_SNAKE_CASE							:					int = 1    ,					)	->  Optional[Any]:





					"""simple docstring"""


					return StableDiffusionInpaintPipelineLegacy(**self.components						)(
					    prompt=_SCREAMING_SNAKE_CASE    ,					image=_SCREAMING_SNAKE_CASE    ,					mask_image=_SCREAMING_SNAKE_CASE    ,					strength=_SCREAMING_SNAKE_CASE    ,					num_inference_steps=_SCREAMING_SNAKE_CASE    ,					guidance_scale=_SCREAMING_SNAKE_CASE    ,					negative_prompt=_SCREAMING_SNAKE_CASE    ,					num_images_per_prompt=_SCREAMING_SNAKE_CASE    ,					eta=_SCREAMING_SNAKE_CASE    ,					generator=_SCREAMING_SNAKE_CASE    ,					output_type=_SCREAMING_SNAKE_CASE    ,					return_dict=_SCREAMING_SNAKE_CASE    ,					callback=_SCREAMING_SNAKE_CASE    ,					)





	@torch.no_grad()
	def  _lowerCAmelCase    (			self							:					List[Any]    ,					_SCREAMING_SNAKE_CASE							:					Union[str, List[str]]    ,					_SCREAMING_SNAKE_CASE							:					Union[torch.FloatTensor, PIL.Image.Image]    ,					_SCREAMING_SNAKE_CASE							:					float = 0.8    ,					_SCREAMING_SNAKE_CASE							:					Optional[int] = 50    ,					_SCREAMING_SNAKE_CASE							:					Optional[float] = 7.5    ,					_SCREAMING_SNAKE_CASE							:					Optional[Union[str, List[str]]] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[int] = 1    ,					_SCREAMING_SNAKE_CASE							:					Optional[float] = 0.0    ,					_SCREAMING_SNAKE_CASE							:					Optional[torch.Generator] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[str] = "pil"    ,					_SCREAMING_SNAKE_CASE							:					bool = True    ,					_SCREAMING_SNAKE_CASE							:					Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,					_SCREAMING_SNAKE_CASE							:					int = 1    ,					**_SCREAMING_SNAKE_CASE							:					Dict    ,					)	->  List[str]:





					"""simple docstring"""


					return StableDiffusionImgaImgPipeline(**self.components						)(
					    prompt=_SCREAMING_SNAKE_CASE    ,					image=_SCREAMING_SNAKE_CASE    ,					strength=_SCREAMING_SNAKE_CASE    ,					num_inference_steps=_SCREAMING_SNAKE_CASE    ,					guidance_scale=_SCREAMING_SNAKE_CASE    ,					negative_prompt=_SCREAMING_SNAKE_CASE    ,					num_images_per_prompt=_SCREAMING_SNAKE_CASE    ,					eta=_SCREAMING_SNAKE_CASE    ,					generator=_SCREAMING_SNAKE_CASE    ,					output_type=_SCREAMING_SNAKE_CASE    ,					return_dict=_SCREAMING_SNAKE_CASE    ,					callback=_SCREAMING_SNAKE_CASE    ,					callback_steps=_SCREAMING_SNAKE_CASE    ,					)







	@torch.no_grad()
	def  _lowerCAmelCase    (			self							:					Union[str, Any]    ,					_SCREAMING_SNAKE_CASE							:					Union[str, List[str]]    ,					_SCREAMING_SNAKE_CASE							:					int = 512    ,					_SCREAMING_SNAKE_CASE							:					int = 512    ,					_SCREAMING_SNAKE_CASE							:					int = 50    ,					_SCREAMING_SNAKE_CASE							:					float = 7.5    ,					_SCREAMING_SNAKE_CASE							:					Optional[Union[str, List[str]]] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[int] = 1    ,					_SCREAMING_SNAKE_CASE							:					float = 0.0    ,					_SCREAMING_SNAKE_CASE							:					Optional[torch.Generator] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[torch.FloatTensor] = None    ,					_SCREAMING_SNAKE_CASE							:					Optional[str] = "pil"    ,					_SCREAMING_SNAKE_CASE							:					bool = True    ,					_SCREAMING_SNAKE_CASE							:					Optional[Callable[[int, int, torch.FloatTensor], None]] = None    ,					_SCREAMING_SNAKE_CASE							:					int = 1    ,					)	->  List[Any]:





					"""simple docstring"""


					return StableDiffusionPipeline(**self.components						)(
					    prompt=_SCREAMING_SNAKE_CASE    ,					height=_SCREAMING_SNAKE_CASE    ,					width=_SCREAMING_SNAKE_CASE    ,					num_inference_steps=_SCREAMING_SNAKE_CASE    ,					guidance_scale=_SCREAMING_SNAKE_CASE    ,					negative_prompt=_SCREAMING_SNAKE_CASE    ,					num_images_per_prompt=_SCREAMING_SNAKE_CASE    ,					eta=_SCREAMING_SNAKE_CASE    ,					generator=_SCREAMING_SNAKE_CASE    ,					latents=_SCREAMING_SNAKE_CASE    ,					output_type=_SCREAMING_SNAKE_CASE    ,					return_dict=_SCREAMING_SNAKE_CASE    ,					callback=_SCREAMING_SNAKE_CASE    ,					callback_steps=_SCREAMING_SNAKE_CASE    ,					)










"""simple docstring"""

import warnings

from ...utils import logging
from .image_processing_convnext import ConvNextImageProcessor


A_	:						Any				=			logging.get_logger(__name__)
class 						lowerCAmelCase__	(  _lowerCamelCase   ):


	'''simple docstring'''







	def __init__(			self							:					Tuple    ,					*_SCREAMING_SNAKE_CASE							:					Optional[int]    ,					**_SCREAMING_SNAKE_CASE							:					Optional[int]						)	->  None:





					"""simple docstring"""


					warnings.warn(
					    'The class ConvNextFeatureExtractor is deprecated and will be removed in version 5 of Transformers.'
					    ' Please use ConvNextImageProcessor instead.'    ,					_SCREAMING_SNAKE_CASE    ,					)
					super().__init__(*_SCREAMING_SNAKE_CASE    ,					**_SCREAMING_SNAKE_CASE						)





