GRDR-TVR / download_checkpoints.sh
JasonCoderMaker's picture
Add download_checkpoints.sh
028eb67 verified
#!/bin/bash
###############################################################################
# Download GRDR-TVR Dataset from Hugging Face Hub
#
# This script provides a simple way to download the GRDR-TVR dataset
# components using the Hugging Face CLI.
#
# Usage:
# ./download_checkpoints.sh [OPTIONS]
#
# Examples:
# # Download everything
# ./download_checkpoints.sh --all
#
# # Download only GRDR checkpoints
# ./download_checkpoints.sh --grdr
#
# # Download features for specific dataset
# ./download_checkpoints.sh --features msrvtt
###############################################################################
REPO_ID="JasonCoderMaker/GRDR-TVR"
OUTPUT_DIR="./GRDR-TVR"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Print colored message
print_msg() {
local color=$1
shift
echo -e "${color}$@${NC}"
}
# Check if huggingface-cli is installed
check_hf_cli() {
if ! command -v huggingface-cli &> /dev/null; then
print_msg $RED "Error: huggingface-cli not found!"
print_msg $YELLOW "Please install: pip install huggingface_hub"
exit 1
fi
}
# Download all components
download_all() {
print_msg $BLUE "=================================================="
print_msg $BLUE "Downloading complete GRDR-TVR dataset..."
print_msg $BLUE "=================================================="
huggingface-cli download $REPO_ID \
--repo-type dataset \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
print_msg $GREEN "✓ Complete dataset downloaded to $OUTPUT_DIR"
}
# Download InternVideo2 features
download_features() {
local dataset=$1
print_msg $BLUE "=================================================="
print_msg $BLUE "Downloading InternVideo2 features..."
print_msg $BLUE "=================================================="
if [ -z "$dataset" ]; then
# Download all features
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "InternVideo2/*" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
else
# Download specific dataset features
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "InternVideo2/${dataset}/*" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
fi
print_msg $GREEN "✓ Features downloaded to $OUTPUT_DIR/InternVideo2"
}
# Download GRDR checkpoints
download_grdr() {
local dataset=$1
print_msg $BLUE "=================================================="
print_msg $BLUE "Downloading GRDR checkpoints..."
print_msg $BLUE "=================================================="
if [ -z "$dataset" ]; then
# Download all GRDR checkpoints
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "GRDR/*" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
else
# Download specific dataset checkpoint
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "GRDR/${dataset}/*" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
fi
print_msg $GREEN "✓ GRDR checkpoints downloaded to $OUTPUT_DIR/GRDR"
}
# Download Xpool checkpoints
download_xpool() {
local dataset=$1
print_msg $BLUE "=================================================="
print_msg $BLUE "Downloading Xpool reranker checkpoints..."
print_msg $BLUE "=================================================="
if [ -z "$dataset" ]; then
# Download all Xpool checkpoints
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "Xpool/*" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
else
# Download specific dataset checkpoint
local filename=""
case $dataset in
msrvtt)
filename="msrvtt9k_model_best.pth"
;;
actnet)
filename="actnet_model_best.pth"
;;
didemo)
filename="didemo_model_best.pth"
;;
lsmdc)
filename="lsmdc_model_best.pth"
;;
*)
print_msg $RED "Error: Unknown dataset '$dataset'"
exit 1
;;
esac
huggingface-cli download $REPO_ID \
--repo-type dataset \
--include "Xpool/${filename}" \
--local-dir $OUTPUT_DIR \
--local-dir-use-symlinks False
fi
print_msg $GREEN "✓ Xpool checkpoints downloaded to $OUTPUT_DIR/Xpool"
}
# Show usage
show_usage() {
cat << EOF
Usage: $0 [OPTIONS] [DATASET]
Download GRDR-TVR dataset components from Hugging Face Hub.
OPTIONS:
--all Download all components (default if no option specified)
--features Download InternVideo2 features only
--grdr Download GRDR checkpoints only
--xpool Download Xpool reranker checkpoints only
-o, --output Specify output directory (default: ./GRDR-TVR)
-h, --help Show this help message
DATASET (optional):
msrvtt MSR-VTT dataset
actnet ActivityNet dataset
didemo DiDeMo dataset
lsmdc LSMDC dataset
If not specified, downloads all datasets.
EXAMPLES:
# Download everything
$0 --all
# Download only GRDR checkpoints
$0 --grdr
# Download InternVideo2 features for MSR-VTT
$0 --features msrvtt
# Download Xpool reranker for ActivityNet
$0 --xpool actnet
# Download to custom directory
$0 --all -o ./my_data
EOF
}
# Main script
main() {
check_hf_cli
# Parse arguments
local mode="all"
local dataset=""
while [[ $# -gt 0 ]]; do
case $1 in
--all)
mode="all"
shift
;;
--features)
mode="features"
shift
;;
--grdr)
mode="grdr"
shift
;;
--xpool)
mode="xpool"
shift
;;
-o|--output)
OUTPUT_DIR="$2"
shift 2
;;
-h|--help)
show_usage
exit 0
;;
msrvtt|actnet|didemo|lsmdc)
dataset="$1"
shift
;;
*)
print_msg $RED "Error: Unknown option '$1'"
show_usage
exit 1
;;
esac
done
print_msg $BLUE "=================================================="
print_msg $BLUE "GRDR-TVR Dataset Downloader"
print_msg $BLUE "=================================================="
print_msg $YELLOW "Repository: $REPO_ID"
print_msg $YELLOW "Output: $OUTPUT_DIR"
if [ -n "$dataset" ]; then
print_msg $YELLOW "Dataset: $dataset"
fi
print_msg $BLUE "==================================================\n"
# Execute download based on mode
case $mode in
all)
download_all
;;
features)
download_features "$dataset"
;;
grdr)
download_grdr "$dataset"
;;
xpool)
download_xpool "$dataset"
;;
esac
print_msg $GREEN "\n=================================================="
print_msg $GREEN "✓ Download Complete!"
print_msg $GREEN "=================================================="
print_msg $YELLOW "\nNext steps:"
print_msg $YELLOW "1. Verify downloads in $OUTPUT_DIR"
print_msg $YELLOW "2. See README.md for usage instructions"
print_msg $YELLOW "3. Visit https://huggingface.co/datasets/$REPO_ID\n"
}
# Run main function
main "$@"