





"""simple docstring"""






import gc
import unittest

import numpy as np
import torch
from transformers import CLIPTextConfig, CLIPTextModel, CLIPTokenizer

from diffusers import (
    AutoencoderKL,
    DDIMScheduler,
    EulerAncestralDiscreteScheduler,
    LMSDiscreteScheduler,
    PNDMScheduler,
    StableDiffusionPanoramaPipeline,
    UNetaDConditionModel,
)
from diffusers.utils import slow, torch_device
from diffusers.utils.testing_utils import enable_full_determinism, require_torch_gpu, skip_mps

from ..pipeline_params import TEXT_TO_IMAGE_BATCH_PARAMS, TEXT_TO_IMAGE_IMAGE_PARAMS, TEXT_TO_IMAGE_PARAMS
from ..test_pipelines_common import PipelineLatentTesterMixin, PipelineTesterMixin


enable_full_determinism()




@skip_mps
class 			__lowercase     (     __lowercase				, __lowercase				, unittest.TestCase							):







					'''simple docstring'''




					__lowerCAmelCase					=					StableDiffusionPanoramaPipeline
					__lowerCAmelCase					=					TEXT_TO_IMAGE_PARAMS
					__lowerCAmelCase					=					TEXT_TO_IMAGE_BATCH_PARAMS
					__lowerCAmelCase					=					TEXT_TO_IMAGE_IMAGE_PARAMS
					__lowerCAmelCase					=					TEXT_TO_IMAGE_IMAGE_PARAMS







					def 	_lowerCamelCase						(  self       ):
									torch.manual_seed(0       )
									__a	:  Optional[int]         =					UNetaDConditionModel(
									    block_out_channels=(32, 64)		,     layers_per_block=1		,     sample_size=32		,     in_channels=4		,     out_channels=4		,     down_block_types=('''DownBlock2D''', '''CrossAttnDownBlock2D''')		,     up_block_types=('''CrossAttnUpBlock2D''', '''UpBlock2D''')		,     cross_attention_dim=32		,     )
									__a	:  Optional[int]         =					DDIMScheduler()
									torch.manual_seed(0       )
									__a	:  Tuple         =					AutoencoderKL(
									    block_out_channels=[32, 64]		,     in_channels=3		,     out_channels=3		,     down_block_types=['''DownEncoderBlock2D''', '''DownEncoderBlock2D''']		,     up_block_types=['''UpDecoderBlock2D''', '''UpDecoderBlock2D''']		,     latent_channels=4		,     )
									torch.manual_seed(0       )
									__a	:  Optional[Any]         =					CLIPTextConfig(
									    bos_token_id=0		,     eos_token_id=2		,     hidden_size=32		,     intermediate_size=37		,     layer_norm_eps=1e-0_5		,     num_attention_heads=4		,     num_hidden_layers=5		,     pad_token_id=1		,     vocab_size=1000		,     )
									__a	:  Optional[Any]         =					CLIPTextModel(_UpperCAmelCase       )
									__a	:  Optional[int]         =					CLIPTokenizer.from_pretrained('''hf-internal-testing/tiny-random-clip'''       )

									__a	:  List[str]         =					{
									    """unet""": unet,
									    """scheduler""": scheduler,
									    """vae""": vae,
									    """text_encoder""": text_encoder,
									    """tokenizer""": tokenizer,
									    """safety_checker""": None,
									    """feature_extractor""": None,
									}
									return components







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase		,     _UpperCAmelCase=0       ):
									__a	:  str         =					torch.manual_seed(_UpperCAmelCase       )
									__a	:  List[Any]         =					{
									    """prompt""": """a photo of the dolomites""",
									    """generator""": generator,
									    # Setting height and width to None to prevent OOMs on CPU.
									    """height""": None,
									    """width""": None,
									    """num_inference_steps""": 1,
									    """guidance_scale""": 6.0,
									    """output_type""": """numpy""",
									}
									return inputs







					def 	_lowerCamelCase						(  self       ):
									__a	:  str         =					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
									__a	:  List[str]         =					self.get_dummy_components()
									__a	:  List[str]         =					StableDiffusionPanoramaPipeline(**_UpperCAmelCase       )
									__a	:  Any         =					sd_pipe.to(_UpperCAmelCase       )
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

									__a	:  List[Any]         =					self.get_dummy_inputs(_UpperCAmelCase       )
									__a	:  Union[str, Any]         =					sd_pipe(**_UpperCAmelCase       ).images
									__a	:  Any         =					image[0, -3:, -3:, -1]
									assert image.shape == (1, 64, 64, 3)

									__a	:  Union[str, Any]         =					np.array([0.6_1_8_6, 0.5_3_7_4, 0.4_9_1_5, 0.4_1_3_5, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_7, 0.4_7_5_7]       )

									assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2







					def 	_lowerCamelCase						(  self       ):
									super().test_inference_batch_consistent(batch_sizes=[1, 2]       )







					def 	_lowerCamelCase						(  self       ):
									super().test_inference_batch_single_identical(batch_size=2		,     expected_max_diff=3.2_5e-3       )







					def 	_lowerCamelCase						(  self       ):
									__a	:  str         =					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
									__a	:  Optional[Any]         =					self.get_dummy_components()
									__a	:  Optional[Any]         =					StableDiffusionPanoramaPipeline(**_UpperCAmelCase       )
									__a	:  str         =					sd_pipe.to(_UpperCAmelCase       )
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

									__a	:  List[Any]         =					self.get_dummy_inputs(_UpperCAmelCase       )
									__a	:  Optional[int]         =					"""french fries"""
									__a	:  Optional[int]         =					sd_pipe(**_UpperCAmelCase		,     negative_prompt=_UpperCAmelCase       )
									__a	:  Optional[Any]         =					output.images
									__a	:  Tuple         =					image[0, -3:, -3:, -1]

									assert image.shape == (1, 64, 64, 3)

									__a	:  str         =					np.array([0.6_1_8_7, 0.5_3_7_5, 0.4_9_1_5, 0.4_1_3_6, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_6, 0.4_7_5_7]       )

									assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2







					def 	_lowerCamelCase						(  self       ):
									__a	:  Optional[int]         =					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
									__a	:  int         =					self.get_dummy_components()
									__a	:  Dict         =					StableDiffusionPanoramaPipeline(**_UpperCAmelCase       )
									__a	:  Optional[int]         =					sd_pipe.to(_UpperCAmelCase       )
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

									__a	:  int         =					self.get_dummy_inputs(_UpperCAmelCase       )
									__a	:  Optional[Any]         =					sd_pipe(**_UpperCAmelCase		,     view_batch_size=2       )
									__a	:  Optional[int]         =					output.images
									__a	:  Optional[Any]         =					image[0, -3:, -3:, -1]

									assert image.shape == (1, 64, 64, 3)

									__a	:  Any         =					np.array([0.6_1_8_7, 0.5_3_7_5, 0.4_9_1_5, 0.4_1_3_6, 0.4_1_1_4, 0.4_5_6_3, 0.5_1_2_8, 0.4_9_7_6, 0.4_7_5_7]       )

									assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2







					def 	_lowerCamelCase						(  self       ):
									__a	:  Any         =					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
									__a	:  str         =					self.get_dummy_components()
									__a	:  List[Any]         =					EulerAncestralDiscreteScheduler(
									    beta_start=0.0_0_0_8_5		,     beta_end=0.0_1_2		,     beta_schedule='''scaled_linear'''       )
									__a	:  List[Any]         =					StableDiffusionPanoramaPipeline(**_UpperCAmelCase       )
									__a	:  List[str]         =					sd_pipe.to(_UpperCAmelCase       )
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

									__a	:  Tuple         =					self.get_dummy_inputs(_UpperCAmelCase       )
									__a	:  List[Any]         =					sd_pipe(**_UpperCAmelCase       ).images
									__a	:  str         =					image[0, -3:, -3:, -1]

									assert image.shape == (1, 64, 64, 3)

									__a	:  int         =					np.array([0.4_0_2_4, 0.6_5_1_0, 0.4_9_0_1, 0.5_3_7_8, 0.5_8_1_3, 0.5_6_2_2, 0.4_7_9_5, 0.4_4_6_7, 0.4_9_5_2]       )

									assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2







					def 	_lowerCamelCase						(  self       ):
									__a	:  Any         =					"""cpu"""  # ensure determinism for the device-dependent torch.Generator
									__a	:  str         =					self.get_dummy_components()
									__a	:  str         =					PNDMScheduler(
									    beta_start=0.0_0_0_8_5		,     beta_end=0.0_1_2		,     beta_schedule='''scaled_linear'''		,     skip_prk_steps=_UpperCAmelCase       )
									__a	:  Any         =					StableDiffusionPanoramaPipeline(**_UpperCAmelCase       )
									__a	:  List[Any]         =					sd_pipe.to(_UpperCAmelCase       )
									sd_pipe.set_progress_bar_config(disable=_UpperCAmelCase       )

									__a	:  List[Any]         =					self.get_dummy_inputs(_UpperCAmelCase       )
									__a	:  Optional[int]         =					sd_pipe(**_UpperCAmelCase       ).images
									__a	:  Union[str, Any]         =					image[0, -3:, -3:, -1]

									assert image.shape == (1, 64, 64, 3)

									__a	:  Optional[int]         =					np.array([0.6_3_9_1, 0.6_2_9_1, 0.4_8_6_1, 0.5_1_3_4, 0.5_5_5_2, 0.4_5_7_8, 0.5_0_3_2, 0.5_0_2_3, 0.4_5_3_9]       )

									assert np.abs(image_slice.flatten() - expected_slice       ).max() < 1e-2






@slow
@require_torch_gpu
class 			__lowercase     (     unittest.TestCase							):







					'''simple docstring'''




					def 	_lowerCamelCase						(  self       ):
									super().tearDown()
									gc.collect()
									torch.cuda.empty_cache()







					def 	_lowerCamelCase						(  self		,     _UpperCAmelCase=0       ):
									__a	:  List[str]         =					torch.manual_seed(_UpperCAmelCase       )
									__a	:  Dict         =					{
									    """prompt""": """a photo of the dolomites""",
									    """generator""": generator,
									    """num_inference_steps""": 3,
									    """guidance_scale""": 7.5,
									    """output_type""": """numpy""",
									}
									return inputs







					def 	_lowerCamelCase						(  self       ):
									__a	:  Tuple         =					"""stabilityai/stable-diffusion-2-base"""
									__a	:  List[str]         =					DDIMScheduler.from_pretrained(_UpperCAmelCase		,     subfolder='''scheduler'''       )
									__a	:  Dict         =					StableDiffusionPanoramaPipeline.from_pretrained(_UpperCAmelCase		,     scheduler=_UpperCAmelCase		,     safety_checker=_UpperCAmelCase       )
									pipe.to(_UpperCAmelCase       )
									pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
									pipe.enable_attention_slicing()

									__a	:  Any         =					self.get_inputs()
									__a	:  int         =					pipe(**_UpperCAmelCase       ).images
									__a	:  Tuple         =					image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 512, 2048, 3)

									__a	:  Union[str, Any]         =					np.array(
									    [
									        0.3_6_9_6_8_3_9_2,
									        0.2_7_0_2_5_3_7_2,
									        0.3_2_4_4_6_7_6_6,
									        0.2_8_3_7_9_3_8_7,
									        0.3_6_3_6_3_2_7_4,
									        0.3_0_7_3_3_3_4_7,
									        0.2_7_1_0_0_0_2_7,
									        0.2_7_0_5_4_1_2_5,
									        0.2_5_5_3_6_0_9_6,
									    ]       )

									assert np.abs(expected_slice - image_slice       ).max() < 1e-2







					def 	_lowerCamelCase						(  self       ):
									__a	:  Optional[int]         =					StableDiffusionPanoramaPipeline.from_pretrained(
									    '''stabilityai/stable-diffusion-2-base'''		,     safety_checker=_UpperCAmelCase       )
									__a	:  Tuple         =					LMSDiscreteScheduler.from_config(pipe.scheduler.config       )
									pipe.to(_UpperCAmelCase       )
									pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
									pipe.enable_attention_slicing()

									__a	:  Tuple         =					self.get_inputs()
									__a	:  Tuple         =					pipe(**_UpperCAmelCase       ).images
									__a	:  Union[str, Any]         =					image[0, -3:, -3:, -1].flatten()

									assert image.shape == (1, 512, 2048, 3)

									__a	:  Optional[Any]         =					np.array(
									    [
									        [
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									            0.0,
									        ]
									    ]       )

									assert np.abs(expected_slice - image_slice       ).max() < 1e-3







					def 	_lowerCamelCase						(  self       ):
									__a	:  List[str]         =					0

									def callback_fn(_UpperCAmelCase		,     _UpperCAmelCase		,     _UpperCAmelCase       ) -> None:
													__a	:  Union[str, Any]         =					True
													nonlocal number_of_steps
													number_of_steps += 1
													if step == 1:
																	__a	:  List[str]         =					latents.detach().cpu().numpy()
																	assert latents.shape == (1, 4, 64, 256)
																	__a	:  Optional[int]         =					latents[0, -3:, -3:, -1]

																	__a	:  List[str]         =					np.array(
																	    [
																	        0.1_8_6_8_1_8_6_9,
																	        0.3_3_9_0_7_8_1_6,
																	        0.5_3_6_1_2_7_6,
																	        0.1_4_4_3_2_8_6_5,
																	        -0.0_2_8_5_6_6_1_1,
																	        -0.7_3_9_4_1_1_2_3,
																	        0.2_3_3_9_7_9_8_7,
																	        0.4_7_3_2_2_6_8_2,
																	        -0.3_7_8_2_3_1_6_4,
																	    ]       )
																	assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 5e-2
													elif step == 2:
																	__a	:  List[str]         =					latents.detach().cpu().numpy()
																	assert latents.shape == (1, 4, 64, 256)
																	__a	:  int         =					latents[0, -3:, -3:, -1]

																	__a	:  List[str]         =					np.array(
																	    [
																	        0.1_8_5_3_9_6_4_5,
																	        0.3_3_9_8_7_2_4_8,
																	        0.5_3_7_8_5_5_9,
																	        0.1_4_4_3_7_1_4_2,
																	        -0.0_2_4_5_5_2_6_1,
																	        -0.7_3_3_8_3_1_7,
																	        0.2_3_9_9_0_7_5_5,
																	        0.4_7_3_5_6_2_7_2,
																	        -0.3_7_8_6_5_0_5,
																	    ]       )

																	assert np.abs(latents_slice.flatten() - expected_slice       ).max() < 5e-2

									__a	:  Optional[Any]         =					False

									__a	:  List[Any]         =					"""stabilityai/stable-diffusion-2-base"""
									__a	:  Any         =					DDIMScheduler.from_pretrained(_UpperCAmelCase		,     subfolder='''scheduler'''       )
									__a	:  Any         =					StableDiffusionPanoramaPipeline.from_pretrained(_UpperCAmelCase		,     scheduler=_UpperCAmelCase		,     safety_checker=_UpperCAmelCase       )
									__a	:  List[Any]         =					pipe.to(_UpperCAmelCase       )
									pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
									pipe.enable_attention_slicing()

									__a	:  List[Any]         =					self.get_inputs()
									pipe(**_UpperCAmelCase		,     callback=_UpperCAmelCase		,     callback_steps=1       )
									assert callback_fn.has_been_called
									assert number_of_steps == 3







					def 	_lowerCamelCase						(  self       ):
									torch.cuda.empty_cache()
									torch.cuda.reset_max_memory_allocated()
									torch.cuda.reset_peak_memory_stats()

									__a	:  Tuple         =					"""stabilityai/stable-diffusion-2-base"""
									__a	:  int         =					DDIMScheduler.from_pretrained(_UpperCAmelCase		,     subfolder='''scheduler'''       )
									__a	:  Tuple         =					StableDiffusionPanoramaPipeline.from_pretrained(_UpperCAmelCase		,     scheduler=_UpperCAmelCase		,     safety_checker=_UpperCAmelCase       )
									__a	:  int         =					pipe.to(_UpperCAmelCase       )
									pipe.set_progress_bar_config(disable=_UpperCAmelCase       )
									pipe.enable_attention_slicing(1       )
									pipe.enable_sequential_cpu_offload()

									__a	:  Union[str, Any]         =					self.get_inputs()
									__a	:  Union[str, Any]         =					pipe(**_UpperCAmelCase       )

									__a	:  Optional[int]         =					torch.cuda.max_memory_allocated()
									# make sure that less than 5.2 GB is allocated
									assert mem_bytes < 5.5 * 10**9






"""simple docstring"""






import argparse
import re

import numpy as np
import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import (
    SamConfig,
    SamImageProcessor,
    SamModel,
    SamProcessor,
    SamVisionConfig,
)


A	     =					{
    '''iou_prediction_head.layers.0''': '''iou_prediction_head.proj_in''',
    '''iou_prediction_head.layers.1''': '''iou_prediction_head.layers.0''',
    '''iou_prediction_head.layers.2''': '''iou_prediction_head.proj_out''',
    '''mask_decoder.output_upscaling.0''': '''mask_decoder.upscale_conv1''',
    '''mask_decoder.output_upscaling.1''': '''mask_decoder.upscale_layer_norm''',
    '''mask_decoder.output_upscaling.3''': '''mask_decoder.upscale_conv2''',
    '''mask_downscaling.0''': '''mask_embed.conv1''',
    '''mask_downscaling.1''': '''mask_embed.layer_norm1''',
    '''mask_downscaling.3''': '''mask_embed.conv2''',
    '''mask_downscaling.4''': '''mask_embed.layer_norm2''',
    '''mask_downscaling.6''': '''mask_embed.conv3''',
    '''point_embeddings''': '''point_embed''',
    '''pe_layer.positional_encoding_gaussian_matrix''': '''shared_embedding.positional_embedding''',
    '''image_encoder''': '''vision_encoder''',
    '''neck.0''': '''neck.conv1''',
    '''neck.1''': '''neck.layer_norm1''',
    '''neck.2''': '''neck.conv2''',
    '''neck.3''': '''neck.layer_norm2''',
    '''patch_embed.proj''': '''patch_embed.projection''',
    '''.norm''': '''.layer_norm''',
    '''blocks''': '''layers''',
}

def       __A (     a_  :List[Any])						->						List[Any]:
				__a	:  List[Any]         =					{}
				state_dict.pop('''pixel_mean'''				,    a_)
				state_dict.pop('''pixel_std'''				,    a_)

				__a	:  List[Any]         =					R'''.*.output_hypernetworks_mlps.(\d+).layers.(\d+).*'''

				for key, value in state_dict.items():
								for key_to_modify, new_key in KEYS_TO_MODIFY_MAPPING.items():
												if key_to_modify in key:
																__a	:  int         =					key.replace(a_				,    a_)

								if re.match(a_				,    a_):
												__a	:  Optional[Any]         =					int(re.match(a_				,    a_).group(2))
												if layer_nb == 0:
																__a	:  Any         =					key.replace('''layers.0'''				,    '''proj_in''')
												elif layer_nb == 1:
																__a	:  Dict         =					key.replace('''layers.1'''				,    '''layers.0''')
												elif layer_nb == 2:
																__a	:  Optional[int]         =					key.replace('''layers.2'''				,    '''proj_out''')

								__a	:  int         =					value

				__a	:  Union[str, Any]         =					model_state_dict[
				    '''prompt_encoder.shared_embedding.positional_embedding'''
				]

				return model_state_dict

def       __A (     a_  :Optional[int]				,    a_  :Optional[Any]				,    a_  :Dict				,    a_  :Optional[int]="ybelkada/segment-anything")						->						Dict:
				__a	:  Dict         =					hf_hub_download(a_				,    F"""checkpoints/{model_name}.pth""")

				if "sam_vit_b" in model_name:
								__a	:  List[str]         =					SamConfig()
				elif "sam_vit_l" in model_name:
								__a	:  List[Any]         =					SamVisionConfig(
								    hidden_size=10_24				,    num_hidden_layers=24				,    num_attention_heads=16				,    global_attn_indexes=[5, 11, 17, 23]				,    )

								__a	:  List[Any]         =					SamConfig(
								    vision_config=a_				,    )
				elif "sam_vit_h" in model_name:
								__a	:  List[str]         =					SamVisionConfig(
								    hidden_size=12_80				,    num_hidden_layers=32				,    num_attention_heads=16				,    global_attn_indexes=[7, 15, 23, 31]				,    )

								__a	:  Optional[int]         =					SamConfig(
								    vision_config=a_				,    )

				__a	:  int         =					torch.load(a_				,    map_location='''cpu''')
				__a	:  Tuple         =					replace_keys(a_)

				__a	:  Optional[int]         =					SamImageProcessor()

				__a	:  Any         =					SamProcessor(image_processor=a_)
				__a	:  Any         =					SamModel(a_)

				hf_model.load_state_dict(a_)
				__a	:  Dict         =					hf_model.to('''cuda''')

				__a	:  Tuple         =					'''https://huggingface.co/ybelkada/segment-anything/resolve/main/assets/car.png'''
				__a	:  str         =					Image.open(requests.get(a_				,    stream=a_).raw).convert('''RGB''')

				__a	:  Tuple         =					[[[4_00, 6_50]]]
				__a	:  Tuple         =					[[1]]

				__a	:  Tuple         =					processor(images=np.array(a_)				,    return_tensors='''pt''').to('''cuda''')

				with torch.no_grad():
								__a	:  str         =					hf_model(**a_)
				__a	:  Optional[int]         =					output.iou_scores.squeeze()

				if model_name == "sam_vit_h_4b8939":
								assert scores[-1].item() == 0.5_7_9_8_9_0_2_5_1_1_5_9_6_6_8

								__a	:  Any         =					processor(
								    images=np.array(a_)				,    input_points=a_				,    input_labels=a_				,    return_tensors='''pt''').to('''cuda''')

								with torch.no_grad():
												__a	:  Optional[int]         =					hf_model(**a_)
								__a	:  Optional[int]         =					output.iou_scores.squeeze()

								assert scores[-1].item() == 0.9_7_1_2_6_0_3_0_9_2_1_9_3_6_0_4

								__a	:  str         =					((75, 2_75, 17_25, 8_50),)

								__a	:  List[str]         =					processor(images=np.array(a_)				,    input_boxes=a_				,    return_tensors='''pt''').to('''cuda''')

								with torch.no_grad():
												__a	:  Any         =					hf_model(**a_)
								__a	:  Any         =					output.iou_scores.squeeze()

								assert scores[-1].item() == 0.8_6_8_6_0_1_5_6_0_5_9_2_6_5_1_4

								# Test with 2 points and 1 image.
								__a	:  int         =					[[[4_00, 6_50], [8_00, 6_50]]]
								__a	:  Dict         =					[[1, 1]]

								__a	:  Optional[Any]         =					processor(
								    images=np.array(a_)				,    input_points=a_				,    input_labels=a_				,    return_tensors='''pt''').to('''cuda''')

								with torch.no_grad():
												__a	:  int         =					hf_model(**a_)
								__a	:  Any         =					output.iou_scores.squeeze()

								assert scores[-1].item() == 0.9_9_3_6_0_4_7_7_9_2_4_3_4_6_9_2


if __name__ == "__main__":
		A	     =					argparse.ArgumentParser()
		A	     =					['''sam_vit_b_01ec64''', '''sam_vit_h_4b8939''', '''sam_vit_l_0b3195''']
		parser.add_argument(
		    '''--model_name''',
		    default='''sam_vit_h_4b8939''',
		    choices=choices,
		    type=str,
		    help='''Path to hf config.json of model to convert''',
		)
		parser.add_argument('''--pytorch_dump_folder_path''', default=None, type=str, help='''Path to the output PyTorch model.''')
		parser.add_argument(
		    '''--push_to_hub''',
		    action='''store_true''',
		    help='''Whether to push the model and processor to the hub after converting''',
		)
		parser.add_argument(
		    '''--model_hub_id''',
		    default='''ybelkada/segment-anything''',
		    choices=choices,
		    type=str,
		    help='''Path to hf config.json of model to convert''',
		)

		A	     =					parser.parse_args()

		convert_sam_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.push_to_hub, args.model_hub_id)