tiny-random-siglip / README.md
VictorSanh's picture
Update README.md
9956005
|
raw
history blame
1.58 kB

Tiny random Siglip model. For testing purposes only.

Script used to create this tiny random model:

from transformers import AutoConfig, AutoModel

config = AutoConfig.from_pretrained("HuggingFaceM4/siglip-so400m-14-384", trust_remote_code=True)

config._name_or_path = 'HuggingFaceM4/tiny-random-siglip'

config.text_config.hidden_size = int(config.text_config.hidden_size/8)
config.text_config.intermediate_size = int(config.text_config.intermediate_size/8)
config.text_config.num_attention_heads = int(config.text_config.num_attention_heads/8)
config.text_config.num_hidden_layers = 3
config.text_config.projection_dim = int(config.text_config.projection_dim/8)

config.vision_config.hidden_size = int(config.vision_config.hidden_size/8)
config.vision_config.image_size = 30
config.vision_config.intermediate_size = int(config.vision_config.intermediate_size/8)
config.vision_config.num_attention_heads = int(config.vision_config.num_attention_heads/8)
config.vision_config.num_hidden_layers = 3
config.vision_config.patch_size = 2
config.vision_config.projection_dim = int(config.vision_config.projection_dim/8)

config.auto_map = {
    "AutoConfig": "HuggingFaceM4/tiny-random-siglip--configuration_siglip.SiglipConfig",
    "AutoModel": "HuggingFaceM4/tiny-random-siglip--modeling_siglip.SiglipModel"
}

config.save_pretrained("./tiny-random-siglip")

model = AutoModel.from_pretrained("HuggingFaceM4/siglip-so400m-14-384", trust_remote_code=True)

SiglipModel = model.__class__

new_model = SiglipModel(config)
new_model.save_pretrained("./tiny-random-siglip")