Datasets:
File size: 8,171 Bytes
028eb67 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
#!/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 "$@"
|