Modelzero-shot-image-classification
zer0int

zer0int/CLIP-GmP-ViT-L-14

🔥 Update SUMMER 2025: 🔥 🤖 New and greatly improved version of the model, check out: - 🌑 https://huggingface.co/zer0int/CLIP-KO-LITE-TypoAttack-Attn-Dropout-ViT-L-14(https://huggingface.co/zer0int/CLIP-KO-LITE-TypoAttack-Attn-Dropout-ViT-L-14) --...

523likes
5.9kdownloads
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: base_model:finetune:openai/clip-vit-large-patch14

#1 Repository of the week

1
TINIX TRENDING·Topic: dataset:SPRIGHT-T2I/spright_coco

#1 Repository of the week

1
TINIX TRENDING·Topic: base_model:openai/clip-vit-large-patch14

#1 Repository of the week

🔥 Update SUMMER 2025: 🔥

🤖 New and greatly improved version of the model, check out:


A fine-tune of CLIP-L. Original model: openai/clip-vit-large-patch14

Love ❤️ this CLIP?

ᐅ Buy me a coffee on Ko-Fi ☕

Or click here for address to send 🪙₿ BTC
3PscBrWYvrutXedLmvpcnQbE12Py8qLqMK

  • Want to feed it yourself? All code for fine-tuning and much more is on my GitHub.

Update 23/SEP/2024:

  • Huggingface Transformers / Diffusers pipeline now implemented.
  • See here for an example script: Integrating my CLIP-L with Flux.1
  • Otherwise, use as normal / any HF model:
from transformers import CLIPModel, CLIPProcessor, CLIPConfig
model_id = "zer0int/CLIP-GmP-ViT-L-14"
config = CLIPConfig.from_pretrained(model_id)

Update 03/SEP/2024 / edit 05/AUG:

👋 Looking for a Text Encoder for Flux.1 (or SD3, SDXL, SD, ...) to replace CLIP-L? 👀

You'll generally want the "TE-only" .safetensors:

  • 👉 The "TEXT" model has superior prompt following, especially for text, but also for other details. DOWNLOAD
  • 👉 The "SMOOTH" model can sometimes** have better details (when there's no text in the image). DOWNLOAD
  • The "GmP" initial fine-tune is deprecated / inferior to the above models. Still, you can DOWNLOAD it.

**: The "TEXT" model is the best for text. Full stop. But whether the "SMOOTH" model is better for your (text-free) scenario than the "TEXT" model really depends on the specific prompt. It might also be the case that the "TEXT" model leads to images that you prefer over "SMOOTH"; the only way to know is to experiment with both.

image/png

🤓👨‍💻 In general (because we're not limited to text-to-image generative AI), I provide four versions / downloads:

  • Text encoder only .safetensors.
  • Full model .safetensors.
  • State_dict pickle.
  • Full model pickle (can be used as-is with "import clip" -> clip.load() after bypassing SHA checksum verification).

The TEXT model has a modality gap of 0.80 (OpenAI pre-trained: 0.82).

  • Trained with high temperature of 0.1 + tinkering.
  • ImageNet/ObjectNet accuracy ~0.91 for both "SMOOTH" and "TEXT" models (pre-trained: ~0.84).
  • The models (this plot = "TEXT" model on MSCOCO) are also golden retrievers: 🥰🐕

image/png


Update 11/AUG/2024:

New Best-Performing CLIP ViT-L/14 'GmP-smooth' model added (simply download the files named BEST!):

image/png

Or just create a fine-tune yourself: https://github.com/zer0int/CLIP-fine-tune

How?

  • Geometric Parametrization (GmP) (same as before)
  • Activation Value manipulation for 'adverb neuron' (same as before)
  • NEW: Custom loss function with label smoothing!
  • For in-depth details, see my GitHub. 🤗

A fine-tune of OpenAI / CLIP ViT-L/14 that has an unprecedented ImageNet/ObjectNet accuracy of ~0.90 (original pre-trained model / OpenAI's CLIP: ~0.85)**.

Made possible with Geometric Parametrization (GmP):


"Normal" CLIP MLP (multi-layer perceptron):

(mlp): Sequential(
  |-(c_fc): Linear(in_features=1024, out_features=4096, bias=True)
  | (gelu): QuickGELU()
|-}-(c_proj): Linear(in_features=4096, out_features=1024, bias=True)
| | 
| |-- visual.transformer.resblocks.0.mlp.c_fc.weight
| |-- visual.transformer.resblocks.0.mlp.c_fc.bias
|
|---- visual.transformer.resblocks.0.mlp.c_proj.weight
|---- visual.transformer.resblocks.0.mlp.c_proj.bias


GmP CLIP MLP:

Weight decomposition into:
- radial component 'r' as norm of pre-trained weights
- angular component 'theta' as normalized direction
-> preserves weight vectors' directionality and magnitude

(mlp): Sequential(
  |-(c_fc): GeometricLinear()
  | (gelu): QuickGELU()
|-}-(c_proj): GeometricLinear()
| | 
| |-- visual.transformer.resblocks.0.mlp.c_fc.r
| |-- visual.transformer.resblocks.0.mlp.c_fc.theta
| |-- visual.transformer.resblocks.0.mlp.c_fc.bias
|
|---- visual.transformer.resblocks.0.mlp.c_proj.r
|---- visual.transformer.resblocks.0.mlp.c_proj.theta
|---- visual.transformer.resblocks.0.mlp.c_proj.bias

(Same thing for [text] transformer.resblocks)

image/png

✅ The model / state_dict I am sharing was converted back to .weight after fine-tuning - alas, it can be used in the same manner as any state_dict, e.g. for use with ComfyUI as the SDXL / SD3 Text Encoder! 🤗

  • ** For details on training and those numbers / the eval, please see https://github.com/zer0int/CLIP-fine-tune
  • -> You can use "exp-acts-ft-finetune-OpenAI-CLIP-ViT-L-14-GmP-manipulate-neurons.py" to replicate my exact model fine-tune.

Pre-trained CLIP model by OpenAI, License: MIT License

Similar Projects

Discover other similar projects and AI models.

Modelzero-shot-image-classification
openai/clip-vit-base-patch32

Model Card: CLIP Disclaimer: The model card is taken and modified from the official CLIP repository, it can be found here(https://github.com/openai/CLIP/blob/main/model-card.md). Model Details The CLIP model was developed by researchers at OpenAI to...

♥0
16.4M
Feb 29, 2024
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...

♥0
157.6M
Jun 1, 2026
Modelfeature-extraction
BAAI/bge-small-en-v1.5

FlagEmbedding Model List | FAQ | Usage | Evaluation | Train | Contact | Citation | License More details please refer to our Github: FlagEmbedding(https://github.com/FlagOpen/FlagEmbedding). If you are looking for a model that supports more languages,...

♥0
41.9M
Feb 22, 2024
Modelzero-shot-image-classification
openai/clip-vit-large-patch14

Model Card: CLIP Disclaimer: The model card is taken and modified from the official CLIP repository, it can be found here(https://github.com/openai/CLIP/blob/main/model-card.md). Model Details The CLIP model was developed by researchers at OpenAI to...

♥0
8.6M
Sep 15, 2023
Modelzero-shot-image-classification
laion/CLIP-ViT-B-32-laion2B-s34B-b79K

Model Card for CLIP ViT-B/32 - LAION-2B Table of Contents 1. Model Details(model-details) 2. Uses(uses) 3. Training Details(training-details) 4. Evaluation(evaluation) 5. Acknowledgements(acknowledgements) 6. Citation(citation) 7. How To Get Started...

♥0
5.7M
Jan 22, 2025
Modelzero-shot-image-classification
laion/CLIP-ViT-H-14-laion2B-s32B-b79K

Model Card for CLIP ViT-H/14 - LAION-2B Table of Contents 1. Model Details(model-details) 2. Uses(uses) 3. Training Details(training-details) 4. Evaluation(evaluation) 5. Acknowledgements(acknowledgements) 6. Citation(citation) 7. How To Get Started...

♥0
583.0k
Jan 22, 2025
Modelzero-shot-image-classification
openai/clip-vit-large-patch14-336

clip-vit-large-patch14-336 This model was trained from scratch on an unknown dataset. It achieves the following results on the evaluation set: Model description More information needed Intended uses & limitations More information needed Training and...

♥0
866.2k
Oct 4, 2022
Modelzero-shot-image-classification
openai/clip-vit-base-patch16

Model Card: CLIP Disclaimer: The model card is taken and modified from the official CLIP repository, it can be found here(https://github.com/openai/CLIP/blob/main/model-card.md). Model Details The CLIP model was developed by researchers at OpenAI to...

♥0
1.6M
Oct 4, 2022
Modelzero-shot-image-classification
microsoft/BiomedCLIP-PubMedBERT_256-vit_base_patch16_224

BiomedCLIP-PubMedBERT256-vitbasepatch16224 BiomedCLIP(https://aka.ms/biomedclip-paper) is a biomedical vision-language foundation model that is pretrained on PMC-15M(https://github.com/microsoft/BiomedCLIPdatapipeline), a dataset of 15 million figur...

♥0
133.3k
Jan 14, 2025