--- datasets: - laion/laion400m - kakaobrain/coyo-700m license: apache-2.0 pipeline_tag: image-feature-extraction tags: - Vision - LLaVA library_name: transformers --- # Region-based Cluster Discrimination for Visual Representation Learning (RICE) [[Paper]](https://huggingface.co/papers/2507.20025) [[GitHub]](https://github.com/deepglint/unicom) ## Abstract Region-Aware Cluster Discrimination (RICE) is a novel method that enhances region-level visual and OCR capabilities. We first construct a billion-scale candidate region dataset and propose a Region Transformer layer to extract rich regional semantics. We further design a unified region cluster discrimination loss that jointly supports object and OCR learning within a single classification framework, enabling efficient and scalable distributed training on large-scale data. Extensive experiments show that RICE consistently outperforms previous methods on tasks, including segmentation, dense detection, and visual perception for Multimodal Large Language Models (MLLMs). ## Model Overview We used the Vision Transformer architecture [ViT-L/14@336px as CLIP](https://huggingface.co/openai/clip-vit-large-patch14-336). ![image/png](https://cdn-uploads.huggingface.co/production/uploads/6478679d7b370854241b2ad8/8n_jBobanaLNAQjM5eZeg.png) ## Highlights ![470695215-38e89eea-8a73-4e3f-b43a-fa1ea6e32f0f](https://github.com/user-attachments/assets/e0de38b3-b20a-491e-9382-1839e9968481) RICE efficiently processes diverse semantic regions within the image using a single forward pass. The model jointly captures both general visual semantics (objects) and OCR semantics (texts), seamlessly integrating them into a unified representation. ## Data Our model was trained on publicly available image-caption data from the [LAION400M](https://arxiv.org/abs/2111.02114) and [COYO700M](https://github.com/kakaobrain/coyo-dataset) datasets. ## Performance and Limitations ### Experiments This table presents a comprehensive performance comparison of RICE with state-of-the-art vision encoders. For all experiments within the LLaVA-NeXT framework, we adopt a high-resolution tiling strategy: each input image is divided into a 2×2+1 grid of crops, where each crop matches the pre-training resolution of the backbone model (e.g., 336px, 378px, or 560px). ![470696193-65b351ac-9399-4dac-8999-b4412286731a](https://github.com/user-attachments/assets/cd66223f-1757-4ff4-859c-19dd25f1246d) ### Limitations Models with higher resolution are more friendly to OCR results. We are currently training such models and will soon make them available. ## How to use #### 1. Standard Usage ```python # Install dependencies # pip install torch transformers # git clone https://github.com/deepglint/unicom # cd unicom/mlcd from vit_rope2d_hf import MLCDVisionModel from transformers import CLIPImageProcessor from PIL import Image import requests import torch # Load model and processor model = MLCDVisionModel.from_pretrained("DeepGlint-AI/rice-vit-large-patch14-560") processor = CLIPImageProcessor.from_pretrained("DeepGlint-AI/rice-vit-large-patch14-560") # Load and process an image url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw) inputs = processor(images=image, return_tensors="pt") # Extract visual features with torch.no_grad(): outputs = model(**inputs) features = outputs.last_hidden_state print(f"Extracted features shape: {features.shape}") ``` #### 2. Using HuggingFace Transformers >= 4.51.3 ```python # pip install torch transformers>=4.51.3 from transformers import AutoProcessor, AutoModel from PIL import Image import requests import torch # Load model and processor model = AutoModel.from_pretrained("DeepGlint-AI/rice-vit-large-patch14-560") processor = AutoProcessor.from_pretrained("DeepGlint-AI/rice-vit-large-patch14-560") # Load and process an image url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = Image.open(requests.get(url, stream=True).raw) inputs = processor(images=image, return_tensors="pt") # Extract visual features with torch.no_grad(): outputs = model(**inputs) features = outputs.last_hidden_state[0] print(f"Extracted features shape: {features.shape}") ``` ### Visualize Semantic Features ![screenshot-20250725-232729](https://github.com/user-attachments/assets/0ff3b764-c5b6-4a10-a63c-89ccbc99d06b) Using 2048-resolution images as input to a ViT-B/16 model, we project token features onto RGB channels via PCA to visualize the semantic structure. Sequential frames (arranged vertically) illustrate the evolution of model attention, consistently highlighting salient objects across time. The visualization reveals stable color patterns for tracked entities such as ice skaters, deers, motorcyclists, and cyclists, demonstrating the model’s ability to maintain semantic focus throughout the sequence. ## ModelZoo | Model | Download | |-------|-------------| | RICE-ViT-L-14-560px | [huggingface](https://huggingface.co/DeepGlint-AI/rice-vit-large-patch14-560) | | MLCD-ViT-bigG-14-448px | [huggingface](https://huggingface.co/DeepGlint-AI/mlcd-vit-bigG-patch14-448) | | MLCD-ViT-L-14-336px | [huggingface](https://huggingface.co/DeepGlint-AI/mlcd-vit-large-patch14-336) | | MLCD-ViT-B-32-224px | [huggingface](https://huggingface.co/DeepGlint-AI/mlcd-vit-base-patch32-224) | ## Acknowledgments We would like to express our gratitude to [Xie Yin](https://huggingface.co/Yin-Xie) and [Yumeng Wang](https://huggingface.co/devymex) for their significant contributions to the experimental validation in MLLMs. The authors are from DeepGlint team and Huawei London Research Institute. ## Citation If you find our work helpful or inspiring, please feel free to cite it. ```latex @inproceedings{yinxie_2025_rice, title={Region-based Cluster Discrimination for Visual Representation Learning}, author={Xie, Yin and Yang, Kaicheng and An, Xiang and Wu, Kun and Zhao, Yongle and Deng, Weimo and Ran, Zimin and Wang, Yumeng and Feng, Ziyong And Roy, Miles And Ismail, Elezi And Deng, Jiankang}, booktitle={ICCV}, year={2025} } @inproceedings{anxiang_2024_mlcd, title={Multi-label Cluster Discrimination for Visual Representation Learning}, author={An, Xiang and Yang, Kaicheng and Dai, Xiangzi and Feng, Ziyong and Deng, Jiankang}, booktitle={ECCV}, year={2024} } @inproceedings{anxiang_2023_unicom, title={Unicom: Universal and Compact Representation Learning for Image Retrieval}, author={An, Xiang and Deng, Jiankang and Yang, Kaicheng and Li, Jiawei and Feng, Ziyong and Guo, Jia and Yang, Jing and Liu, Tongliang}, booktitle={ICLR}, year={2023} } @inproceedings{anxiang_2022_partialfc, author={An, Xiang and Deng, Jiankang and Guo, Jia and Feng, Ziyong and Zhu, XuHan and Yang, Jing and Liu, Tongliang}, title={Killing Two Birds With One Stone: Efficient and Robust Training of Face Recognition CNNs by Partial FC}, booktitle={CVPR}, year={2022}, } @inproceedings{deng_2019_arcface, title={Arcface: Additive angular margin loss for deep face recognition}, author={Deng, Jiankang and Guo, Jia and Xue, Niannan and Zafeiriou, Stefanos}, booktitle={CVPR}, year={2019} } ```