




"""simple docstring"""







import argparse
import json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import ConvNextConfig, ConvNextForImageClassification, ConvNextImageProcessor
from transformers.utils import logging


logging.set_verbosity_info()
a								=							logging.get_logger(__name__)





def 							lowercase   (snake_case__				:	List[Any]	)       ->					List[Any]:


				'''simple docstring'''






				lowerCAmelCase		=			ConvNextConfig()

				if "tiny" in checkpoint_url:
								lowerCAmelCase		=			[3, 3, 9, 3]
								lowerCAmelCase		=			[96, 192, 384, 768]
				if "small" in checkpoint_url:
								lowerCAmelCase		=			[3, 3, 27, 3]
								lowerCAmelCase		=			[96, 192, 384, 768]
				if "base" in checkpoint_url:
								lowerCAmelCase		=			[3, 3, 27, 3]
								lowerCAmelCase		=			[128, 256, 512, 1_024]
				if "large" in checkpoint_url:
								lowerCAmelCase		=			[3, 3, 27, 3]
								lowerCAmelCase		=			[192, 384, 768, 1_536]
				if "xlarge" in checkpoint_url:
								lowerCAmelCase		=			[3, 3, 27, 3]
								lowerCAmelCase		=			[256, 512, 1_024, 2_048]

				if "1k" in checkpoint_url:
								lowerCAmelCase		=			1_000
								lowerCAmelCase		=			"""imagenet-1k-id2label.json"""
								lowerCAmelCase		=			(1, 1_000)
				else:
								lowerCAmelCase		=			21_841
								lowerCAmelCase		=			"""imagenet-22k-id2label.json"""
								lowerCAmelCase		=			(1, 21_841)

				lowerCAmelCase		=			"""huggingface/label-files"""
				lowerCAmelCase		=			num_labels
				lowerCAmelCase		=			json.load(open(hf_hub_download(snake_case__ ,    snake_case__ ,    repo_type="""dataset"""	) ,    """r"""	)	)
				lowerCAmelCase		=			{int(snake_case__	): v for k, v in idalabel.items()}
				if "1k" not in checkpoint_url:
								# this dataset contains 21843 labels but the model only has 21841
								# we delete the classes as mentioned in https://github.com/google-research/big_transfer/issues/18
								del idalabel[9_205]
								del idalabel[15_027]
				lowerCAmelCase		=			idalabel
				lowerCAmelCase		=			{v: k for k, v in idalabel.items()}
				lowerCAmelCase		=			hidden_sizes
				lowerCAmelCase		=			depths

				return config, expected_shape





def 							lowercase   (snake_case__				:	str	)       ->					List[Any]:


				'''simple docstring'''






				if "downsample_layers.0.0" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.0.0""" ,    """embeddings.patch_embeddings"""	)
				if "downsample_layers.0.1" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.0.1""" ,    """embeddings.norm"""	)  # we rename to layernorm later on
				if "downsample_layers.1.0" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.1.0""" ,    """stages.1.downsampling_layer.0"""	)
				if "downsample_layers.1.1" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.1.1""" ,    """stages.1.downsampling_layer.1"""	)
				if "downsample_layers.2.0" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.2.0""" ,    """stages.2.downsampling_layer.0"""	)
				if "downsample_layers.2.1" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.2.1""" ,    """stages.2.downsampling_layer.1"""	)
				if "downsample_layers.3.0" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.3.0""" ,    """stages.3.downsampling_layer.0"""	)
				if "downsample_layers.3.1" in name:
								lowerCAmelCase		=			name.replace("""downsample_layers.3.1""" ,    """stages.3.downsampling_layer.1"""	)
				if "stages" in name and "downsampling_layer" not in name:
								# stages.0.0. for instance should be renamed to stages.0.layers.0.
								lowerCAmelCase		=			name[: len("""stages.0"""	)] + """.layers""" + name[len("""stages.0"""	) :]
				if "stages" in name:
								lowerCAmelCase		=			name.replace("""stages""" ,    """encoder.stages"""	)
				if "norm" in name:
								lowerCAmelCase		=			name.replace("""norm""" ,    """layernorm"""	)
				if "gamma" in name:
								lowerCAmelCase		=			name.replace("""gamma""" ,    """layer_scale_parameter"""	)
				if "head" in name:
								lowerCAmelCase		=			name.replace("""head""" ,    """classifier"""	)

				return name





def 							lowercase   ()       ->					Optional[Any]:


				'''simple docstring'''






				lowerCAmelCase		=			"""http://images.cocodataset.org/val2017/000000039769.jpg"""
				lowerCAmelCase		=			Image.open(requests.get(snake_case__ ,    stream=snake_case__	).raw	)
				return im





@torch.no_grad()
def 							lowercase   (snake_case__				:	List[str] ,    snake_case__				:	Union[str, Any]	)       ->					str:


				'''simple docstring'''






				lowerCAmelCase	,  lowerCAmelCase		=			get_convnext_config(snake_case__	)
				# load original state_dict from URL
				lowerCAmelCase		=			torch.hub.load_state_dict_from_url(snake_case__	)["""model"""]
				# rename keys
				for key in state_dict.copy().keys():
								lowerCAmelCase		=			state_dict.pop(snake_case__	)
								lowerCAmelCase		=			val
				# add prefix to all keys expect classifier head
				for key in state_dict.copy().keys():
								lowerCAmelCase		=			state_dict.pop(snake_case__	)
								if not key.startswith("""classifier"""	):
												lowerCAmelCase		=			"""convnext.""" + key
								lowerCAmelCase		=			val

				# load HuggingFace model
				lowerCAmelCase		=			ConvNextForImageClassification(snake_case__	)
				model.load_state_dict(snake_case__	)
				model.eval()

				# Check outputs on an image, prepared by ConvNextImageProcessor
				lowerCAmelCase		=			224 if """224""" in checkpoint_url else 384
				lowerCAmelCase		=			ConvNextImageProcessor(size=snake_case__	)
				lowerCAmelCase		=			image_processor(images=prepare_img() ,    return_tensors="""pt"""	).pixel_values

				lowerCAmelCase		=			model(snake_case__	).logits

				# note: the logits below were obtained without center cropping
				if checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth":
								lowerCAmelCase		=			torch.tensor([-0.1_210, -0.6_605, 0.1_918]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_small_1k_224_ema.pth":
								lowerCAmelCase		=			torch.tensor([-0.4_473, -0.1_847, -0.6_365]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_224_ema.pth":
								lowerCAmelCase		=			torch.tensor([0.4_525, 0.7_539, 0.0_308]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_1k_384.pth":
								lowerCAmelCase		=			torch.tensor([0.3_561, 0.6_350, -0.0_384]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_224_ema.pth":
								lowerCAmelCase		=			torch.tensor([0.4_174, -0.0_989, 0.1_489]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_1k_384.pth":
								lowerCAmelCase		=			torch.tensor([0.2_513, -0.1_349, -0.1_613]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_224.pth":
								lowerCAmelCase		=			torch.tensor([1.2_980, 0.3_631, -0.1_198]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_224.pth":
								lowerCAmelCase		=			torch.tensor([1.2_963, 0.1_227, 0.1_723]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_224.pth":
								lowerCAmelCase		=			torch.tensor([1.7_956, 0.8_390, 0.2_820]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_224.pth":
								lowerCAmelCase		=			torch.tensor([-0.2_822, -0.0_502, -0.0_878]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_base_22k_1k_384.pth":
								lowerCAmelCase		=			torch.tensor([-0.5_672, -0.0_730, -0.4_348]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_224.pth":
								lowerCAmelCase		=			torch.tensor([0.2_681, 0.2_365, 0.6_246]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_large_22k_1k_384.pth":
								lowerCAmelCase		=			torch.tensor([-0.2_642, 0.3_931, 0.5_116]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_224_ema.pth":
								lowerCAmelCase		=			torch.tensor([-0.6_677, -0.1_873, -0.8_379]	)
				elif checkpoint_url == "https://dl.fbaipublicfiles.com/convnext/convnext_xlarge_22k_1k_384_ema.pth":
								lowerCAmelCase		=			torch.tensor([-0.7_749, -0.2_967, -0.6_444]	)
				else:
								raise ValueError(f'''Unknown URL: {checkpoint_url}'''	)

				assert torch.allclose(logits[0, :3] ,    snake_case__ ,    atol=1e-3	)
				assert logits.shape == expected_shape

				Path(snake_case__	).mkdir(exist_ok=snake_case__	)
				print(f'''Saving model to {pytorch_dump_folder_path}'''	)
				model.save_pretrained(snake_case__	)
				print(f'''Saving image processor to {pytorch_dump_folder_path}'''	)
				image_processor.save_pretrained(snake_case__	)

				print("""Pushing model to the hub..."""	)
				lowerCAmelCase		=			"""convnext"""
				if "tiny" in checkpoint_url:
								model_name += "-tiny"
				elif "small" in checkpoint_url:
								model_name += "-small"
				elif "base" in checkpoint_url:
								model_name += "-base"
				elif "xlarge" in checkpoint_url:
								model_name += "-xlarge"
				elif "large" in checkpoint_url:
								model_name += "-large"
				if "224" in checkpoint_url:
								model_name += "-224"
				elif "384" in checkpoint_url:
								model_name += "-384"
				if "22k" in checkpoint_url and "1k" not in checkpoint_url:
								model_name += "-22k"
				if "22k" in checkpoint_url and "1k" in checkpoint_url:
								model_name += "-22k-1k"

				model.push_to_hub(
				    repo_path_or_name=Path(snake_case__ ,    snake_case__	) ,    organization="""nielsr""" ,    commit_message="""Add model""" ,    )


if __name__ == "__main__":
		a								=							argparse.ArgumentParser()
		# Required parameters
		parser.add_argument(
		    '--checkpoint_url',
		    default='https://dl.fbaipublicfiles.com/convnext/convnext_tiny_1k_224_ema.pth',
		    type=str,
		    help='URL of the original ConvNeXT checkpoint you\'d like to convert.',
		)
		parser.add_argument(
		    '--pytorch_dump_folder_path',
		    default=None,
		    type=str,
		    required=True,
		    help='Path to the output PyTorch model directory.',
		)

		a								=							parser.parse_args()
		convert_convnext_checkpoint(args.checkpoint_url, args.pytorch_dump_folder_path)











"""simple docstring"""







import colorsys
import io

import cva
import matplotlib as mpl
import matplotlib.colors as mplc
import matplotlib.figure as mplfigure
import numpy as np
import torch
from matplotlib.backends.backend_agg import FigureCanvasAgg

from utils import img_tensorize


a								=							1_0_0_0






class  SCREAMING_SNAKE_CASE__   :


						def __init__(							self			:     Any  ,  lowerCAmelCase			:     List[Any]  ,  lowerCAmelCase			:     Tuple=1.2  ,  lowerCAmelCase			:     str="g"  ,  lowerCAmelCase			:     List[Any]=0.5  ,  lowerCAmelCase			:     List[Any]="-"  ,  lowerCAmelCase			:     Optional[int]="test_out.jpg"  ,  lowerCAmelCase			:     Union[str, Any]=True  ,  lowerCAmelCase			:     Tuple=False  ,  lowerCAmelCase			:     Optional[int]=None  ,  lowerCAmelCase			:     Tuple=None  ,  lowerCAmelCase			:     str=0.7  ,  ):
										if isinstance(lowerCAmelCase  ,  torch.Tensor   ):
														lowerCAmelCase		=			img.numpy().astype("""np.uint8"""   )
										if isinstance(lowerCAmelCase  ,  lowerCAmelCase   ):
														lowerCAmelCase		=			img_tensorize(lowerCAmelCase   )
										assert isinstance(lowerCAmelCase  ,  np.ndarray   )

										lowerCAmelCase	,  lowerCAmelCase		=			img.shape[1], img.shape[0]
										lowerCAmelCase		=			mplfigure.Figure(frameon=lowerCAmelCase   )
										lowerCAmelCase		=			fig.get_dpi()
										lowerCAmelCase		=			(width * scale + 1e-2) / dpi
										lowerCAmelCase		=			(height * scale + 1e-2) / dpi
										fig.set_size_inches(lowerCAmelCase  ,  lowerCAmelCase   )
										lowerCAmelCase		=			fig.add_axes([0.0, 0.0, 1.0, 1.0]   )
										ax.axis("""off"""   )
										ax.set_xlim(0.0  ,  lowerCAmelCase   )
										ax.set_ylim(lowerCAmelCase   )

										lowerCAmelCase		=			saveas
										lowerCAmelCase		=			rgb
										lowerCAmelCase		=			pynb
										lowerCAmelCase		=			img
										lowerCAmelCase		=			edgecolor
										lowerCAmelCase		=			0.5
										lowerCAmelCase		=			linestyle
										lowerCAmelCase		=			int(np.sqrt(min(lowerCAmelCase  ,  lowerCAmelCase   )   ) * scale // 3   )
										lowerCAmelCase		=			width
										lowerCAmelCase		=			height
										lowerCAmelCase		=			scale
										lowerCAmelCase		=			fig
										lowerCAmelCase		=			ax
										lowerCAmelCase		=			pad
										lowerCAmelCase		=			idaobj
										lowerCAmelCase		=			idaattr
										lowerCAmelCase		=			FigureCanvasAgg(lowerCAmelCase   )


						def 					__lowercase	(							self			:     str  ,  lowerCAmelCase			:     Optional[int]  ,  lowerCAmelCase			:     List[str]=None   ):
										if color is None:
														lowerCAmelCase		=			self.edgecolor
										((lowerCAmelCase)	,  (lowerCAmelCase)	,  (lowerCAmelCase)	,  (lowerCAmelCase))		=			box
										lowerCAmelCase		=			xa - xa
										lowerCAmelCase		=			ya - ya
										self.ax.add_patch(
										    mpl.patches.Rectangle(
										        (xa, ya)  ,  lowerCAmelCase  ,  lowerCAmelCase  ,  fill=lowerCAmelCase  ,  edgecolor=lowerCAmelCase  ,  linewidth=self.font_size // 3  ,  alpha=self.alpha  ,  linestyle=self.linestyle  ,  )   )


						def 					__lowercase	(							self			:     int  ,  lowerCAmelCase			:     Any  ,  lowerCAmelCase			:     int=None  ,  lowerCAmelCase			:     Tuple=None  ,  lowerCAmelCase			:     Optional[Any]=None  ,  lowerCAmelCase			:     Dict=None   ):
										if len(boxes.shape   ) > 2:
														lowerCAmelCase		=			boxes[0]
										if len(obj_ids.shape   ) > 1:
														lowerCAmelCase		=			obj_ids[0]
										if len(obj_scores.shape   ) > 1:
														lowerCAmelCase		=			obj_scores[0]
										if len(attr_ids.shape   ) > 1:
														lowerCAmelCase		=			attr_ids[0]
										if len(attr_scores.shape   ) > 1:
														lowerCAmelCase		=			attr_scores[0]
										if isinstance(lowerCAmelCase  ,  torch.Tensor   ):
														lowerCAmelCase		=			boxes.numpy()
										if isinstance(lowerCAmelCase  ,  lowerCAmelCase   ):
														lowerCAmelCase		=			np.array(lowerCAmelCase   )
										assert isinstance(lowerCAmelCase  ,  np.ndarray   )
										lowerCAmelCase		=			np.prod(boxes[:, 2:] - boxes[:, :2]  ,  axis=1   )
										lowerCAmelCase		=			np.argsort(-areas   ).tolist()
										lowerCAmelCase		=			boxes[sorted_idxs] if boxes is not None else None
										lowerCAmelCase		=			obj_ids[sorted_idxs] if obj_ids is not None else None
										lowerCAmelCase		=			obj_scores[sorted_idxs] if obj_scores is not None else None
										lowerCAmelCase		=			attr_ids[sorted_idxs] if attr_ids is not None else None
										lowerCAmelCase		=			attr_scores[sorted_idxs] if attr_scores is not None else None

										lowerCAmelCase		=			[self._random_color(maximum=1   ) for _ in range(len(lowerCAmelCase   )   )]
										lowerCAmelCase		=			[assigned_colors[idx] for idx in sorted_idxs]
										if obj_ids is not None:
														lowerCAmelCase		=			self._create_text_labels_attr(lowerCAmelCase  ,  lowerCAmelCase  ,  lowerCAmelCase  ,  lowerCAmelCase   )
														for i in range(len(lowerCAmelCase   )   ):
																		lowerCAmelCase		=			assigned_colors[i]
																		self.add_box(boxes[i]  ,  lowerCAmelCase   )
																		self.draw_labels(labels[i]  ,  boxes[i]  ,  lowerCAmelCase   )


						def 					__lowercase	(							self			:     int  ,  lowerCAmelCase			:     Optional[Any]  ,  lowerCAmelCase			:     Any  ,  lowerCAmelCase			:     Dict   ):
										lowerCAmelCase	,  lowerCAmelCase	,  lowerCAmelCase	,  lowerCAmelCase		=			box
										lowerCAmelCase		=			(xa, ya)
										lowerCAmelCase		=			(ya - ya) * (xa - xa)
										lowerCAmelCase		=			_SMALL_OBJ * self.scale
										if instance_area < small or ya - ya < 40 * self.scale:
														if ya >= self.height - 5:
																		lowerCAmelCase		=			(xa, ya)
														else:
																		lowerCAmelCase		=			(xa, ya)

										lowerCAmelCase		=			(ya - ya) / np.sqrt(self.height * self.width   )
										lowerCAmelCase		=			self._change_color_brightness(lowerCAmelCase  ,  brightness_factor=0.7   )
										lowerCAmelCase		=			np.clip((height_ratio - 0.02) / 0.08 + 1  ,  1.2  ,  2   )
										font_size *= 0.75 * self.font_size

										self.draw_text(
										    text=lowerCAmelCase  ,  position=lowerCAmelCase  ,  color=lowerCAmelCase  ,  )


						def 					__lowercase	(							self			:     str  ,  lowerCAmelCase			:     List[str]  ,  lowerCAmelCase			:     Optional[int]  ,  lowerCAmelCase			:     Optional[int]="g"  ,  lowerCAmelCase			:     Optional[int]="left"  ,  ):
										lowerCAmelCase		=			0
										lowerCAmelCase		=			self.font_size
										lowerCAmelCase		=			np.maximum(list(mplc.to_rgb(lowerCAmelCase   )   )  ,  0.2   )
										lowerCAmelCase		=			max(0.8  ,  np.max(lowerCAmelCase   )   )
										lowerCAmelCase		=			{
										    """facecolor""": """black""",
										    """alpha""": self.alpha,
										    """pad""": self.pad,
										    """edgecolor""": """none""",
										}
										lowerCAmelCase	,  lowerCAmelCase		=			position
										self.ax.text(
										    lowerCAmelCase  ,  lowerCAmelCase  ,  lowerCAmelCase  ,  size=font_size * self.scale  ,  family="""sans-serif"""  ,  bbox=lowerCAmelCase  ,  verticalalignment="""top"""  ,  horizontalalignment=lowerCAmelCase  ,  color=lowerCAmelCase  ,  zorder=10  ,  rotation=lowerCAmelCase  ,  )


						def 					__lowercase	(							self			:     str  ,  lowerCAmelCase			:     Tuple=None   ):
										if saveas is None:
														lowerCAmelCase		=			self.saveas
										if saveas.lower().endswith(""".jpg"""   ) or saveas.lower().endswith(""".png"""   ):
														cva.imwrite(
														    lowerCAmelCase  ,  self._get_buffer()[:, :, ::-1]  ,  )
										else:
														self.fig.savefig(lowerCAmelCase   )


						def 					__lowercase	(							self			:     str  ,  lowerCAmelCase			:     int  ,  lowerCAmelCase			:     List[str]  ,  lowerCAmelCase			:     Any  ,  lowerCAmelCase			:     Optional[Any]   ):
										lowerCAmelCase		=			[self.idaobj[i] for i in classes]
										lowerCAmelCase		=			[self.idaattr[i] for i in attr_classes]
										lowerCAmelCase		=			[
										    f'''{label} {score:.2f} {attr} {attr_score:.2f}'''
										    for label, score, attr, attr_score in zip(lowerCAmelCase  ,  lowerCAmelCase  ,  lowerCAmelCase  ,  lowerCAmelCase   )
										]
										return labels


						def 					__lowercase	(							self			:     Any  ,  lowerCAmelCase			:     Dict  ,  lowerCAmelCase			:     Union[str, Any]   ):
										lowerCAmelCase		=			[self.idaobj[i] for i in classes]
										if scores is not None:
														if labels is None:
																		lowerCAmelCase		=			["""{:.0f}%""".format(s * 100   ) for s in scores]
														else:
																		lowerCAmelCase		=			["""{} {:.0f}%""".format(lowerCAmelCase  ,  s * 100   ) for li, s in zip(lowerCAmelCase  ,  lowerCAmelCase   )]
										return labels


						def 					__lowercase	(							self			:     Any  ,  lowerCAmelCase			:     str=255   ):
										lowerCAmelCase		=			np.random.randint(0  ,  len(_COLORS   )   )
										lowerCAmelCase		=			_COLORS[idx] * maximum
										if not self.rgb:
														lowerCAmelCase		=			ret[::-1]
										return ret


						def 					__lowercase	(							self			:     List[str]   ):
										if not self.pynb:
														lowerCAmelCase	,  lowerCAmelCase		=			self.canvas.print_to_buffer()
														if (width, height) != (self.width, self.height):
																		lowerCAmelCase		=			cva.resize(self.img  ,  (width, height)   )
														else:
																		lowerCAmelCase		=			self.img
										else:
														lowerCAmelCase		=			io.BytesIO()  # works for cairo backend
														self.canvas.print_rgba(lowerCAmelCase   )
														lowerCAmelCase	,  lowerCAmelCase		=			self.width, self.height
														lowerCAmelCase		=			buf.getvalue()
														lowerCAmelCase		=			self.img

										lowerCAmelCase		=			np.frombuffer(lowerCAmelCase  ,  dtype="""uint8"""   )
										lowerCAmelCase		=			buffer.reshape(lowerCAmelCase  ,  lowerCAmelCase  ,  4   )
										lowerCAmelCase	,  lowerCAmelCase		=			np.split(lowerCAmelCase  ,  [3]  ,  axis=2   )

										try:
														import numexpr as ne  # fuse them with numexpr

														lowerCAmelCase		=			ne.evaluate("""img * (1 - alpha / 255.0) + rgb * (alpha / 255.0)"""   )
										except ImportError:
														lowerCAmelCase		=			alpha.astype("""float32"""   ) / 255.0
														lowerCAmelCase		=			img * (1 - alpha) + rgb * alpha

										return visualized_image.astype("""uint8"""   )




						def 					__lowercase	(							self			:     List[str]  ,  lowerCAmelCase			:     Optional[Any]  ,  lowerCAmelCase			:     Optional[int]   ):
										assert brightness_factor >= -1.0 and brightness_factor <= 1.0
										lowerCAmelCase		=			mplc.to_rgb(lowerCAmelCase   )
										lowerCAmelCase		=			colorsys.rgb_to_hls(*mplc.to_rgb(lowerCAmelCase   )   )
										lowerCAmelCase		=			polygon_color[1] + (brightness_factor * polygon_color[1])
										lowerCAmelCase		=			0.0 if modified_lightness < 0.0 else modified_lightness
										lowerCAmelCase		=			1.0 if modified_lightness > 1.0 else modified_lightness
										lowerCAmelCase		=			colorsys.hls_to_rgb(polygon_color[0]  ,  lowerCAmelCase  ,  polygon_color[2]   )
										return modified_color





a								=							(
    np.array(
        [
            0.000,
            0.447,
            0.741,
            0.850,
            0.325,
            0.098,
            0.929,
            0.694,
            0.125,
            0.494,
            0.184,
            0.556,
            0.466,
            0.674,
            0.188,
            0.301,
            0.745,
            0.933,
            0.635,
            0.078,
            0.184,
            0.300,
            0.300,
            0.300,
            0.600,
            0.600,
            0.600,
            1.000,
            0.000,
            0.000,
            1.000,
            0.500,
            0.000,
            0.749,
            0.749,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.333,
            0.333,
            0.000,
            0.333,
            0.667,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            0.333,
            0.000,
            0.667,
            0.667,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.667,
            0.000,
            1.000,
            1.000,
            0.000,
            0.000,
            0.333,
            0.500,
            0.000,
            0.667,
            0.500,
            0.000,
            1.000,
            0.500,
            0.333,
            0.000,
            0.500,
            0.333,
            0.333,
            0.500,
            0.333,
            0.667,
            0.500,
            0.333,
            1.000,
            0.500,
            0.667,
            0.000,
            0.500,
            0.667,
            0.333,
            0.500,
            0.667,
            0.667,
            0.500,
            0.667,
            1.000,
            0.500,
            1.000,
            0.000,
            0.500,
            1.000,
            0.333,
            0.500,
            1.000,
            0.667,
            0.500,
            1.000,
            1.000,
            0.500,
            0.000,
            0.333,
            1.000,
            0.000,
            0.667,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            0.000,
            1.000,
            0.333,
            0.333,
            1.000,
            0.333,
            0.667,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            0.000,
            1.000,
            0.667,
            0.333,
            1.000,
            0.667,
            0.667,
            1.000,
            0.667,
            1.000,
            1.000,
            1.000,
            0.000,
            1.000,
            1.000,
            0.333,
            1.000,
            1.000,
            0.667,
            1.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.167,
            0.000,
            0.000,
            0.333,
            0.000,
            0.000,
            0.500,
            0.000,
            0.000,
            0.667,
            0.000,
            0.000,
            0.833,
            0.000,
            0.000,
            1.000,
            0.000,
            0.000,
            0.000,
            0.143,
            0.143,
            0.143,
            0.857,
            0.857,
            0.857,
            1.000,
            1.000,
            1.000,
        ]
    )
    .astype(np.floataa)
    .reshape(-1, 3)
)





