Image-Text-to-Text
PEFT
Safetensors
English
lora
cvpd
self-distillation
multimodal
vision-language
lmm
ocr
qwen3-vl
unsupervised
conversational
Instructions to use shravvvv/CVPD with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use shravvvv/CVPD with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3-VL-8B-Instruct") model = PeftModel.from_pretrained(base_model, "shravvvv/CVPD") - Notebooks
- Google Colab
- Kaggle
Expand model card
Browse files
README.md
CHANGED
|
@@ -1,25 +1,91 @@
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen3-VL-8B-Instruct
|
|
|
|
| 3 |
library_name: peft
|
| 4 |
pipeline_tag: image-text-to-text
|
|
|
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
- lora
|
| 7 |
- peft
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
- qwen3-vl
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
# CVPD
|
| 12 |
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Usage
|
| 16 |
|
|
|
|
|
|
|
| 17 |
```python
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
from peft import PeftModel
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
```
|
|
|
|
| 1 |
---
|
| 2 |
base_model: Qwen/Qwen3-VL-8B-Instruct
|
| 3 |
+
base_model_relation: adapter
|
| 4 |
library_name: peft
|
| 5 |
pipeline_tag: image-text-to-text
|
| 6 |
+
license: apache-2.0
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
tags:
|
| 10 |
- lora
|
| 11 |
- peft
|
| 12 |
+
- cvpd
|
| 13 |
+
- self-distillation
|
| 14 |
+
- multimodal
|
| 15 |
+
- vision-language
|
| 16 |
+
- lmm
|
| 17 |
+
- ocr
|
| 18 |
- qwen3-vl
|
| 19 |
+
- unsupervised
|
| 20 |
---
|
| 21 |
|
| 22 |
+
# CVPD: Contrastive Counterfactual Visual Process Distillation
|
| 23 |
|
| 24 |
+
This is the CVPD LoRA adapter for `Qwen/Qwen3-VL-8B-Instruct`, from our paper
|
| 25 |
+
[Perception Before Supervision: Self-Contained Visual Distillation from Counterfactual Blind Spots](https://github.com/mbzuai-oryx/CVPD),
|
| 26 |
+
accepted to BMVC 2026.
|
| 27 |
+
|
| 28 |
+
CVPD is a fully self-contained framework for dense, token-level visual self-distillation.
|
| 29 |
+
Where prior visual distillation builds its privileged context from outside the model, using
|
| 30 |
+
segmentation systems, region proposals, or a stronger annotator, CVPD recovers that context
|
| 31 |
+
from the model's own counterfactual behavior. We train on raw, unlabeled images with no
|
| 32 |
+
captions, bounding boxes, labels, reward models, or teacher models, by locating **visual blind
|
| 33 |
+
spots**, regions the model can perceive but fails to exploit under full-image conditioning:
|
| 34 |
+
|
| 35 |
+
- **Discovery:** the model writes its own question and probe answer per image and proposes
|
| 36 |
+
candidate regions by self-grounding and by 3x3 and 2x2 partitions. A region is kept when
|
| 37 |
+
cropping to it moves and sharpens the answer distribution while blurring ("ghosting") it
|
| 38 |
+
leaves the full-image behavior unchanged.
|
| 39 |
+
- **Contrastive self-distillation:** each retained region instantiates four policies from the
|
| 40 |
+
same backbone. The online student learns from a crop-conditioned positive teacher, is pushed
|
| 41 |
+
away from a ghost-conditioned negative teacher, and is anchored to a frozen reference policy.
|
| 42 |
+
|
| 43 |
+
We combine these as latent transfer plus contrastive ranking (`lambda_rank=0.5`, margin
|
| 44 |
+
`m=0.1`) and optimize under a KL anchor adapted online to a target divergence of `0.03`.
|
| 45 |
|
| 46 |
## Usage
|
| 47 |
|
| 48 |
+
This is a LoRA adapter, so load the base model first and attach the adapter:
|
| 49 |
+
|
| 50 |
```python
|
| 51 |
+
import torch
|
| 52 |
+
from PIL import Image
|
| 53 |
+
from transformers import AutoModelForImageTextToText, AutoProcessor
|
| 54 |
from peft import PeftModel
|
| 55 |
|
| 56 |
+
BASE = "Qwen/Qwen3-VL-8B-Instruct"
|
| 57 |
+
ADAPTER = "shravvvv/CVPD"
|
| 58 |
+
|
| 59 |
+
model = AutoModelForImageTextToText.from_pretrained(BASE, dtype=torch.bfloat16, device_map="auto")
|
| 60 |
+
model = PeftModel.from_pretrained(model, ADAPTER)
|
| 61 |
+
processor = AutoProcessor.from_pretrained(ADAPTER)
|
| 62 |
+
model.eval()
|
| 63 |
+
|
| 64 |
+
image = Image.open("example.jpg").convert("RGB")
|
| 65 |
+
messages = [{"role": "user", "content": [
|
| 66 |
+
{"type": "image", "image": image},
|
| 67 |
+
{"type": "text", "text": "What is the text written on the sign?"},
|
| 68 |
+
]}]
|
| 69 |
+
text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
| 70 |
+
inputs = processor(text=[text], images=[image], return_tensors="pt").to(model.device)
|
| 71 |
+
|
| 72 |
+
with torch.inference_mode():
|
| 73 |
+
out = model.generate(**inputs, max_new_tokens=128)
|
| 74 |
+
print(processor.batch_decode(out[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)[0])
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## License
|
| 78 |
+
|
| 79 |
+
Apache 2.0.
|
| 80 |
+
|
| 81 |
+
## Citation
|
| 82 |
+
|
| 83 |
+
```bibtex
|
| 84 |
+
@inproceedings{cvpd,
|
| 85 |
+
author = {Venkatraman, Shravan and Thawakar, Omkar and Thawkar, Ritesh and Shaker, Abdelrahman and Muhammad, Rao},
|
| 86 |
+
title = {Perception Before Supervision: Self-Contained Visual Distillation from Counterfactual Blind Spots},
|
| 87 |
+
booktitle = {37th British Machine Vision Conference 2026, {BMVC} 2026, Lancaster, UK, November 23-26, 2026},
|
| 88 |
+
publisher = {BMVA},
|
| 89 |
+
year = {2026}
|
| 90 |
+
}
|
| 91 |
```
|