Adding the necessary files to make the model compatible with the HF CLIP class
Browse filesI converted the open_clip model to the HF CLIP compatible model and added the necessary files (preprocessor_config.json and config.json). Double-checked that the models outputs are the same.
- config.json +165 -0
- preprocessor_config.json +19 -0
- pytorch_model.bin +3 -0
    	
        config.json
    ADDED
    
    | @@ -0,0 +1,165 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "_commit_hash": null,
         | 
| 3 | 
            +
              "architectures": [
         | 
| 4 | 
            +
                "CLIPModel"
         | 
| 5 | 
            +
              ],
         | 
| 6 | 
            +
              "initializer_factor": 1.0,
         | 
| 7 | 
            +
              "logit_scale_init_value": 2.6592,
         | 
| 8 | 
            +
              "model_type": "clip",
         | 
| 9 | 
            +
              "projection_dim": 768,
         | 
| 10 | 
            +
              "text_config": {
         | 
| 11 | 
            +
                "_name_or_path": "",
         | 
| 12 | 
            +
                "add_cross_attention": false,
         | 
| 13 | 
            +
                "architectures": null,
         | 
| 14 | 
            +
                "attention_dropout": 0.0,
         | 
| 15 | 
            +
                "bad_words_ids": null,
         | 
| 16 | 
            +
                "begin_suppress_tokens": null,
         | 
| 17 | 
            +
                "bos_token_id": 0,
         | 
| 18 | 
            +
                "chunk_size_feed_forward": 0,
         | 
| 19 | 
            +
                "cross_attention_hidden_size": null,
         | 
| 20 | 
            +
                "decoder_start_token_id": null,
         | 
| 21 | 
            +
                "diversity_penalty": 0.0,
         | 
| 22 | 
            +
                "do_sample": false,
         | 
| 23 | 
            +
                "early_stopping": false,
         | 
| 24 | 
            +
                "encoder_no_repeat_ngram_size": 0,
         | 
| 25 | 
            +
                "eos_token_id": 2,
         | 
| 26 | 
            +
                "exponential_decay_length_penalty": null,
         | 
| 27 | 
            +
                "finetuning_task": null,
         | 
| 28 | 
            +
                "forced_bos_token_id": null,
         | 
| 29 | 
            +
                "forced_eos_token_id": null,
         | 
| 30 | 
            +
                "hidden_act": "gelu",
         | 
| 31 | 
            +
                "hidden_size": 768,
         | 
| 32 | 
            +
                "id2label": {
         | 
| 33 | 
            +
                  "0": "LABEL_0",
         | 
| 34 | 
            +
                  "1": "LABEL_1"
         | 
| 35 | 
            +
                },
         | 
| 36 | 
            +
                "initializer_factor": 1.0,
         | 
| 37 | 
            +
                "initializer_range": 0.02,
         | 
| 38 | 
            +
                "intermediate_size": 3072,
         | 
| 39 | 
            +
                "is_decoder": false,
         | 
| 40 | 
            +
                "is_encoder_decoder": false,
         | 
| 41 | 
            +
                "label2id": {
         | 
| 42 | 
            +
                  "LABEL_0": 0,
         | 
| 43 | 
            +
                  "LABEL_1": 1
         | 
| 44 | 
            +
                },
         | 
| 45 | 
            +
                "layer_norm_eps": 1e-05,
         | 
| 46 | 
            +
                "length_penalty": 1.0,
         | 
| 47 | 
            +
                "max_length": 20,
         | 
| 48 | 
            +
                "max_position_embeddings": 77,
         | 
| 49 | 
            +
                "min_length": 0,
         | 
| 50 | 
            +
                "model_type": "clip_text_model",
         | 
| 51 | 
            +
                "no_repeat_ngram_size": 0,
         | 
| 52 | 
            +
                "num_attention_heads": 12,
         | 
| 53 | 
            +
                "num_beam_groups": 1,
         | 
| 54 | 
            +
                "num_beams": 1,
         | 
| 55 | 
            +
                "num_hidden_layers": 12,
         | 
| 56 | 
            +
                "num_return_sequences": 1,
         | 
| 57 | 
            +
                "output_attentions": false,
         | 
| 58 | 
            +
                "output_hidden_states": false,
         | 
| 59 | 
            +
                "output_scores": false,
         | 
| 60 | 
            +
                "pad_token_id": 1,
         | 
| 61 | 
            +
                "prefix": null,
         | 
| 62 | 
            +
                "problem_type": null,
         | 
| 63 | 
            +
                "projection_dim": 512,
         | 
| 64 | 
            +
                "pruned_heads": {},
         | 
| 65 | 
            +
                "remove_invalid_values": false,
         | 
| 66 | 
            +
                "repetition_penalty": 1.0,
         | 
| 67 | 
            +
                "return_dict": true,
         | 
| 68 | 
            +
                "return_dict_in_generate": false,
         | 
| 69 | 
            +
                "sep_token_id": null,
         | 
| 70 | 
            +
                "suppress_tokens": null,
         | 
| 71 | 
            +
                "task_specific_params": null,
         | 
| 72 | 
            +
                "temperature": 1.0,
         | 
| 73 | 
            +
                "tf_legacy_loss": false,
         | 
| 74 | 
            +
                "tie_encoder_decoder": false,
         | 
| 75 | 
            +
                "tie_word_embeddings": true,
         | 
| 76 | 
            +
                "tokenizer_class": null,
         | 
| 77 | 
            +
                "top_k": 50,
         | 
| 78 | 
            +
                "top_p": 1.0,
         | 
| 79 | 
            +
                "torch_dtype": null,
         | 
| 80 | 
            +
                "torchscript": false,
         | 
| 81 | 
            +
                "transformers_version": "4.29.1",
         | 
| 82 | 
            +
                "typical_p": 1.0,
         | 
| 83 | 
            +
                "use_bfloat16": false,
         | 
| 84 | 
            +
                "vocab_size": 49408
         | 
| 85 | 
            +
              },
         | 
| 86 | 
            +
              "torch_dtype": "float32",
         | 
| 87 | 
            +
              "transformers_version": null,
         | 
| 88 | 
            +
              "vision_config": {
         | 
| 89 | 
            +
                "_name_or_path": "",
         | 
| 90 | 
            +
                "add_cross_attention": false,
         | 
| 91 | 
            +
                "architectures": null,
         | 
| 92 | 
            +
                "attention_dropout": 0.0,
         | 
| 93 | 
            +
                "bad_words_ids": null,
         | 
| 94 | 
            +
                "begin_suppress_tokens": null,
         | 
| 95 | 
            +
                "bos_token_id": null,
         | 
| 96 | 
            +
                "chunk_size_feed_forward": 0,
         | 
| 97 | 
            +
                "cross_attention_hidden_size": null,
         | 
| 98 | 
            +
                "decoder_start_token_id": null,
         | 
| 99 | 
            +
                "diversity_penalty": 0.0,
         | 
| 100 | 
            +
                "do_sample": false,
         | 
| 101 | 
            +
                "early_stopping": false,
         | 
| 102 | 
            +
                "encoder_no_repeat_ngram_size": 0,
         | 
| 103 | 
            +
                "eos_token_id": null,
         | 
| 104 | 
            +
                "exponential_decay_length_penalty": null,
         | 
| 105 | 
            +
                "finetuning_task": null,
         | 
| 106 | 
            +
                "forced_bos_token_id": null,
         | 
| 107 | 
            +
                "forced_eos_token_id": null,
         | 
| 108 | 
            +
                "hidden_act": "gelu",
         | 
| 109 | 
            +
                "hidden_size": 1024,
         | 
| 110 | 
            +
                "id2label": {
         | 
| 111 | 
            +
                  "0": "LABEL_0",
         | 
| 112 | 
            +
                  "1": "LABEL_1"
         | 
| 113 | 
            +
                },
         | 
| 114 | 
            +
                "image_size": 224,
         | 
| 115 | 
            +
                "initializer_factor": 1.0,
         | 
| 116 | 
            +
                "initializer_range": 0.02,
         | 
| 117 | 
            +
                "intermediate_size": 4096,
         | 
| 118 | 
            +
                "is_decoder": false,
         | 
| 119 | 
            +
                "is_encoder_decoder": false,
         | 
| 120 | 
            +
                "label2id": {
         | 
| 121 | 
            +
                  "LABEL_0": 0,
         | 
| 122 | 
            +
                  "LABEL_1": 1
         | 
| 123 | 
            +
                },
         | 
| 124 | 
            +
                "layer_norm_eps": 1e-05,
         | 
| 125 | 
            +
                "length_penalty": 1.0,
         | 
| 126 | 
            +
                "max_length": 20,
         | 
| 127 | 
            +
                "min_length": 0,
         | 
| 128 | 
            +
                "model_type": "clip_vision_model",
         | 
| 129 | 
            +
                "no_repeat_ngram_size": 0,
         | 
| 130 | 
            +
                "num_attention_heads": 16,
         | 
| 131 | 
            +
                "num_beam_groups": 1,
         | 
| 132 | 
            +
                "num_beams": 1,
         | 
| 133 | 
            +
                "num_channels": 3,
         | 
| 134 | 
            +
                "num_hidden_layers": 24,
         | 
| 135 | 
            +
                "num_return_sequences": 1,
         | 
| 136 | 
            +
                "output_attentions": false,
         | 
| 137 | 
            +
                "output_hidden_states": false,
         | 
| 138 | 
            +
                "output_scores": false,
         | 
| 139 | 
            +
                "pad_token_id": null,
         | 
| 140 | 
            +
                "patch_size": 14,
         | 
| 141 | 
            +
                "prefix": null,
         | 
| 142 | 
            +
                "problem_type": null,
         | 
| 143 | 
            +
                "projection_dim": 512,
         | 
| 144 | 
            +
                "pruned_heads": {},
         | 
| 145 | 
            +
                "remove_invalid_values": false,
         | 
| 146 | 
            +
                "repetition_penalty": 1.0,
         | 
| 147 | 
            +
                "return_dict": true,
         | 
| 148 | 
            +
                "return_dict_in_generate": false,
         | 
| 149 | 
            +
                "sep_token_id": null,
         | 
| 150 | 
            +
                "suppress_tokens": null,
         | 
| 151 | 
            +
                "task_specific_params": null,
         | 
| 152 | 
            +
                "temperature": 1.0,
         | 
| 153 | 
            +
                "tf_legacy_loss": false,
         | 
| 154 | 
            +
                "tie_encoder_decoder": false,
         | 
| 155 | 
            +
                "tie_word_embeddings": true,
         | 
| 156 | 
            +
                "tokenizer_class": null,
         | 
| 157 | 
            +
                "top_k": 50,
         | 
| 158 | 
            +
                "top_p": 1.0,
         | 
| 159 | 
            +
                "torch_dtype": null,
         | 
| 160 | 
            +
                "torchscript": false,
         | 
| 161 | 
            +
                "transformers_version": "4.29.1",
         | 
| 162 | 
            +
                "typical_p": 1.0,
         | 
| 163 | 
            +
                "use_bfloat16": false
         | 
| 164 | 
            +
              }
         | 
| 165 | 
            +
            }
         | 
    	
        preprocessor_config.json
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            {
         | 
| 2 | 
            +
              "crop_size": 224,
         | 
| 3 | 
            +
              "do_center_crop": true,
         | 
| 4 | 
            +
              "do_normalize": true,
         | 
| 5 | 
            +
              "do_resize": true,
         | 
| 6 | 
            +
              "feature_extractor_type": "CLIPFeatureExtractor",
         | 
| 7 | 
            +
              "image_mean": [
         | 
| 8 | 
            +
                0.48145466,
         | 
| 9 | 
            +
                0.4578275,
         | 
| 10 | 
            +
                0.40821073
         | 
| 11 | 
            +
              ],
         | 
| 12 | 
            +
              "image_std": [
         | 
| 13 | 
            +
                0.26862954,
         | 
| 14 | 
            +
                0.26130258,
         | 
| 15 | 
            +
                0.27577711
         | 
| 16 | 
            +
              ],
         | 
| 17 | 
            +
              "resample": 3,
         | 
| 18 | 
            +
              "size": 224
         | 
| 19 | 
            +
            }
         | 
    	
        pytorch_model.bin
    ADDED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            version https://git-lfs.github.com/spec/v1
         | 
| 2 | 
            +
            oid sha256:cbae707ef72c3d2748f3c9482e9ca8645d8bbd915d59a86e4f11107c9b341068
         | 
| 3 | 
            +
            size 1710660257
         | 
