abodeza commited on
Commit
c8a9ad8
·
verified ·
1 Parent(s): db9adc4

Upload 11 files

Browse files

CLIP trained on 5 disease classes. More details found here: https://github.com/abodeza/clip-ViT-B-32-leaf-disease.git

README.md ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ tags:
3
+ - sentence-transformers
4
+ - sentence-similarity
5
+ - feature-extraction
6
+ - generated_from_trainer
7
+ - dataset_size:326
8
+ - loss:MultipleNegativesRankingLoss
9
+ base_model: sentence-transformers/clip-ViT-B-32
10
+ widget:
11
+ - source_sentence: powdery_mildew
12
+ sentences:
13
+ - rot
14
+ - rot
15
+ - spot
16
+ - source_sentence: powdery_mildew
17
+ sentences:
18
+ - rot
19
+ - chlorosis
20
+ - spot
21
+ - source_sentence: rot
22
+ sentences:
23
+ - powdery_mildew
24
+ - powdery_mildew
25
+ - spot
26
+ - source_sentence: powdery_mildew
27
+ sentences:
28
+ - burn
29
+ - chlorosis
30
+ - chlorosis
31
+ - source_sentence: rot
32
+ sentences:
33
+ - rot
34
+ - spot
35
+ - powdery_mildew
36
+ pipeline_tag: sentence-similarity
37
+ library_name: sentence-transformers
38
+ ---
39
+
40
+ # SentenceTransformer based on sentence-transformers/clip-ViT-B-32
41
+
42
+ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/clip-ViT-B-32](https://huggingface.co/sentence-transformers/clip-ViT-B-32). It maps sentences & paragraphs to a None-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
43
+
44
+ ## Model Details
45
+
46
+ ### Model Description
47
+ - **Model Type:** Sentence Transformer
48
+ - **Base model:** [sentence-transformers/clip-ViT-B-32](https://huggingface.co/sentence-transformers/clip-ViT-B-32) <!-- at revision 11fb331c2c388748c110926aa8013161cb5a85b5 -->
49
+ - **Maximum Sequence Length:** 77 tokens
50
+ - **Output Dimensionality:** None dimensions
51
+ - **Similarity Function:** Cosine Similarity
52
+ <!-- - **Training Dataset:** Unknown -->
53
+ <!-- - **Language:** Unknown -->
54
+ <!-- - **License:** Unknown -->
55
+
56
+ ### Model Sources
57
+
58
+ - **Documentation:** [Sentence Transformers Documentation](https://sbert.net)
59
+ - **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
60
+ - **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
61
+
62
+ ### Full Model Architecture
63
+
64
+ ```
65
+ SentenceTransformer(
66
+ (0): CLIPModel()
67
+ )
68
+ ```
69
+
70
+ ## Usage
71
+
72
+ ### Direct Usage (Sentence Transformers)
73
+
74
+ First install the Sentence Transformers library:
75
+
76
+ ```bash
77
+ pip install -U sentence-transformers
78
+ ```
79
+
80
+ Then you can load this model and run inference.
81
+ ```python
82
+ from sentence_transformers import SentenceTransformer
83
+
84
+ # Download from the 🤗 Hub
85
+ model = SentenceTransformer("sentence_transformers_model_id")
86
+ # Run inference
87
+ sentences = [
88
+ 'rot',
89
+ 'spot',
90
+ 'powdery_mildew',
91
+ ]
92
+ embeddings = model.encode(sentences)
93
+ print(embeddings.shape)
94
+ # [3, 1024]
95
+
96
+ # Get the similarity scores for the embeddings
97
+ similarities = model.similarity(embeddings, embeddings)
98
+ print(similarities.shape)
99
+ # [3, 3]
100
+ ```
101
+
102
+ <!--
103
+ ### Direct Usage (Transformers)
104
+
105
+ <details><summary>Click to see the direct usage in Transformers</summary>
106
+
107
+ </details>
108
+ -->
109
+
110
+ <!--
111
+ ### Downstream Usage (Sentence Transformers)
112
+
113
+ You can finetune this model on your own dataset.
114
+
115
+ <details><summary>Click to expand</summary>
116
+
117
+ </details>
118
+ -->
119
+
120
+ <!--
121
+ ### Out-of-Scope Use
122
+
123
+ *List how the model may foreseeably be misused and address what users ought not to do with the model.*
124
+ -->
125
+
126
+ <!--
127
+ ## Bias, Risks and Limitations
128
+
129
+ *What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model.*
130
+ -->
131
+
132
+ <!--
133
+ ### Recommendations
134
+
135
+ *What are recommendations with respect to the foreseeable issues? For example, filtering explicit content.*
136
+ -->
137
+
138
+ ## Training Details
139
+
140
+ ### Training Dataset
141
+
142
+ #### Unnamed Dataset
143
+
144
+ * Size: 326 training samples
145
+ * Columns: <code>sentence_0</code> and <code>sentence_1</code>
146
+ * Approximate statistics based on the first 326 samples:
147
+ | | sentence_0 | sentence_1 |
148
+ |:--------|:----------------------------------|:--------------------------------------------------------------------------------|
149
+ | type | PIL.JpegImagePlugin.JpegImageFile | string |
150
+ | details | <ul><li></li></ul> | <ul><li>min: 3 tokens</li><li>mean: 4.02 tokens</li><li>max: 7 tokens</li></ul> |
151
+ * Samples:
152
+ | sentence_0 | sentence_1 |
153
+ |:-----------------------------------------------------------------------------------------------|:----------------------------|
154
+ | <code><PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=640x640 at 0x7E07F60418D0></code> | <code>spot</code> |
155
+ | <code><PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=640x640 at 0x7E07ECD2BAD0></code> | <code>spot</code> |
156
+ | <code><PIL.PngImagePlugin.PngImageFile image mode=RGB size=512x512 at 0x7E0802951F90></code> | <code>powdery_mildew</code> |
157
+ * Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
158
+ ```json
159
+ {
160
+ "scale": 20.0,
161
+ "similarity_fct": "cos_sim"
162
+ }
163
+ ```
164
+
165
+ ### Training Hyperparameters
166
+ #### Non-Default Hyperparameters
167
+
168
+ - `per_device_train_batch_size`: 16
169
+ - `per_device_eval_batch_size`: 16
170
+ - `num_train_epochs`: 10
171
+ - `multi_dataset_batch_sampler`: round_robin
172
+
173
+ #### All Hyperparameters
174
+ <details><summary>Click to expand</summary>
175
+
176
+ - `overwrite_output_dir`: False
177
+ - `do_predict`: False
178
+ - `eval_strategy`: no
179
+ - `prediction_loss_only`: True
180
+ - `per_device_train_batch_size`: 16
181
+ - `per_device_eval_batch_size`: 16
182
+ - `per_gpu_train_batch_size`: None
183
+ - `per_gpu_eval_batch_size`: None
184
+ - `gradient_accumulation_steps`: 1
185
+ - `eval_accumulation_steps`: None
186
+ - `torch_empty_cache_steps`: None
187
+ - `learning_rate`: 5e-05
188
+ - `weight_decay`: 0.0
189
+ - `adam_beta1`: 0.9
190
+ - `adam_beta2`: 0.999
191
+ - `adam_epsilon`: 1e-08
192
+ - `max_grad_norm`: 1
193
+ - `num_train_epochs`: 10
194
+ - `max_steps`: -1
195
+ - `lr_scheduler_type`: linear
196
+ - `lr_scheduler_kwargs`: {}
197
+ - `warmup_ratio`: 0.0
198
+ - `warmup_steps`: 0
199
+ - `log_level`: passive
200
+ - `log_level_replica`: warning
201
+ - `log_on_each_node`: True
202
+ - `logging_nan_inf_filter`: True
203
+ - `save_safetensors`: True
204
+ - `save_on_each_node`: False
205
+ - `save_only_model`: False
206
+ - `restore_callback_states_from_checkpoint`: False
207
+ - `no_cuda`: False
208
+ - `use_cpu`: False
209
+ - `use_mps_device`: False
210
+ - `seed`: 42
211
+ - `data_seed`: None
212
+ - `jit_mode_eval`: False
213
+ - `use_ipex`: False
214
+ - `bf16`: False
215
+ - `fp16`: False
216
+ - `fp16_opt_level`: O1
217
+ - `half_precision_backend`: auto
218
+ - `bf16_full_eval`: False
219
+ - `fp16_full_eval`: False
220
+ - `tf32`: None
221
+ - `local_rank`: 0
222
+ - `ddp_backend`: None
223
+ - `tpu_num_cores`: None
224
+ - `tpu_metrics_debug`: False
225
+ - `debug`: []
226
+ - `dataloader_drop_last`: False
227
+ - `dataloader_num_workers`: 0
228
+ - `dataloader_prefetch_factor`: None
229
+ - `past_index`: -1
230
+ - `disable_tqdm`: False
231
+ - `remove_unused_columns`: True
232
+ - `label_names`: None
233
+ - `load_best_model_at_end`: False
234
+ - `ignore_data_skip`: False
235
+ - `fsdp`: []
236
+ - `fsdp_min_num_params`: 0
237
+ - `fsdp_config`: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
238
+ - `tp_size`: 0
239
+ - `fsdp_transformer_layer_cls_to_wrap`: None
240
+ - `accelerator_config`: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
241
+ - `deepspeed`: None
242
+ - `label_smoothing_factor`: 0.0
243
+ - `optim`: adamw_torch
244
+ - `optim_args`: None
245
+ - `adafactor`: False
246
+ - `group_by_length`: False
247
+ - `length_column_name`: length
248
+ - `ddp_find_unused_parameters`: None
249
+ - `ddp_bucket_cap_mb`: None
250
+ - `ddp_broadcast_buffers`: False
251
+ - `dataloader_pin_memory`: True
252
+ - `dataloader_persistent_workers`: False
253
+ - `skip_memory_metrics`: True
254
+ - `use_legacy_prediction_loop`: False
255
+ - `push_to_hub`: False
256
+ - `resume_from_checkpoint`: None
257
+ - `hub_model_id`: None
258
+ - `hub_strategy`: every_save
259
+ - `hub_private_repo`: None
260
+ - `hub_always_push`: False
261
+ - `gradient_checkpointing`: False
262
+ - `gradient_checkpointing_kwargs`: None
263
+ - `include_inputs_for_metrics`: False
264
+ - `include_for_metrics`: []
265
+ - `eval_do_concat_batches`: True
266
+ - `fp16_backend`: auto
267
+ - `push_to_hub_model_id`: None
268
+ - `push_to_hub_organization`: None
269
+ - `mp_parameters`:
270
+ - `auto_find_batch_size`: False
271
+ - `full_determinism`: False
272
+ - `torchdynamo`: None
273
+ - `ray_scope`: last
274
+ - `ddp_timeout`: 1800
275
+ - `torch_compile`: False
276
+ - `torch_compile_backend`: None
277
+ - `torch_compile_mode`: None
278
+ - `include_tokens_per_second`: False
279
+ - `include_num_input_tokens_seen`: False
280
+ - `neftune_noise_alpha`: None
281
+ - `optim_target_modules`: None
282
+ - `batch_eval_metrics`: False
283
+ - `eval_on_start`: False
284
+ - `use_liger_kernel`: False
285
+ - `eval_use_gather_object`: False
286
+ - `average_tokens_across_devices`: False
287
+ - `prompts`: None
288
+ - `batch_sampler`: batch_sampler
289
+ - `multi_dataset_batch_sampler`: round_robin
290
+
291
+ </details>
292
+
293
+ ### Framework Versions
294
+ - Python: 3.11.12
295
+ - Sentence Transformers: 4.1.0
296
+ - Transformers: 4.51.3
297
+ - PyTorch: 2.6.0+cu124
298
+ - Accelerate: 1.6.0
299
+ - Datasets: 3.6.0
300
+ - Tokenizers: 0.21.1
301
+
302
+ ## Citation
303
+
304
+ ### BibTeX
305
+
306
+ #### Sentence Transformers
307
+ ```bibtex
308
+ @inproceedings{reimers-2019-sentence-bert,
309
+ title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
310
+ author = "Reimers, Nils and Gurevych, Iryna",
311
+ booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
312
+ month = "11",
313
+ year = "2019",
314
+ publisher = "Association for Computational Linguistics",
315
+ url = "https://arxiv.org/abs/1908.10084",
316
+ }
317
+ ```
318
+
319
+ #### MultipleNegativesRankingLoss
320
+ ```bibtex
321
+ @misc{henderson2017efficient,
322
+ title={Efficient Natural Language Response Suggestion for Smart Reply},
323
+ author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
324
+ year={2017},
325
+ eprint={1705.00652},
326
+ archivePrefix={arXiv},
327
+ primaryClass={cs.CL}
328
+ }
329
+ ```
330
+
331
+ <!--
332
+ ## Glossary
333
+
334
+ *Clearly define terms in order to be accessible across audiences.*
335
+ -->
336
+
337
+ <!--
338
+ ## Model Card Authors
339
+
340
+ *Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
341
+ -->
342
+
343
+ <!--
344
+ ## Model Card Contact
345
+
346
+ *Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
347
+ -->
config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "CLIPModel"
4
+ ],
5
+ "initializer_factor": 1.0,
6
+ "logit_scale_init_value": 2.6592,
7
+ "model_type": "clip",
8
+ "projection_dim": 512,
9
+ "text_config": {
10
+ "attention_dropout": 0.0,
11
+ "bos_token_id": 0,
12
+ "dropout": 0.0,
13
+ "eos_token_id": 2,
14
+ "gradient_checkpointing": false,
15
+ "hidden_act": "quick_gelu",
16
+ "hidden_size": 512,
17
+ "initializer_factor": 1.0,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 2048,
20
+ "layer_norm_eps": 1e-05,
21
+ "max_position_embeddings": 77,
22
+ "model_type": "clip_text_model",
23
+ "num_attention_heads": 8,
24
+ "num_hidden_layers": 12,
25
+ "projection_dim": 512,
26
+ "torch_dtype": "float32",
27
+ "vocab_size": 49408
28
+ },
29
+ "torch_dtype": "float32",
30
+ "transformers_version": "4.51.3",
31
+ "vision_config": {
32
+ "attention_dropout": 0.0,
33
+ "dropout": 0.0,
34
+ "gradient_checkpointing": false,
35
+ "hidden_act": "quick_gelu",
36
+ "hidden_size": 768,
37
+ "image_size": 224,
38
+ "initializer_factor": 1.0,
39
+ "initializer_range": 0.02,
40
+ "intermediate_size": 3072,
41
+ "layer_norm_eps": 1e-05,
42
+ "model_type": "clip_vision_model",
43
+ "num_attention_heads": 12,
44
+ "num_channels": 3,
45
+ "num_hidden_layers": 12,
46
+ "patch_size": 32,
47
+ "projection_dim": 512,
48
+ "torch_dtype": "float32"
49
+ }
50
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "sentence_transformers": "4.1.0",
4
+ "transformers": "4.51.3",
5
+ "pytorch": "2.6.0+cu124"
6
+ },
7
+ "prompts": {},
8
+ "default_prompt_name": null,
9
+ "similarity_fn_name": "cosine"
10
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6825796d0d8bbd29fe5889a7835422e11172101189afb7ef4298085c23c73857
3
+ size 605156676
modules.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.models.CLIPModel"
7
+ }
8
+ ]
preprocessor_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": {
3
+ "height": 224,
4
+ "width": 224
5
+ },
6
+ "do_center_crop": true,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_rescale": true,
10
+ "do_resize": true,
11
+ "image_mean": [
12
+ 0.48145466,
13
+ 0.4578275,
14
+ 0.40821073
15
+ ],
16
+ "image_processor_type": "CLIPImageProcessor",
17
+ "image_std": [
18
+ 0.26862954,
19
+ 0.26130258,
20
+ 0.27577711
21
+ ],
22
+ "processor_class": "CLIPProcessor",
23
+ "resample": 3,
24
+ "rescale_factor": 0.00392156862745098,
25
+ "size": {
26
+ "shortest_edge": 224
27
+ }
28
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token": {
3
+ "content": "<|startoftext|>",
4
+ "lstrip": false,
5
+ "normalized": true,
6
+ "rstrip": false,
7
+ "single_word": false
8
+ },
9
+ "eos_token": {
10
+ "content": "<|endoftext|>",
11
+ "lstrip": false,
12
+ "normalized": true,
13
+ "rstrip": false,
14
+ "single_word": false
15
+ },
16
+ "pad_token": "<|endoftext|>",
17
+ "unk_token": {
18
+ "content": "<|endoftext|>",
19
+ "lstrip": false,
20
+ "normalized": true,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ }
24
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "49406": {
5
+ "content": "<|startoftext|>",
6
+ "lstrip": false,
7
+ "normalized": true,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "49407": {
13
+ "content": "<|endoftext|>",
14
+ "lstrip": false,
15
+ "normalized": true,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ }
20
+ },
21
+ "bos_token": "<|startoftext|>",
22
+ "clean_up_tokenization_spaces": false,
23
+ "do_lower_case": true,
24
+ "eos_token": "<|endoftext|>",
25
+ "errors": "replace",
26
+ "extra_special_tokens": {},
27
+ "model_max_length": 77,
28
+ "pad_token": "<|endoftext|>",
29
+ "processor_class": "CLIPProcessor",
30
+ "tokenizer_class": "CLIPTokenizer",
31
+ "unk_token": "<|endoftext|>"
32
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff