Last active
June 10, 2024 07:54
-
-
Save zucchini-nlp/e9f20b054fa322f84ac9311d9ab67042 to your computer and use it in GitHub Desktop.
Update BLIP-2 model for new version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Load your model and processor and run the following to update BLIP-2 model | |
# It will update file in your repo by adding new args in configs and resizing embedding layer | |
# Then you'll be able to run BLIP-2 without warnings/errors | |
processor.num_query_tokens = model.config.num_query_tokens | |
model.resize_token_embeddings(processor.tokenizer.vocab_size, pad_to_multiple_of=64) # pad for efficient computation | |
model.config.image_token_index = processor.tokenizer.vocab_size | |
model.push_to_hub("YOUR-REPO") | |
processor.push_to_hub("YOUR-REPO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment