


"""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__				(					A_ ,A_ ,unittest.TestCase				):
   __UpperCAmelCase							       =					StableDiffusionPanoramaPipeline
   __UpperCAmelCase							       =					TEXT_TO_IMAGE_PARAMS
   __UpperCAmelCase							       =					TEXT_TO_IMAGE_BATCH_PARAMS
   __UpperCAmelCase							       =					TEXT_TO_IMAGE_IMAGE_PARAMS
   __UpperCAmelCase							       =					TEXT_TO_IMAGE_IMAGE_PARAMS





   def 		UpperCamelCase_  (							self)  ->  str:
      torch.manual_seed(0)
      _lowerCamelCase	:					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      ,   )
      _lowerCamelCase	:					Optional[Any]   =		DDIMScheduler()
      torch.manual_seed(0)
      _lowerCamelCase	:					int   =		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)
      _lowerCamelCase	:					Dict   =		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      ,   )
      _lowerCamelCase	:					Any   =		CLIPTextModel(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					int   =		CLIPTokenizer.from_pretrained("""hf-internal-testing/tiny-random-clip""")

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





   def 		UpperCamelCase_  (							self      ,   SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE=0)  ->  Tuple:
      _lowerCamelCase	:					Optional[int]   =		torch.manual_seed(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					List[str]   =		{
          """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 		UpperCamelCase_  (							self)  ->  Optional[int]:
      _lowerCamelCase	:					str   =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      _lowerCamelCase	:					Optional[int]   =		self.get_dummy_components()
      _lowerCamelCase	:					Dict   =		StableDiffusionPanoramaPipeline(**SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Union[str, Any]   =		sd_pipe.to(SCREAMING_SNAKE_CASE)
      sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					int   =		self.get_dummy_inputs(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Union[str, Any]   =		sd_pipe(**SCREAMING_SNAKE_CASE).images
      _lowerCamelCase	:					Optional[int]   =		image[0, -3:, -3:, -1]
      assert image.shape == (1, 64, 64, 3)

      _lowerCamelCase	:					Any   =		np.array([0.61_86, 0.53_74, 0.49_15, 0.41_35, 0.41_14, 0.45_63, 0.51_28, 0.49_77, 0.47_57])

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





   def 		UpperCamelCase_  (							self)  ->  Tuple:
      super().test_inference_batch_consistent(batch_sizes=[1, 2])





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





   def 		UpperCamelCase_  (							self)  ->  Tuple:
      _lowerCamelCase	:					List[Any]   =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      _lowerCamelCase	:					int   =		self.get_dummy_components()
      _lowerCamelCase	:					Union[str, Any]   =		StableDiffusionPanoramaPipeline(**SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Tuple   =		sd_pipe.to(SCREAMING_SNAKE_CASE)
      sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)

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

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

      _lowerCamelCase	:					Optional[int]   =		np.array([0.61_87, 0.53_75, 0.49_15, 0.41_36, 0.41_14, 0.45_63, 0.51_28, 0.49_76, 0.47_57])

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





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

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

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

      _lowerCamelCase	:					List[str]   =		np.array([0.61_87, 0.53_75, 0.49_15, 0.41_36, 0.41_14, 0.45_63, 0.51_28, 0.49_76, 0.47_57])

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





   def 		UpperCamelCase_  (							self)  ->  int:
      _lowerCamelCase	:					str   =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      _lowerCamelCase	:					str   =		self.get_dummy_components()
      _lowerCamelCase	:					Optional[Any]   =		EulerAncestralDiscreteScheduler(
          beta_start=0.0_00_85      ,   beta_end=0.0_12      ,   beta_schedule="""scaled_linear""")
      _lowerCamelCase	:					str   =		StableDiffusionPanoramaPipeline(**SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Dict   =		sd_pipe.to(SCREAMING_SNAKE_CASE)
      sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					Optional[int]   =		self.get_dummy_inputs(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					int   =		sd_pipe(**SCREAMING_SNAKE_CASE).images
      _lowerCamelCase	:					Optional[Any]   =		image[0, -3:, -3:, -1]

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

      _lowerCamelCase	:					Dict   =		np.array([0.40_24, 0.65_10, 0.49_01, 0.53_78, 0.58_13, 0.56_22, 0.47_95, 0.44_67, 0.49_52])

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





   def 		UpperCamelCase_  (							self)  ->  int:
      _lowerCamelCase	:					int   =		"""cpu"""  # ensure determinism for the device-dependent torch.Generator
      _lowerCamelCase	:					Tuple   =		self.get_dummy_components()
      _lowerCamelCase	:					Any   =		PNDMScheduler(
          beta_start=0.0_00_85      ,   beta_end=0.0_12      ,   beta_schedule="""scaled_linear"""      ,   skip_prk_steps=SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Dict   =		StableDiffusionPanoramaPipeline(**SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					List[str]   =		sd_pipe.to(SCREAMING_SNAKE_CASE)
      sd_pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					Tuple   =		self.get_dummy_inputs(SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Dict   =		sd_pipe(**SCREAMING_SNAKE_CASE).images
      _lowerCamelCase	:					Optional[int]   =		image[0, -3:, -3:, -1]

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

      _lowerCamelCase	:					Union[str, Any]   =		np.array([0.63_91, 0.62_91, 0.48_61, 0.51_34, 0.55_52, 0.45_78, 0.50_32, 0.50_23, 0.45_39])

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







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





   def 		UpperCamelCase_  (							self)  ->  Dict:
      super().tearDown()
      gc.collect()
      torch.cuda.empty_cache()





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





   def 		UpperCamelCase_  (							self)  ->  List[str]:
      _lowerCamelCase	:					Tuple   =		"""stabilityai/stable-diffusion-2-base"""
      _lowerCamelCase	:					Optional[Any]   =		DDIMScheduler.from_pretrained(SCREAMING_SNAKE_CASE      ,   subfolder="""scheduler""")
      _lowerCamelCase	:					Union[str, Any]   =		StableDiffusionPanoramaPipeline.from_pretrained(SCREAMING_SNAKE_CASE      ,   scheduler=SCREAMING_SNAKE_CASE      ,   safety_checker=SCREAMING_SNAKE_CASE)
      pipe.to(SCREAMING_SNAKE_CASE)
      pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)
      pipe.enable_attention_slicing()

      _lowerCamelCase	:					int   =		self.get_inputs()
      _lowerCamelCase	:					Dict   =		pipe(**SCREAMING_SNAKE_CASE).images
      _lowerCamelCase	:					Union[str, Any]   =		image[0, -3:, -3:, -1].flatten()

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

      _lowerCamelCase	:					Union[str, Any]   =		np.array(
          [
              0.36_96_83_92,
              0.27_02_53_72,
              0.32_44_67_66,
              0.28_37_93_87,
              0.36_36_32_74,
              0.30_73_33_47,
              0.27_10_00_27,
              0.27_05_41_25,
              0.25_53_60_96,
          ])

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





   def 		UpperCamelCase_  (							self)  ->  Dict:
      _lowerCamelCase	:					int   =		StableDiffusionPanoramaPipeline.from_pretrained(
          """stabilityai/stable-diffusion-2-base"""      ,   safety_checker=SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					Optional[int]   =		LMSDiscreteScheduler.from_config(pipe.scheduler.config)
      pipe.to(SCREAMING_SNAKE_CASE)
      pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)
      pipe.enable_attention_slicing()

      _lowerCamelCase	:					Optional[int]   =		self.get_inputs()
      _lowerCamelCase	:					str   =		pipe(**SCREAMING_SNAKE_CASE).images
      _lowerCamelCase	:					int   =		image[0, -3:, -3:, -1].flatten()

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

      _lowerCamelCase	:					int   =		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 		UpperCamelCase_  (							self)  ->  Any:
      _lowerCamelCase	:					List[str]   =		0

      def callback_fn(SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE      ,   SCREAMING_SNAKE_CASE) -> None:
         _lowerCamelCase	:					str   =		True
         nonlocal number_of_steps
         number_of_steps += 1
         if step == 1:
            _lowerCamelCase	:					int   =		latents.detach().cpu().numpy()
            assert latents.shape == (1, 4, 64, 256)
            _lowerCamelCase	:					Dict   =		latents[0, -3:, -3:, -1]

            _lowerCamelCase	:					Tuple   =		np.array(
                [
                    0.18_68_18_69,
                    0.33_90_78_16,
                    0.5_36_12_76,
                    0.14_43_28_65,
                    -0.02_85_66_11,
                    -0.73_94_11_23,
                    0.23_39_79_87,
                    0.47_32_26_82,
                    -0.37_82_31_64,
                ])
            assert np.abs(latents_slice.flatten() - expected_slice).max() < 5e-2
         elif step == 2:
            _lowerCamelCase	:					int   =		latents.detach().cpu().numpy()
            assert latents.shape == (1, 4, 64, 256)
            _lowerCamelCase	:					int   =		latents[0, -3:, -3:, -1]

            _lowerCamelCase	:					Tuple   =		np.array(
                [
                    0.18_53_96_45,
                    0.33_98_72_48,
                    0.5_37_85_59,
                    0.14_43_71_42,
                    -0.02_45_52_61,
                    -0.7_33_83_17,
                    0.23_99_07_55,
                    0.47_35_62_72,
                    -0.3_78_65_05,
                ])

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

      _lowerCamelCase	:					Any   =		False

      _lowerCamelCase	:					Optional[Any]   =		"""stabilityai/stable-diffusion-2-base"""
      _lowerCamelCase	:					Optional[Any]   =		DDIMScheduler.from_pretrained(SCREAMING_SNAKE_CASE      ,   subfolder="""scheduler""")
      _lowerCamelCase	:					int   =		StableDiffusionPanoramaPipeline.from_pretrained(SCREAMING_SNAKE_CASE      ,   scheduler=SCREAMING_SNAKE_CASE      ,   safety_checker=SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					str   =		pipe.to(SCREAMING_SNAKE_CASE)
      pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)
      pipe.enable_attention_slicing()

      _lowerCamelCase	:					Dict   =		self.get_inputs()
      pipe(**SCREAMING_SNAKE_CASE      ,   callback=SCREAMING_SNAKE_CASE      ,   callback_steps=1)
      assert callback_fn.has_been_called
      assert number_of_steps == 3





   def 		UpperCamelCase_  (							self)  ->  Tuple:
      torch.cuda.empty_cache()
      torch.cuda.reset_max_memory_allocated()
      torch.cuda.reset_peak_memory_stats()

      _lowerCamelCase	:					Tuple   =		"""stabilityai/stable-diffusion-2-base"""
      _lowerCamelCase	:					List[str]   =		DDIMScheduler.from_pretrained(SCREAMING_SNAKE_CASE      ,   subfolder="""scheduler""")
      _lowerCamelCase	:					Any   =		StableDiffusionPanoramaPipeline.from_pretrained(SCREAMING_SNAKE_CASE      ,   scheduler=SCREAMING_SNAKE_CASE      ,   safety_checker=SCREAMING_SNAKE_CASE)
      _lowerCamelCase	:					List[str]   =		pipe.to(SCREAMING_SNAKE_CASE)
      pipe.set_progress_bar_config(disable=SCREAMING_SNAKE_CASE)
      pipe.enable_attention_slicing(1)
      pipe.enable_sequential_cpu_offload()

      _lowerCamelCase	:					int   =		self.get_inputs()
      _lowerCamelCase	:					int   =		pipe(**SCREAMING_SNAKE_CASE)

      _lowerCamelCase	:					List[Any]   =		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 json
from pathlib import Path

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
from timm import create_model
from timm.data import resolve_data_config
from timm.data.transforms_factory import create_transform

from transformers import BitConfig, BitForImageClassification, BitImageProcessor
from transformers.image_utils import PILImageResampling
from transformers.utils import logging


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



def 							_lowerCamelCase			(			__a     ):
		SCREAMING_SNAKE_CASE_    			=			'''huggingface/label-files'''
		SCREAMING_SNAKE_CASE_    			=			'''imagenet-1k-id2label.json'''
		SCREAMING_SNAKE_CASE_    			=			json.load(open(hf_hub_download(__a,				__a,				repo_type='''dataset'''     ),				'''r'''     )     )
		SCREAMING_SNAKE_CASE_    			=			{int(__a     ): v for k, v in idalabel.items()}
		SCREAMING_SNAKE_CASE_    			=			{v: k for k, v in idalabel.items()}

		SCREAMING_SNAKE_CASE_    			=			'''std_conv''' if '''bit''' in model_name else False

		# note that when using BiT as backbone for ViT-hybrid checkpoints,
		# one needs to additionally set config.layer_type = "bottleneck", config.stem_type = "same",
		# config.conv_layer = "std_conv_same"
		SCREAMING_SNAKE_CASE_    			=			BitConfig(
		    conv_layer=__a,				num_labels=1_000,				idalabel=__a,				labelaid=__a,				)

		return config



def 							_lowerCamelCase			(			__a     ):
		if "stem.conv" in name:
				SCREAMING_SNAKE_CASE_    			=			name.replace('''stem.conv''',				'''bit.embedder.convolution'''     )
		if "blocks" in name:
				SCREAMING_SNAKE_CASE_    			=			name.replace('''blocks''',				'''layers'''     )
		if "head.fc" in name:
				SCREAMING_SNAKE_CASE_    			=			name.replace('''head.fc''',				'''classifier.1'''     )
		if name.startswith('''norm'''     ):
				SCREAMING_SNAKE_CASE_    			=			'''bit.''' + name
		if "bit" not in name and "classifier" not in name:
				SCREAMING_SNAKE_CASE_    			=			'''bit.encoder.''' + name

		return name



def 							_lowerCamelCase			(			):
		SCREAMING_SNAKE_CASE_    			=			'''http://images.cocodataset.org/val2017/000000039769.jpg'''
		SCREAMING_SNAKE_CASE_    			=			Image.open(requests.get(__a,				stream=__a     ).raw     )
		return im



@torch.no_grad()
def 							_lowerCamelCase			(			__a,				__a,				__a=False     ):
		SCREAMING_SNAKE_CASE_    			=			get_config(__a     )

		# load original model from timm
		SCREAMING_SNAKE_CASE_    			=			create_model(__a,				pretrained=__a     )
		timm_model.eval()

		# load state_dict of original model
		SCREAMING_SNAKE_CASE_    			=			timm_model.state_dict()
		for key in state_dict.copy().keys():
				SCREAMING_SNAKE_CASE_    			=			state_dict.pop(__a     )
				SCREAMING_SNAKE_CASE_    			=			val.squeeze() if '''head''' in key else val

		# load HuggingFace model
		SCREAMING_SNAKE_CASE_    			=			BitForImageClassification(__a     )
		model.eval()
		model.load_state_dict(__a     )

		# create image processor
		SCREAMING_SNAKE_CASE_    			=			create_transform(**resolve_data_config({},				model=__a     )     )
		SCREAMING_SNAKE_CASE_    			=			transform.transforms

		SCREAMING_SNAKE_CASE_    			=			{
		    '''bilinear''': PILImageResampling.BILINEAR,
		    '''bicubic''': PILImageResampling.BICUBIC,
		    '''nearest''': PILImageResampling.NEAREST,
		}

		SCREAMING_SNAKE_CASE_    			=			BitImageProcessor(
		    do_resize=__a,				size={'''shortest_edge''': timm_transforms[0].size},				resample=pillow_resamplings[timm_transforms[0].interpolation.value],				do_center_crop=__a,				crop_size={'''height''': timm_transforms[1].size[0], '''width''': timm_transforms[1].size[1]},				do_normalize=__a,				image_mean=timm_transforms[-1].mean.tolist(),				image_std=timm_transforms[-1].std.tolist(),				)

		SCREAMING_SNAKE_CASE_    			=			prepare_img()
		SCREAMING_SNAKE_CASE_    			=			transform(__a     ).unsqueeze(0     )
		SCREAMING_SNAKE_CASE_    			=			processor(__a,				return_tensors='''pt'''     ).pixel_values

		# verify pixel values
		assert torch.allclose(__a,				__a     )

		# verify logits
		with torch.no_grad():
				SCREAMING_SNAKE_CASE_    			=			model(__a     )
				SCREAMING_SNAKE_CASE_    			=			outputs.logits

		print('''Logits:''',				logits[0, :3]     )
		print('''Predicted class:''',				model.config.idalabel[logits.argmax(-1     ).item()]     )
		SCREAMING_SNAKE_CASE_    			=			timm_model(__a     )
		assert timm_logits.shape == outputs.logits.shape
		assert torch.allclose(__a,				outputs.logits,				atol=1E-3     )
		print('''Looks ok!'''     )

		if pytorch_dump_folder_path is not None:
				Path(__a     ).mkdir(exist_ok=__a     )
				print(F'Saving model {model_name} and processor to {pytorch_dump_folder_path}'     )
				model.save_pretrained(__a     )
				processor.save_pretrained(__a     )

		if push_to_hub:
				print(F'Pushing model {model_name} and processor to the hub'     )
				model.push_to_hub(F'ybelkada/{model_name}'     )
				processor.push_to_hub(F'ybelkada/{model_name}'     )


if __name__ == "__main__":
						lowerCAmelCase__				=					argparse.ArgumentParser()
						# Required parameters
						parser.add_argument(
						    '--model_name',
						    default='resnetv2_50x1_bitm',
						    type=str,
						    help='Name of the BiT timm model you\'d like to convert.',
						)
						parser.add_argument(
						    '--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model directory.'
						)
						parser.add_argument(
						    '--push_to_hub',
						    action='store_true',
						    help='Whether to push the model to the hub.',
						)

						lowerCAmelCase__				=					parser.parse_args()
						convert_bit_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.push_to_hub)