| # Usage: ./download.sh [num_trajectories] | |
| # Example: ./download.sh 5000 | |
| # Use -1 to download all shards. | |
| NUM_TRAJS=${1:-5000} | |
| DEST_DIR=$(dirname "$(readlink -f "$0")") | |
| echo "Target directory: $DEST_DIR" | |
| # Download metadata | |
| echo "Downloading metadata files..." | |
| gsutil cp gs://gresearch/robotics/language_table/0.1.0/dataset_info.json "$DEST_DIR/" | |
| gsutil cp gs://gresearch/robotics/language_table/0.1.0/features.json "$DEST_DIR/" | |
| if [ "$NUM_TRAJS" -eq -1 ]; then | |
| echo "Downloading all 1024 shards (approx 400GB)..." | |
| gsutil -m cp "gs://gresearch/robotics/language_table/0.1.0/language_table-train.tfrecord-*-of-01024" "$DEST_DIR/" | |
| else | |
| # Each shard has ~430 trajectories. | |
| NUM_SHARDS=$(( (NUM_TRAJS + 399) / 400 )) | |
| if [ "$NUM_SHARDS" -gt 1024 ]; then | |
| NUM_SHARDS=1024 | |
| fi | |
| echo "Downloading $NUM_SHARDS shards to get approximately $NUM_TRAJS trajectories..." | |
| # Loop to download shards | |
| for i in $(seq 0 $((NUM_SHARDS-1))); do | |
| SHARD_ID=$(printf "%05d" $i) | |
| FILE="language_table-train.tfrecord-$SHARD_ID-of-01024" | |
| if [ ! -f "$DEST_DIR/$FILE" ]; then | |
| echo "Downloading $FILE..." | |
| gsutil cp "gs://gresearch/robotics/language_table/0.1.0/$FILE" "$DEST_DIR/" | |
| else | |
| echo "$FILE already exists, skipping." | |
| fi | |
| done | |
| fi | |
| echo "Download process finished." | |