### Install CLIP Dependencies Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Installs necessary packages for CLIP, including PyTorch, torchvision, and other Python libraries. Ensure you have the correct CUDA toolkit version installed. ```sh conda install --yes -c pytorch pytorch=1.7.1 torchvision cudatoolkit=11.0 pip install ftfy regex tqdm pip install opencv-python boto3 requests pandas ``` -------------------------------- ### Train CLIP4Clip on DiDeMo Dataset Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Command for training CLIP4Clip on DiDeMo for video-paragraph retrieval. This task also requires a significant number of GPUs. ```sh DATA_PATH=[Your DiDeMo data and videos path] python -m torch.distributed.launch --nproc_per_node=8 \ main_task_retrieval.py --do_train --num_thread_reader=2 \ --epochs=5 --batch_size=128 --n_display=50 \ --data_path ${DATA_PATH} \ --features_path ${DATA_PATH}/DiDeMo_Videos \ --output_dir ckpts/ckpt_didemo_retrieval_looseType \ --lr 1e-4 --max_words 64 --max_frames 64 --batch_size_val 16 \ --datatype didemo --feature_framerate 1 --coef_lr 1e-3 \ --freeze_layer_num 0 --slice_framepos 2 \ --loose_type --linear_patch 2d --sim_header meanP \ --pretrained_clip_name ViT-B/32 ``` -------------------------------- ### Download CLIP (ViT-B/32) Weight Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Downloads the pre-trained weights for the ViT-B/32 CLIP model. Save these weights in the './modules' directory. ```sh wget -P ./modules https://openaipublic.azureedge.net/clip/models/40d365715913c9da98579312b702a82c18be219cc2a73407c4526f58eba950af/ViT-B-32.pt ``` -------------------------------- ### Train CLIP4Clip on ActivityNet Dataset Source: https://github.com/arrowluo/clip4clip/blob/master/README.md This snippet trains CLIP4Clip for video-paragraph retrieval on ActivityNet. Requires more GPUs due to the nature of the task. ```sh DATA_PATH=[Your ActivityNet data and videos path] python -m torch.distributed.launch --nproc_per_node=8 \ main_task_retrieval.py --do_train --num_thread_reader=2 \ --epochs=5 --batch_size=128 --n_display=50 \ --data_path ${DATA_PATH} \ --features_path ${DATA_PATH}/Activity_Videos \ --output_dir ckpts/ckpt_activity_retrieval_looseType \ --lr 1e-4 --max_words 64 --max_frames 64 --batch_size_val 16 \ --datatype activity --feature_framerate 1 --coef_lr 1e-3 \ --freeze_layer_num 0 --slice_framepos 2 \ --loose_type --linear_patch 2d --sim_header meanP \ --pretrained_clip_name ViT-B/32 ``` -------------------------------- ### Train CLIP4Clip on LSMDC Dataset Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Command to initiate CLIP4Clip training for retrieval on the LSMDC dataset. Ensure DATA_PATH points to your LSMDC data. ```sh DATA_PATH=[Your LSMDC data and videos path] python -m torch.distributed.launch --nproc_per_node=4 \ main_task_retrieval.py --do_train --num_thread_reader=2 \ --epochs=5 --batch_size=128 --n_display=50 \ --data_path ${DATA_PATH} \ --features_path ${DATA_PATH}/LSMDC_Videos \ --output_dir ckpts/ckpt_lsmdc_retrieval_looseType \ --lr 1e-4 --max_words 32 --max_frames 12 --batch_size_val 16 \ --datatype lsmdc --feature_framerate 1 --coef_lr 1e-3 \ --freeze_layer_num 0 --slice_framepos 2 \ --loose_type --linear_patch 2d --sim_header meanP \ --pretrained_clip_name ViT-B/32 ``` -------------------------------- ### Download CLIP (ViT-B/16) Weight Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Downloads the pre-trained weights for the ViT-B/16 CLIP model. Save these weights in the './modules' directory. This model offers better performance. ```sh wget -P ./modules https://openaipublic.azureedge.net/clip/models/5806e77cd80f8b59890b7e101eabd078d9fb84e6937f9e85e4ecb61988df416f/ViT-B-16.pt ``` -------------------------------- ### Download MSVD Data Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Downloads the MSVD dataset splits and raw captions. This script provides convenient access to the dataset files. ```sh wget https://github.com/ArrowLuo/CLIP4Clip/releases/download/v0.0/msvd_data.zip ``` -------------------------------- ### Train CLIP4Clip on MSRVTT Dataset Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Use this command to train the CLIP4Clip model for retrieval on the MSRVTT dataset. Ensure the DATA_PATH is correctly set. ```sh DATA_PATH=[Your MSRVTT data and videos path] python -m torch.distributed.launch --nproc_per_node=4 \ main_task_retrieval.py --do_train --num_thread_reader=0 \ --epochs=5 --batch_size=128 --n_display=50 \ --train_csv ${DATA_PATH}/MSRVTT_train.9k.csv \ --val_csv ${DATA_PATH}/MSRVTT_JSFUSION_test.csv \ --data_path ${DATA_PATH}/MSRVTT_data.json \ --features_path ${DATA_PATH}/MSRVTT_Videos \ --output_dir ckpts/ckpt_msrvtt_retrieval_looseType \ --lr 1e-4 --max_words 32 --max_frames 12 --batch_size_val 16 \ --datatype msrvtt --expand_msrvtt_sentences \ --feature_framerate 1 --coef_lr 1e-3 \ --freeze_layer_num 0 --slice_framepos 2 \ --loose_type --linear_patch 2d --sim_header meanP \ --pretrained_clip_name ViT-B/32 ``` -------------------------------- ### Train CLIP4Clip on MSVD Dataset Source: https://github.com/arrowluo/clip4clip/blob/master/README.md This command trains the CLIP4Clip model for retrieval on the MSVD dataset. Adjust DATA_PATH to your local directory. ```sh DATA_PATH=[Your MSVD data and videos path] python -m torch.distributed.launch --nproc_per_node=4 \ main_task_retrieval.py --do_train --num_thread_reader=2 \ --epochs=5 --batch_size=128 --n_display=50 \ --data_path ${DATA_PATH} \ --features_path ${DATA_PATH}/MSVD_Videos \ --output_dir ckpts/ckpt_msvd_retrieval_looseType \ --lr 1e-4 --max_words 32 --max_frames 12 --batch_size_val 16 \ --datatype msvd \ --feature_framerate 1 --coef_lr 1e-3 \ --freeze_layer_num 0 --slice_framepos 2 \ --loose_type --linear_patch 2d --sim_header meanP \ --pretrained_clip_name ViT-B/32 ``` -------------------------------- ### Compress Video for Speed-up Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Compresses videos to a specified frame rate (3fps) and width (224). Modify input_root and output_root paths as needed. This script helps optimize video processing speed. ```sh python preprocess/compress_video.py --input_root [raw_video_path] --output_root [compressed_video_path] ``` -------------------------------- ### Download MSRVTT Data Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Downloads the MSRVTT dataset splits and captions. This is a convenience script for accessing the data. ```sh wget https://github.com/ArrowLuo/CLIP4Clip/releases/download/v0.0/msrvtt_data.zip ``` -------------------------------- ### Download MSRVTT Raw Videos Source: https://github.com/arrowluo/clip4clip/blob/master/README.md Downloads raw videos for the MSRVTT dataset from the 'Frozen in Time' repository. This is an alternative source for video data. ```sh wget https://www.robots.ox.ac.uk/~maxbain/frozen-in-time/data/MSRVTT.zip ``` -------------------------------- ### CLIP4Clip Citation Source: https://github.com/arrowluo/clip4clip/blob/master/README.md If you find CLIP4Clip useful in your work, please cite the following paper. ```bibtex @Article{Luo2021CLIP4Clip, author = {Huaishao Luo and Lei Ji and Ming Zhong and Yang Chen and Wen Lei and Nan Duan and Tianrui Li}, title = {{CLIP4Clip}: An Empirical Study of CLIP for End to End Video Clip Retrieval}, journal = {arXiv preprint arXiv:2104.08860}, year = {2021}, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.