Downloads · 30 days
34
4% of all-time downloads
lorebianchi98/Talk2DINO-ViTL
Talk2DINO-ViTL is a image segmentation model from lorebianchi98. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for Pytorch. The card lists the license as apache-2.0.
<div align="center" <h1 Talking to DINO: Bridging Self-Supervised Vision Backbones with Language for Open-Vocabulary Segmentation (ICCV 2025) </h1
Downloads · 30 days
34
4% of all-time downloads
All-time downloads
796
Public
Parameters
456M
1.6 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.6 GB · 99%
How the weights are stored.
F32332M · 73%
From the Hugging Face model README
Project Page | Paper | Code
</div> <div align="center"> <figure> <img alt="Overview of Talk2DINO" src="./assets/overview.png" width="90%"> </figure> </div>Open-Vocabulary Segmentation (OVS) aims at segmenting images from free-form textual concepts without predefined training classes. While existing vision-language models such as CLIP can generate segmentation masks by leveraging coarse spatial information from Vision Transformers, they face challenges in spatial localization due to their global alignment of image and text features. Conversely, self-supervised visual models like DINO excel in fine-grained visual encoding but lack integration with language. To bridge this gap, we present Talk2DINO, a novel hybrid approach that combines the spatial accuracy of DINOv2 with the language understanding of CLIP. Our approach aligns the textual embeddings of CLIP to the patch-level features of DINOv2 through a learned mapping function without the need to fine-tune the underlying backbones. At training time, we exploit the attention maps of DINOv2 to selectively align local visual patches with textual embeddings. We show that the powerful semantic and localization abilities of Talk2DINO can enhance the segmentation process, resulting in more natural and less noisy segmentations, and that our approach can also effectively distinguish foreground objects from the background. Experimental results demonstrate that Talk2DINO achieves state-of-the-art performance across several unsupervised OVS benchmarks.
We can use Talk2DINO to map CLIP text embeddings into the DINOv2 patch embedding space.
from transformers import AutoModel
from torchvision.io import read_image
# Device setup
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# Model Loading
model = AutoModel.from_pretrained("lorebianchi98/Talk2DINO-ViTL").to(device).eval()
# Embedding generation
with torch.no_grad():
text_embed = model.encode_text("a pikachu")
image_embed = model.encode_image(image)
# normalize the features to perform cosine similarity
text_embed = text_embed / text_embed.norm(dim=-1, keepdim=True)
image_embed = image_embed / image_embed.norm(dim=-1, keepdim=True)
similarity = (image_embed @ text_embed.T).squeeze(0, -1).cpu().numpy()
In demo.ipynb we provide a simple example on how to use Talk2DINO for inference on a given image with custom textual categories.
Result:
To use the Hugging Face interface for inference:
# Clone the repository
git clone https://huggingface.co/lorebianchi98/Talk2DINO-ViTL
cd Talk2DINO-ViTL
# Install dependencies
pip install -r requirements.txt
# Install PyTorch and torchvision with the appropriate CUDA version
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu126
<details> <summary>Qualitative Results</summary>For the full MMCV interface to perform evaluation on segmentation benchmarks, please refer to the original Talk2DINO repository.
| Image | Ground Truth | FreeDA | ProxyCLIP | CLIP-DINOiser | Ours (Talk2DINO) |
|---|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
If you found this code useful, please cite the following paper:
@misc{barsellotti2024talkingdinobridgingselfsupervised,
title={Talking to DINO: Bridging Self-Supervised Vision Backbones with Language for Open-Vocabulary Segmentation},
author={Luca Barsellotti and Lorenzo Bianchi and Nicola Messina and Fabio Carrara and Marcella Cornia and Lorenzo Baraldi and Fabrizio Falchi and Rita Cucchiara},
year={2024},
eprint={2411.19331},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2411.19331},
}