XaviXva/Video-LLaVA
0
1from transformers import AutoConfig2 3 4def auto_upgrade(config):5 cfg = AutoConfig.from_pretrained(config)6 if 'llava' in config and 'llava' not in cfg.model_type:7 assert cfg.model_type == 'llama'8 print("You are using newer LLaVA code base, while the checkpoint of v0 is from older code base.")9 print("You must upgrade the checkpoint to the new code base (this can be done automatically).")10 confirm = input("Please confirm that you want to upgrade the checkpoint. [Y/N]")11 if confirm.lower() in ["y", "yes"]:12 print("Upgrading checkpoint...")13 assert len(cfg.architectures) == 114 setattr(cfg.__class__, "model_type", "llava")15 cfg.architectures[0] = 'LlavaLlamaForCausalLM'16 cfg.save_pretrained(config)17 print("Checkpoint upgraded.")18 else:19 print("Checkpoint upgrade aborted.")20 exit(1)21 