zer0int/CLIP-Regression-ViT-L-14

Model

Regression CLIP - with strong typographic robustness!

2

9 commits

1 linked in READMEs

updated Jun 13, 2026

See the code

README

Regression CLIP - with strong typographic robustness!

  • Fine-tuned using CLS-Patch Linear Regression teachers
  • This model: Strong robustness to typographic attacks, good generalization
  • Check the benchmarks below - or read the πŸ“„ Latent Crossroads paper
  • βž•
  • New full-auto CLIP-fine-tune suite, (almost) config-free & super fast:
  • Get the code: πŸ‘‰ github.com/zer0int/CLIP-fine-tune
  • Dataset heuristics (will infer dataset from local or HuggingFace automatically)
  • Loads HuggingFace models, pickles, state dicts / local safetensors, ...
  • Geometry analysis tools: get human-language answers to 'what went wrong', if it did

Love ❀️ this CLIP?

ᐅ Buy me a coffee on Ko-Fi β˜•

Or click here for address to send πŸͺ™β‚Ώ BTC
3PscBrWYvrutXedLmvpcnQbE12Py8qLqMK

latent-crossroads-banner

πŸ“Š Standard Benchmark Evaluation

🌟 = This Model

Zero-Shot (Typographic Attack)

Task / DatasetMetricpretrained🌟 regr-normregr-brut
SCAM::NoSCAMacc0.99050.98970.9897
SCAM::SCAMacc0.41910.80460.8830
SCAM::SynthSCAMacc0.32270.80290.8804
RTA100acc0.43300.78800.8930
πŸ‘‰ CLICK to reproduce: Expand SCAM typographic attack benchmark code βš‘πŸ’»
from datasets import load_dataset
from transformers import CLIPModel, CLIPProcessor
import torch
from PIL import Image
from tqdm import tqdm
import pandas as pd

device = "cuda" if torch.cuda.is_available() else "cpu"

# BLISS / SCAM Typographic Attack Dataset
# https://huggingface.co/datasets/BLISS-e-V/SCAM
ds = load_dataset("BLISS-e-V/SCAM", split="train")

# Benchmark pre-trained model against my fine-tune
model_variants = [
    ("OpenAI ", "openai/clip-vit-large-patch14-336", "openai/clip-vit-large-patch14-336"),
    ("regr-norm", "zer0int/CLIP-Regression-ViT-L-14", "zer0int/CLIP-Regression-ViT-L-14"),
    ("regr-brut", "zer0int/CLIP-Regression-BRUT-ViT-L-14", "zer0int/CLIP-Regression-BRUT-ViT-L-14"),
]

models = {}
for name, model_path, processor_path in model_variants:
    model = CLIPModel.from_pretrained(model_path).to(device).float()
    processor = CLIPProcessor.from_pretrained(processor_path)
    models[name] = (model, processor)

for variant in ["NoSCAM", "SCAM", "SynthSCAM"]:
    print(f"\n=== Evaluating var.: {variant} ===")
    idxs = [i for i, v in enumerate(ds['id']) if v.startswith(variant)]
    if not idxs:
        print(f"  No samples for {variant}")
        continue
    subset = [ds[i] for i in idxs]

    for model_name, (model, processor) in models.items():
        results = []
        for entry in tqdm(subset, desc=f"{model_name}", ncols=30, bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt} |"):
            img = entry['image']
            object_label = entry['object_label']
            attack_word = entry['attack_word']

            texts = [f"a photo of a {object_label}", f"a photo of a {attack_word}"]
            inputs = processor(
                text=texts,
                images=img,
                return_tensors="pt",
                padding=True
            )
            for k in inputs:
                if isinstance(inputs[k], torch.Tensor):
                    inputs[k] = inputs[k].to(device)

            with torch.no_grad():
                outputs = model(**inputs)
                image_features = outputs.image_embeds
                text_features = outputs.text_embeds

                logits = image_features @ text_features.T
                probs = logits.softmax(dim=-1).cpu().numpy().flatten()
                pred_idx = probs.argmax()
                pred_label = [object_label, attack_word][pred_idx]
                is_correct = (pred_label == object_label)

            results.append({
                "id": entry['id'],
                "object_label": object_label,
                "attack_word": attack_word,
                "pred_label": pred_label,
                "is_correct": is_correct,
                "type": entry['type'],
                "model": model_name
            })

        n_total = len(results)
        n_correct = sum(r['is_correct'] for r in results)
        acc = n_correct / n_total if n_total else float('nan')
        print(f"| > > > > Zero-shot accuracy for {variant}, {model_name}: {n_correct}/{n_total} = {acc:.4f}")

Zero-Shot (CLIP Benchmark)

Task / DatasetMetricpretrained🌟 regr-normregr-brut
VOC-2007 multilabelZero-Shot acc0.76150.85230.8350
ImageNet-1k (train)Zero-Shot acc@10.32700.45660.4100
ImageNet-1k (train)Zero-Shot acc@50.53000.68170.6513
ImageNet-1k (train)Zero-Shot mean per-class recall0.32610.45470.4078

Retrieval (CLIP Benchmark)

DatasetMetricpretrained🌟 regr-normregr-brut
MSCOCO Captions (COCO 2014 val)image retrieval R@50.21960.35100.3308
MSCOCO Captions (COCO 2014 val)text retrieval R@50.30320.50420.4758
XM3600image retrieval R@50.30590.42540.4138
XM3600text retrieval R@50.24290.40910.3874

Retrieval (MSCOCO Captions, COCO 2014 val) β€” own scripts

TaskMetricpretrained🌟 regr-normregr-brut
Image-to-Text (I2T)R@10.33660.37480.3508
Image-to-Text (I2T)R@50.78820.87060.8502
Text-to-Image (T2I)R@10.21530.32640.3184
Text-to-Image (T2I)R@50.59020.78510.7821
Text-to-Text (T2T)R@10.20640.24230.2359
Text-to-Text (T2T)R@50.55160.61750.6130
Text-to-Text (T2T_IMG)R@10.31200.35060.3275
Text-to-Text (T2T_IMG)R@50.74660.83860.8179

Retrieval (SugarCrepe, COCO 2017 val) β€” own scripts

SplitMetricpretrained🌟 regr-normregr-brut
add_objacc0.78420.96270.9515
add_attacc0.71680.92050.8743
replace_objacc0.94070.97520.9740
replace_attacc0.79190.85790.8388
replace_relacc0.65290.77520.7696
swap_objacc0.60410.72240.6898
swap_attacc0.62610.72820.7102

Linear Probe (ImageNet-1k) β€” own scripts

Metricpretrained🌟 regr-normregr-brut
Linear Probe Top-1 (%)72.3570.9465.09
Linear Probe Top-5 (%)93.4293.2989.60

πŸ”— Note: 'own scripts' available at github.com/zer0int/CLIP-fine-tune


🎯 Special Evaluation

Please see the paper for more information!

Zero-Shot Accuracy

Dataset (n)Methodpretrained🌟 regr-normregr-brut
NoSCAM (1162)CLS0.99050.98970.9897
NoSCAM (1162)CLS-PATCHSUB0.95440.98450.9811
NoSCAM (1162)CLS-PATCHREG-I0.94660.98880.9888
NoSCAM (1162)CLS-PATCHREG-N0.98710.98970.9888
NoSCAM (1162)REG-L23-NOPC0.93800.96130.9570
NoSCAM (1162)REG-L23-1PC0.96300.98020.9802
NoSCAM (1162)REG-L23-8PC0.95090.96640.9604
NoSCAM (1162)PATCH-L230.73490.97250.9716
NoSCAM (1162)PATCHΞ”0.96900.99050.9888
SCAM (1162)CLS0.41820.80380.8830
SCAM (1162)CLS-PATCHSUB0.49570.86320.9002
SCAM (1162)CLS-PATCHREG-I0.87610.85370.9174
SCAM (1162)CLS-PATCHREG-N0.92860.85370.9165
SCAM (1162)REG-L23-NOPC0.74100.82440.7719
SCAM (1162)REG-L23-1PC0.75390.87260.7943
SCAM (1162)REG-L23-8PC0.70570.80380.7143
SCAM (1162)PATCH-L230.60240.74700.8623
SCAM (1162)PATCHΞ”0.87780.84510.8744
SynthSCAM (1162)CLS0.32190.80210.8804
SynthSCAM (1162)CLS-PATCHSUB0.44060.85800.9071
SynthSCAM (1162)CLS-PATCHREG-I0.88900.84600.9200
SynthSCAM (1162)CLS-PATCHREG-N0.94490.84940.9200
SynthSCAM (1162)REG-L23-NOPC0.78230.83820.7771
SynthSCAM (1162)REG-L23-1PC0.80550.88120.8072
SynthSCAM (1162)REG-L23-8PC0.72890.81670.7126
SynthSCAM (1162)PATCH-L230.63170.74700.8632
SynthSCAM (1162)PATCHΞ”0.92170.86140.8769
MVT (200382)CLS0.88300.87300.8573
MVT (200382)CLS-PATCHSUB0.47200.82460.8057
MVT (200382)CLS-PATCHREG-I0.71660.87030.8518
MVT (200382)CLS-PATCHREG-N0.56950.86750.8478
MVT (200382)REG-L23-NOPC0.76400.79350.7680
MVT (200382)REG-L23-1PC0.79210.81930.8032
MVT (200382)REG-L23-8PC0.77240.80570.7812
MVT (200382)PATCH-L230.34140.86520.8191
MVT (200382)PATCHΞ”0.68810.86670.8510
clip
safetensors

Contributors

zer0int

9 commits

zer0int/CLIP-Regression-ViT-L-14

Model

Regression CLIP - with strong typographic robustness!

2

9 commits

1 linked in READMEs

updated Jun 13, 2026

See the code

README

Regression CLIP - with strong typographic robustness!

  • Fine-tuned using CLS-Patch Linear Regression teachers
  • This model: Strong robustness to typographic attacks, good generalization
  • Check the benchmarks below - or read the πŸ“„ Latent Crossroads paper
  • βž•
  • New full-auto CLIP-fine-tune suite, (almost) config-free & super fast:
  • Get the code: πŸ‘‰ github.com/zer0int/CLIP-fine-tune
  • Dataset heuristics (will infer dataset from local or HuggingFace automatically)
  • Loads HuggingFace models, pickles, state dicts / local safetensors, ...
  • Geometry analysis tools: get human-language answers to 'what went wrong', if it did

Love ❀️ this CLIP?

ᐅ Buy me a coffee on Ko-Fi β˜•

Or click here for address to send πŸͺ™β‚Ώ BTC
3PscBrWYvrutXedLmvpcnQbE12Py8qLqMK

latent-crossroads-banner

πŸ“Š Standard Benchmark Evaluation

🌟 = This Model

Zero-Shot (Typographic Attack)

Task / DatasetMetricpretrained🌟 regr-normregr-brut
SCAM::NoSCAMacc0.99050.98970.9897
SCAM::SCAMacc0.41910.80460.8830
SCAM::SynthSCAMacc0.32270.80290.8804
RTA100acc0.43300.78800.8930
πŸ‘‰ CLICK to reproduce: Expand SCAM typographic attack benchmark code βš‘πŸ’»
from datasets import load_dataset
from transformers import CLIPModel, CLIPProcessor
import torch
from PIL import Image
from tqdm import tqdm
import pandas as pd

device = "cuda" if torch.cuda.is_available() else "cpu"

# BLISS / SCAM Typographic Attack Dataset
# https://huggingface.co/datasets/BLISS-e-V/SCAM
ds = load_dataset("BLISS-e-V/SCAM", split="train")

# Benchmark pre-trained model against my fine-tune
model_variants = [
    ("OpenAI ", "openai/clip-vit-large-patch14-336", "openai/clip-vit-large-patch14-336"),
    ("regr-norm", "zer0int/CLIP-Regression-ViT-L-14", "zer0int/CLIP-Regression-ViT-L-14"),
    ("regr-brut", "zer0int/CLIP-Regression-BRUT-ViT-L-14", "zer0int/CLIP-Regression-BRUT-ViT-L-14"),
]

models = {}
for name, model_path, processor_path in model_variants:
    model = CLIPModel.from_pretrained(model_path).to(device).float()
    processor = CLIPProcessor.from_pretrained(processor_path)
    models[name] = (model, processor)

for variant in ["NoSCAM", "SCAM", "SynthSCAM"]:
    print(f"\n=== Evaluating var.: {variant} ===")
    idxs = [i for i, v in enumerate(ds['id']) if v.startswith(variant)]
    if not idxs:
        print(f"  No samples for {variant}")
        continue
    subset = [ds[i] for i in idxs]

    for model_name, (model, processor) in models.items():
        results = []
        for entry in tqdm(subset, desc=f"{model_name}", ncols=30, bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt} |"):
            img = entry['image']
            object_label = entry['object_label']
            attack_word = entry['attack_word']

            texts = [f"a photo of a {object_label}", f"a photo of a {attack_word}"]
            inputs = processor(
                text=texts,
                images=img,
                return_tensors="pt",
                padding=True
            )
            for k in inputs:
                if isinstance(inputs[k], torch.Tensor):
                    inputs[k] = inputs[k].to(device)

            with torch.no_grad():
                outputs = model(**inputs)
                image_features = outputs.image_embeds
                text_features = outputs.text_embeds

                logits = image_features @ text_features.T
                probs = logits.softmax(dim=-1).cpu().numpy().flatten()
                pred_idx = probs.argmax()
                pred_label = [object_label, attack_word][pred_idx]
                is_correct = (pred_label == object_label)

            results.append({
                "id": entry['id'],
                "object_label": object_label,
                "attack_word": attack_word,
                "pred_label": pred_label,
                "is_correct": is_correct,
                "type": entry['type'],
                "model": model_name
            })

        n_total = len(results)
        n_correct = sum(r['is_correct'] for r in results)
        acc = n_correct / n_total if n_total else float('nan')
        print(f"| > > > > Zero-shot accuracy for {variant}, {model_name}: {n_correct}/{n_total} = {acc:.4f}")

Zero-Shot (CLIP Benchmark)

Task / DatasetMetricpretrained🌟 regr-normregr-brut
VOC-2007 multilabelZero-Shot acc0.76150.85230.8350
ImageNet-1k (train)Zero-Shot acc@10.32700.45660.4100
ImageNet-1k (train)Zero-Shot acc@50.53000.68170.6513
ImageNet-1k (train)Zero-Shot mean per-class recall0.32610.45470.4078

Retrieval (CLIP Benchmark)

DatasetMetricpretrained🌟 regr-normregr-brut
MSCOCO Captions (COCO 2014 val)image retrieval R@50.21960.35100.3308
MSCOCO Captions (COCO 2014 val)text retrieval R@50.30320.50420.4758
XM3600image retrieval R@50.30590.42540.4138
XM3600text retrieval R@50.24290.40910.3874

Retrieval (MSCOCO Captions, COCO 2014 val) β€” own scripts

TaskMetricpretrained🌟 regr-normregr-brut
Image-to-Text (I2T)R@10.33660.37480.3508
Image-to-Text (I2T)R@50.78820.87060.8502
Text-to-Image (T2I)R@10.21530.32640.3184
Text-to-Image (T2I)R@50.59020.78510.7821
Text-to-Text (T2T)R@10.20640.24230.2359
Text-to-Text (T2T)R@50.55160.61750.6130
Text-to-Text (T2T_IMG)R@10.31200.35060.3275
Text-to-Text (T2T_IMG)R@50.74660.83860.8179

Retrieval (SugarCrepe, COCO 2017 val) β€” own scripts

SplitMetricpretrained🌟 regr-normregr-brut
add_objacc0.78420.96270.9515
add_attacc0.71680.92050.8743
replace_objacc0.94070.97520.9740
replace_attacc0.79190.85790.8388
replace_relacc0.65290.77520.7696
swap_objacc0.60410.72240.6898
swap_attacc0.62610.72820.7102

Linear Probe (ImageNet-1k) β€” own scripts

Metricpretrained🌟 regr-normregr-brut
Linear Probe Top-1 (%)72.3570.9465.09
Linear Probe Top-5 (%)93.4293.2989.60

πŸ”— Note: 'own scripts' available at github.com/zer0int/CLIP-fine-tune


🎯 Special Evaluation

Please see the paper for more information!

Zero-Shot Accuracy

Dataset (n)Methodpretrained🌟 regr-normregr-brut
NoSCAM (1162)CLS0.99050.98970.9897
NoSCAM (1162)CLS-PATCHSUB0.95440.98450.9811
NoSCAM (1162)CLS-PATCHREG-I0.94660.98880.9888
NoSCAM (1162)CLS-PATCHREG-N0.98710.98970.9888
NoSCAM (1162)REG-L23-NOPC0.93800.96130.9570
NoSCAM (1162)REG-L23-1PC0.96300.98020.9802
NoSCAM (1162)REG-L23-8PC0.95090.96640.9604
NoSCAM (1162)PATCH-L230.73490.97250.9716
NoSCAM (1162)PATCHΞ”0.96900.99050.9888
SCAM (1162)CLS0.41820.80380.8830
SCAM (1162)CLS-PATCHSUB0.49570.86320.9002
SCAM (1162)CLS-PATCHREG-I0.87610.85370.9174
SCAM (1162)CLS-PATCHREG-N0.92860.85370.9165
SCAM (1162)REG-L23-NOPC0.74100.82440.7719
SCAM (1162)REG-L23-1PC0.75390.87260.7943
SCAM (1162)REG-L23-8PC0.70570.80380.7143
SCAM (1162)PATCH-L230.60240.74700.8623
SCAM (1162)PATCHΞ”0.87780.84510.8744
SynthSCAM (1162)CLS0.32190.80210.8804
SynthSCAM (1162)CLS-PATCHSUB0.44060.85800.9071
SynthSCAM (1162)CLS-PATCHREG-I0.88900.84600.9200
SynthSCAM (1162)CLS-PATCHREG-N0.94490.84940.9200
SynthSCAM (1162)REG-L23-NOPC0.78230.83820.7771
SynthSCAM (1162)REG-L23-1PC0.80550.88120.8072
SynthSCAM (1162)REG-L23-8PC0.72890.81670.7126
SynthSCAM (1162)PATCH-L230.63170.74700.8632
SynthSCAM (1162)PATCHΞ”0.92170.86140.8769
MVT (200382)CLS0.88300.87300.8573
MVT (200382)CLS-PATCHSUB0.47200.82460.8057
MVT (200382)CLS-PATCHREG-I0.71660.87030.8518
MVT (200382)CLS-PATCHREG-N0.56950.86750.8478
MVT (200382)REG-L23-NOPC0.76400.79350.7680
MVT (200382)REG-L23-1PC0.79210.81930.8032
MVT (200382)REG-L23-8PC0.77240.80570.7812
MVT (200382)PATCH-L230.34140.86520.8191
MVT (200382)PATCHΞ”0.68810.86670.8510
clip
safetensors

Contributors

zer0int

9 commits