JasonCoderMaker commited on
Commit
028eb67
·
verified ·
1 Parent(s): 520acfe

Add download_checkpoints.sh

Browse files
Files changed (1) hide show
  1. download_checkpoints.sh +284 -0
download_checkpoints.sh ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ ###############################################################################
3
+ # Download GRDR-TVR Dataset from Hugging Face Hub
4
+ #
5
+ # This script provides a simple way to download the GRDR-TVR dataset
6
+ # components using the Hugging Face CLI.
7
+ #
8
+ # Usage:
9
+ # ./download_checkpoints.sh [OPTIONS]
10
+ #
11
+ # Examples:
12
+ # # Download everything
13
+ # ./download_checkpoints.sh --all
14
+ #
15
+ # # Download only GRDR checkpoints
16
+ # ./download_checkpoints.sh --grdr
17
+ #
18
+ # # Download features for specific dataset
19
+ # ./download_checkpoints.sh --features msrvtt
20
+ ###############################################################################
21
+
22
+ REPO_ID="JasonCoderMaker/GRDR-TVR"
23
+ OUTPUT_DIR="./GRDR-TVR"
24
+
25
+ # Colors for output
26
+ RED='\033[0;31m'
27
+ GREEN='\033[0;32m'
28
+ YELLOW='\033[1;33m'
29
+ BLUE='\033[0;34m'
30
+ NC='\033[0m' # No Color
31
+
32
+ # Print colored message
33
+ print_msg() {
34
+ local color=$1
35
+ shift
36
+ echo -e "${color}$@${NC}"
37
+ }
38
+
39
+ # Check if huggingface-cli is installed
40
+ check_hf_cli() {
41
+ if ! command -v huggingface-cli &> /dev/null; then
42
+ print_msg $RED "Error: huggingface-cli not found!"
43
+ print_msg $YELLOW "Please install: pip install huggingface_hub"
44
+ exit 1
45
+ fi
46
+ }
47
+
48
+ # Download all components
49
+ download_all() {
50
+ print_msg $BLUE "=================================================="
51
+ print_msg $BLUE "Downloading complete GRDR-TVR dataset..."
52
+ print_msg $BLUE "=================================================="
53
+
54
+ huggingface-cli download $REPO_ID \
55
+ --repo-type dataset \
56
+ --local-dir $OUTPUT_DIR \
57
+ --local-dir-use-symlinks False
58
+
59
+ print_msg $GREEN "✓ Complete dataset downloaded to $OUTPUT_DIR"
60
+ }
61
+
62
+ # Download InternVideo2 features
63
+ download_features() {
64
+ local dataset=$1
65
+ print_msg $BLUE "=================================================="
66
+ print_msg $BLUE "Downloading InternVideo2 features..."
67
+ print_msg $BLUE "=================================================="
68
+
69
+ if [ -z "$dataset" ]; then
70
+ # Download all features
71
+ huggingface-cli download $REPO_ID \
72
+ --repo-type dataset \
73
+ --include "InternVideo2/*" \
74
+ --local-dir $OUTPUT_DIR \
75
+ --local-dir-use-symlinks False
76
+ else
77
+ # Download specific dataset features
78
+ huggingface-cli download $REPO_ID \
79
+ --repo-type dataset \
80
+ --include "InternVideo2/${dataset}/*" \
81
+ --local-dir $OUTPUT_DIR \
82
+ --local-dir-use-symlinks False
83
+ fi
84
+
85
+ print_msg $GREEN "✓ Features downloaded to $OUTPUT_DIR/InternVideo2"
86
+ }
87
+
88
+ # Download GRDR checkpoints
89
+ download_grdr() {
90
+ local dataset=$1
91
+ print_msg $BLUE "=================================================="
92
+ print_msg $BLUE "Downloading GRDR checkpoints..."
93
+ print_msg $BLUE "=================================================="
94
+
95
+ if [ -z "$dataset" ]; then
96
+ # Download all GRDR checkpoints
97
+ huggingface-cli download $REPO_ID \
98
+ --repo-type dataset \
99
+ --include "GRDR/*" \
100
+ --local-dir $OUTPUT_DIR \
101
+ --local-dir-use-symlinks False
102
+ else
103
+ # Download specific dataset checkpoint
104
+ huggingface-cli download $REPO_ID \
105
+ --repo-type dataset \
106
+ --include "GRDR/${dataset}/*" \
107
+ --local-dir $OUTPUT_DIR \
108
+ --local-dir-use-symlinks False
109
+ fi
110
+
111
+ print_msg $GREEN "✓ GRDR checkpoints downloaded to $OUTPUT_DIR/GRDR"
112
+ }
113
+
114
+ # Download Xpool checkpoints
115
+ download_xpool() {
116
+ local dataset=$1
117
+ print_msg $BLUE "=================================================="
118
+ print_msg $BLUE "Downloading Xpool reranker checkpoints..."
119
+ print_msg $BLUE "=================================================="
120
+
121
+ if [ -z "$dataset" ]; then
122
+ # Download all Xpool checkpoints
123
+ huggingface-cli download $REPO_ID \
124
+ --repo-type dataset \
125
+ --include "Xpool/*" \
126
+ --local-dir $OUTPUT_DIR \
127
+ --local-dir-use-symlinks False
128
+ else
129
+ # Download specific dataset checkpoint
130
+ local filename=""
131
+ case $dataset in
132
+ msrvtt)
133
+ filename="msrvtt9k_model_best.pth"
134
+ ;;
135
+ actnet)
136
+ filename="actnet_model_best.pth"
137
+ ;;
138
+ didemo)
139
+ filename="didemo_model_best.pth"
140
+ ;;
141
+ lsmdc)
142
+ filename="lsmdc_model_best.pth"
143
+ ;;
144
+ *)
145
+ print_msg $RED "Error: Unknown dataset '$dataset'"
146
+ exit 1
147
+ ;;
148
+ esac
149
+
150
+ huggingface-cli download $REPO_ID \
151
+ --repo-type dataset \
152
+ --include "Xpool/${filename}" \
153
+ --local-dir $OUTPUT_DIR \
154
+ --local-dir-use-symlinks False
155
+ fi
156
+
157
+ print_msg $GREEN "✓ Xpool checkpoints downloaded to $OUTPUT_DIR/Xpool"
158
+ }
159
+
160
+ # Show usage
161
+ show_usage() {
162
+ cat << EOF
163
+ Usage: $0 [OPTIONS] [DATASET]
164
+
165
+ Download GRDR-TVR dataset components from Hugging Face Hub.
166
+
167
+ OPTIONS:
168
+ --all Download all components (default if no option specified)
169
+ --features Download InternVideo2 features only
170
+ --grdr Download GRDR checkpoints only
171
+ --xpool Download Xpool reranker checkpoints only
172
+ -o, --output Specify output directory (default: ./GRDR-TVR)
173
+ -h, --help Show this help message
174
+
175
+ DATASET (optional):
176
+ msrvtt MSR-VTT dataset
177
+ actnet ActivityNet dataset
178
+ didemo DiDeMo dataset
179
+ lsmdc LSMDC dataset
180
+
181
+ If not specified, downloads all datasets.
182
+
183
+ EXAMPLES:
184
+ # Download everything
185
+ $0 --all
186
+
187
+ # Download only GRDR checkpoints
188
+ $0 --grdr
189
+
190
+ # Download InternVideo2 features for MSR-VTT
191
+ $0 --features msrvtt
192
+
193
+ # Download Xpool reranker for ActivityNet
194
+ $0 --xpool actnet
195
+
196
+ # Download to custom directory
197
+ $0 --all -o ./my_data
198
+
199
+ EOF
200
+ }
201
+
202
+ # Main script
203
+ main() {
204
+ check_hf_cli
205
+
206
+ # Parse arguments
207
+ local mode="all"
208
+ local dataset=""
209
+
210
+ while [[ $# -gt 0 ]]; do
211
+ case $1 in
212
+ --all)
213
+ mode="all"
214
+ shift
215
+ ;;
216
+ --features)
217
+ mode="features"
218
+ shift
219
+ ;;
220
+ --grdr)
221
+ mode="grdr"
222
+ shift
223
+ ;;
224
+ --xpool)
225
+ mode="xpool"
226
+ shift
227
+ ;;
228
+ -o|--output)
229
+ OUTPUT_DIR="$2"
230
+ shift 2
231
+ ;;
232
+ -h|--help)
233
+ show_usage
234
+ exit 0
235
+ ;;
236
+ msrvtt|actnet|didemo|lsmdc)
237
+ dataset="$1"
238
+ shift
239
+ ;;
240
+ *)
241
+ print_msg $RED "Error: Unknown option '$1'"
242
+ show_usage
243
+ exit 1
244
+ ;;
245
+ esac
246
+ done
247
+
248
+ print_msg $BLUE "=================================================="
249
+ print_msg $BLUE "GRDR-TVR Dataset Downloader"
250
+ print_msg $BLUE "=================================================="
251
+ print_msg $YELLOW "Repository: $REPO_ID"
252
+ print_msg $YELLOW "Output: $OUTPUT_DIR"
253
+ if [ -n "$dataset" ]; then
254
+ print_msg $YELLOW "Dataset: $dataset"
255
+ fi
256
+ print_msg $BLUE "==================================================\n"
257
+
258
+ # Execute download based on mode
259
+ case $mode in
260
+ all)
261
+ download_all
262
+ ;;
263
+ features)
264
+ download_features "$dataset"
265
+ ;;
266
+ grdr)
267
+ download_grdr "$dataset"
268
+ ;;
269
+ xpool)
270
+ download_xpool "$dataset"
271
+ ;;
272
+ esac
273
+
274
+ print_msg $GREEN "\n=================================================="
275
+ print_msg $GREEN "✓ Download Complete!"
276
+ print_msg $GREEN "=================================================="
277
+ print_msg $YELLOW "\nNext steps:"
278
+ print_msg $YELLOW "1. Verify downloads in $OUTPUT_DIR"
279
+ print_msg $YELLOW "2. See README.md for usage instructions"
280
+ print_msg $YELLOW "3. Visit https://huggingface.co/datasets/$REPO_ID\n"
281
+ }
282
+
283
+ # Run main function
284
+ main "$@"