





'''simple docstring'''


def       A							(      _UpperCAmelCase   :				float						,_UpperCAmelCase   :				float						,_UpperCAmelCase   :				float					)  ->				list[int]:


  '''simple docstring'''




  if hue < 0 or hue > 3_6_0:
    raise Exception('hue should be between 0 and 360'					)

  if saturation < 0 or saturation > 1:
    raise Exception('saturation should be between 0 and 1'					)

  if value < 0 or value > 1:
    raise Exception('value should be between 0 and 1'					)

  __lowerCAmelCase		:    Tuple			     =  value * saturation
  __lowerCAmelCase		:    Tuple			     =  hue / 6_0
  __lowerCAmelCase		:    Dict			     =  chroma * (1 - abs(hue_section % 2 - 1					))
  __lowerCAmelCase		:    List[Any]			     =  value - chroma

  if hue_section >= 0 and hue_section <= 1:
    __lowerCAmelCase		:    Union[str, Any]			     =  round(2_5_5 * (chroma + match_value)					)
    __lowerCAmelCase		:    Any			     =  round(2_5_5 * (second_largest_component + match_value)					)
    __lowerCAmelCase		:    Optional[int]			     =  round(2_5_5 * (match_value)					)
  elif hue_section > 1 and hue_section <= 2:
    __lowerCAmelCase		:    Dict			     =  round(2_5_5 * (second_largest_component + match_value)					)
    __lowerCAmelCase		:    Tuple			     =  round(2_5_5 * (chroma + match_value)					)
    __lowerCAmelCase		:    int			     =  round(2_5_5 * (match_value)					)
  elif hue_section > 2 and hue_section <= 3:
    __lowerCAmelCase		:    List[Any]			     =  round(2_5_5 * (match_value)					)
    __lowerCAmelCase		:    str			     =  round(2_5_5 * (chroma + match_value)					)
    __lowerCAmelCase		:    Optional[Any]			     =  round(2_5_5 * (second_largest_component + match_value)					)
  elif hue_section > 3 and hue_section <= 4:
    __lowerCAmelCase		:    Optional[int]			     =  round(2_5_5 * (match_value)					)
    __lowerCAmelCase		:    Union[str, Any]			     =  round(2_5_5 * (second_largest_component + match_value)					)
    __lowerCAmelCase		:    int			     =  round(2_5_5 * (chroma + match_value)					)
  elif hue_section > 4 and hue_section <= 5:
    __lowerCAmelCase		:    Tuple			     =  round(2_5_5 * (second_largest_component + match_value)					)
    __lowerCAmelCase		:    Union[str, Any]			     =  round(2_5_5 * (match_value)					)
    __lowerCAmelCase		:    str			     =  round(2_5_5 * (chroma + match_value)					)
  else:
    __lowerCAmelCase		:    Union[str, Any]			     =  round(2_5_5 * (chroma + match_value)					)
    __lowerCAmelCase		:    int			     =  round(2_5_5 * (match_value)					)
    __lowerCAmelCase		:    int			     =  round(2_5_5 * (second_largest_component + match_value)					)

  return [red, green, blue]




def       A							(      _UpperCAmelCase   :				int						,_UpperCAmelCase   :				int						,_UpperCAmelCase   :				int					)  ->				list[float]:


  '''simple docstring'''




  if red < 0 or red > 2_5_5:
    raise Exception('red should be between 0 and 255'					)

  if green < 0 or green > 2_5_5:
    raise Exception('green should be between 0 and 255'					)

  if blue < 0 or blue > 2_5_5:
    raise Exception('blue should be between 0 and 255'					)

  __lowerCAmelCase		:    int			     =  red / 2_5_5
  __lowerCAmelCase		:    Dict			     =  green / 2_5_5
  __lowerCAmelCase		:    List[str]			     =  blue / 2_5_5
  __lowerCAmelCase		:    int			     =  max(_UpperCAmelCase						,_UpperCAmelCase						,_UpperCAmelCase					)
  __lowerCAmelCase		:    List[Any]			     =  value - min(_UpperCAmelCase						,_UpperCAmelCase						,_UpperCAmelCase					)
  __lowerCAmelCase		:    List[str]			     =  0 if value == 0 else chroma / value

  if chroma == 0:
    __lowerCAmelCase		:    Tuple			     =  0.0
  elif value == float_red:
    __lowerCAmelCase		:    Optional[int]			     =  6_0 * (0 + (float_green - float_blue) / chroma)
  elif value == float_green:
    __lowerCAmelCase		:    int			     =  6_0 * (2 + (float_blue - float_red) / chroma)
  else:
    __lowerCAmelCase		:    Tuple			     =  6_0 * (4 + (float_red - float_green) / chroma)

  __lowerCAmelCase		:    int			     =  (hue + 3_6_0) % 3_6_0

  return [hue, saturation, value]




def       A							(      _UpperCAmelCase   :				list[float]						,_UpperCAmelCase   :				list[float]					)  ->				bool:


  '''simple docstring'''




  __lowerCAmelCase		:    List[str]			     =  abs(hsv_a[0] - hsv_a[0]					) < 0.2
  __lowerCAmelCase		:    Tuple			     =  abs(hsv_a[1] - hsv_a[1]					) < 0.002
  __lowerCAmelCase		:    Optional[Any]			     =  abs(hsv_a[2] - hsv_a[2]					) < 0.002

  return check_hue and check_saturation and check_value












'''simple docstring'''


from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


A_				     =							{
    "configuration_sam": [
        "SAM_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "SamConfig",
        "SamMaskDecoderConfig",
        "SamPromptEncoderConfig",
        "SamVisionConfig",
    ],
    "processing_sam": ["SamProcessor"],
}


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							[
        "SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
        "SamModel",
        "SamPreTrainedModel",
    ]
try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							[
        "TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
        "TFSamModel",
        "TFSamPreTrainedModel",
    ]
try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A_				     =							["SamImageProcessor"]


if TYPE_CHECKING:
    from .configuration_sam import (
        SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
        SamConfig,
        SamMaskDecoderConfig,
        SamPromptEncoderConfig,
        SamVisionConfig,
    )
    from .processing_sam import SamProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .image_processing_sam import SamImageProcessor

else:
    import sys

    A_				     =							_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)





