Datasets:
Commit
·
547112a
1
Parent(s):
b4ab9d2
Provide bash script for simple dataset access
Browse files- download.sh +98 -0
download.sh
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Base URL of the Hugging Face repository
|
| 4 |
+
BASE_URL="https://huggingface.co/datasets/imageomics/KABR/resolve/main/KABR"
|
| 5 |
+
|
| 6 |
+
# Array of relative file paths
|
| 7 |
+
FILES=(
|
| 8 |
+
"README.txt"
|
| 9 |
+
"annotation/classes.json"
|
| 10 |
+
"annotation/distribution.xlsx"
|
| 11 |
+
"annotation/train.csv"
|
| 12 |
+
"annotation/val.csv"
|
| 13 |
+
"configs/I3D.yaml"
|
| 14 |
+
"configs/SLOWFAST.yaml"
|
| 15 |
+
"configs/X3D.yaml"
|
| 16 |
+
"dataset/image2video.py"
|
| 17 |
+
"dataset/image/giraffes_md5.txt"
|
| 18 |
+
"dataset/image/giraffes_part_aa"
|
| 19 |
+
"dataset/image/giraffes_part_ab"
|
| 20 |
+
"dataset/image/giraffes_part_ac"
|
| 21 |
+
"dataset/image/giraffes_part_ad"
|
| 22 |
+
"dataset/image/giraffes.zip"
|
| 23 |
+
"dataset/image/zebras_grevys_md5.txt"
|
| 24 |
+
"dataset/image/zebras_grevys_part_aa"
|
| 25 |
+
"dataset/image/zebras_grevys_part_ab"
|
| 26 |
+
"dataset/image/zebras_grevys_part_ac"
|
| 27 |
+
"dataset/image/zebras_grevys_part_ad"
|
| 28 |
+
"dataset/image/zebras_grevys_part_ae"
|
| 29 |
+
"dataset/image/zebras_grevys_part_af"
|
| 30 |
+
"dataset/image/zebras_grevys_part_ag"
|
| 31 |
+
"dataset/image/zebras_grevys_part_ah"
|
| 32 |
+
"dataset/image/zebras_grevys_part_ai"
|
| 33 |
+
"dataset/image/zebras_grevys_part_aj"
|
| 34 |
+
"dataset/image/zebras_grevys_part_ak"
|
| 35 |
+
"dataset/image/zebras_grevys_part_al"
|
| 36 |
+
"dataset/image/zebras_grevys_part_am"
|
| 37 |
+
"dataset/image/zebras_plains_md5.txt"
|
| 38 |
+
"dataset/image/zebras_plains_part_aa"
|
| 39 |
+
"dataset/image/zebras_plains_part_ab"
|
| 40 |
+
"dataset/image/zebras_plains_part_ac"
|
| 41 |
+
"dataset/image/zebras_plains_part_ad"
|
| 42 |
+
"dataset/image/zebras_plains_part_ae"
|
| 43 |
+
"dataset/image/zebras_plains_part_af"
|
| 44 |
+
"dataset/image/zebras_plains_part_ag"
|
| 45 |
+
"dataset/image/zebras_plains_part_ah"
|
| 46 |
+
"dataset/image/zebras_plains_part_ai"
|
| 47 |
+
"dataset/image/zebras_plains_part_aj"
|
| 48 |
+
"dataset/image/zebras_plains_part_ak"
|
| 49 |
+
"dataset/image/zebras_plains_part_al"
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
# Loop through each relative file path
|
| 53 |
+
for FILE_PATH in "${FILES[@]}"; do
|
| 54 |
+
# Construct the full URL
|
| 55 |
+
FULL_URL="$BASE_URL/$FILE_PATH"
|
| 56 |
+
|
| 57 |
+
# Create the necessary directories based on the file path
|
| 58 |
+
mkdir -p "$(dirname "KABR_files/$FILE_PATH")"
|
| 59 |
+
|
| 60 |
+
# Download the file and save it with the preserved file path
|
| 61 |
+
wget -P "KABR_files/$(dirname "$FILE_PATH")" "$FULL_URL"
|
| 62 |
+
done
|
| 63 |
+
|
| 64 |
+
ANIMALS=("giraffes" "zebras_grevys" "zebras_plains")
|
| 65 |
+
|
| 66 |
+
# Loop through each animal name
|
| 67 |
+
for ANIMAL in "${ANIMALS[@]}"; do
|
| 68 |
+
# Concatenate the split files into their archive.
|
| 69 |
+
PART_FILES="./KABR_files/dataset/image/${ANIMAL}_part_*"
|
| 70 |
+
if ls $PART_FILES 1> /dev/null 2>&1; then
|
| 71 |
+
cat $PART_FILES > "./KABR_files/dataset/image/${ANIMAL}.zip"
|
| 72 |
+
else
|
| 73 |
+
echo "No part files found for $ANIMAL."
|
| 74 |
+
continue
|
| 75 |
+
fi
|
| 76 |
+
|
| 77 |
+
# Calculate the MD5 sum of the ZIP file
|
| 78 |
+
ZIP_MD5=$(md5sum "./KABR_files/dataset/image/${ANIMAL}.zip" | awk '{ print $1 }')
|
| 79 |
+
|
| 80 |
+
# Read the expected MD5 sum from the associated txt file
|
| 81 |
+
EXPECTED_MD5=$(cat "./KABR_files/dataset/image/${ANIMAL}_md5.txt" | awk '{ print $1 }')
|
| 82 |
+
|
| 83 |
+
# Compare the calculated MD5 sum with the expected MD5 sum
|
| 84 |
+
if [ "$ZIP_MD5" == "$EXPECTED_MD5" ]; then
|
| 85 |
+
echo "MD5 sum for ${ANIMAL}.zip is correct."
|
| 86 |
+
# Delete the part files
|
| 87 |
+
rm $PART_FILES
|
| 88 |
+
unzip -d "./KABR_files/dataset/image/" "./KABR_files/dataset/image/${ANIMAL}.zip"
|
| 89 |
+
rm "./KABR_files/dataset/image/${ANIMAL}.zip"
|
| 90 |
+
rm "./KABR_files/dataset/image/${ANIMAL}_md5.txt"
|
| 91 |
+
else
|
| 92 |
+
echo "MD5 sum for ${ANIMAL}.zip is incorrect. Expected: $EXPECTED_MD5, but got: $ZIP_MD5."
|
| 93 |
+
echo "There may be data corruption. Please try to download and reconstruct the data again or reach out to the corresponding authors for assistance."
|
| 94 |
+
fi
|
| 95 |
+
|
| 96 |
+
done
|
| 97 |
+
|
| 98 |
+
echo "Download, reconstruction, extraction, and verification completed."
|