Awesome
<div align="center"> <h2>γCVPR'2023 πHighlightπ & TPAMIγCap4Video: What Can Auxiliary Captions Do for Text-Video Retrieval? </h2>Wenhao Wu<sup>1,2</sup>, Haipeng Luo<sup>3</sup>, Bo Fang<sup>3</sup>, Jingdong Wang<sup>2</sup>, Wanli Ouyang<sup>4,1</sup>
<sup>1</sup>The University of Sydney, <sup>2</sup>Baidu, <sup>3</sup>UCAS, <sup>4</sup>Shanghai AI Lab
</div>Welcome to the official implementation of Cap4Video - an innovative framework that maximizes the utility of auxiliary captions generated by powerful LLMs (e.g., GPT) to enhance video-text matching.
<details open><summary>π£ I also have other cross-modal video projects that may interest you β¨. </summary><p>Revisiting Classifier: Transferring Vision-Language Models for Video Recognition<br> Wenhao Wu, Zhun Sun, Wanli Ouyang <br>
</p></details> <!-- I am currently traveling and may not be able to open-source the code until May. -->Bidirectional Cross-Modal Knowledge Exploration for Video Recognition with Pre-trained Vision-Language Models<br> Wenhao Wu, Xiaohan Wang, Haipeng Luo, Jingdong Wang, Yi Yang, Wanli Ouyang <br>
News
- [May 24, 2024] The extension of Cap4Video has been accepted by TPAMI ππ!!
- [Apr 27, 2023] Our code has been released. Thanks for your star π.
- [Mar 21, 2023] π Our Cap4Video has been selected as a πHighlightπ paper at CVPR 2023! (Top 2.5% of 9155 submissions).
- [Feb 28, 2023] π Our Cap4Video has been accepted by CVPR-2023.
Overview
Cap4Video leverages captions generated by large language models to improve text-video matching in three ways: (1) input data augmentation during training, (2) intermediate video-caption feature interaction for creating compact video representations, and (3) output score fusion for enhancing text-video matching. Cap4Video is compatible with both global and fine-grained matching.
<!-- ## Content - [Prerequisites](#prerequisites) - [Data Preparation](#data-preparation) - [Training](#training) - [BibTeX & Citation](#bibtex) - [Acknowledgment](#acknowledgment) -->Requirement
# From CLIP
conda install --yes -c pytorch pytorch=1.8.1 torchvision cudatoolkit=11.1
pip install ftfy regex tqdm
pip install opencv-python boto3 requests pandas
Data Preparing
All video datasets can be downloaded from respective official links. In order to improve training efficiency, we have preprocessed these videos into frames, which we have packaged and uploaded for convenient reproduction of our results.
Dataset | Official Link | Ours |
---|---|---|
MSRVTT | Video | Frames |
DiDeMo | Video | Video |
MSVD | Video | Frames |
VATEX | Video | Frames |
How to Run
-
To begin, you will need to prepare a video dataset that has been processed into frames.
-
Next, download the CLIP B/32 and CLIP B/16 models and place them in the
modules
folder. -
Then, download the Caption files that we provide, and place them in the
data
folder. -
Finally, execute the following command to train MSRVTT dataset.
# For more details, please refer to the co_train_msrvtt.sh # DATA_PATH=[Your MSRVTT data path] sh co_train_msrvtt.sh
Visualization
The text-video results on the MSR-VTT 1K-A test set. Left: The ranking results of the query-video matching model. Right: The ranking results of Cap4Video, which incorporates generated captions to enhance retrieval.
<div align="center"> <img src="docs/vis.png" width="550"> </div><a name="bibtex"></a>
π BibTeX & Citation
If you use our code in your research or wish to refer to the results, please star π this repo and use the following BibTeX π entry.
@inproceedings{cap4video,
title={Cap4Video: What Can Auxiliary Captions Do for Text-Video Retrieval?},
author={Wu, Wenhao and Luo, Haipeng and Fang, Bo and Wang, Jingdong and Ouyang, Wanli},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
year={2023}
}
@article{wu2024cap4video++,
title={Cap4Video++: Enhancing Video Understanding with Auxiliary Captions},
author={Wu, Wenhao and Wang, Xiaohan and Luo, Haipeng and Wang, Jingdong and Yang, Yi and Ouyang, Wanli},
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
year={2024},
publisher={IEEE}
}
<a name="acknowledgment"></a>
ποΈ Acknowledgement
This repository is built in part on the excellent works of CLIP4Clip and DRL. We use Video ZeroCap to pre-extract captions from the videos. We extend our sincere gratitude to these contributors for their invaluable contributions.
π« Contact
For any questions, please feel free to file an issue.