Spaces:
Sleeping
Sleeping
Add dataset download script for Chest X-Ray
Browse filesThis script downloads the Chest X-Ray dataset from Kaggle, unzips it, and cleans up the zip file.
scripts/01_download_dataset.sh
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
# Exit immediately if a command exits with a non-zero status
|
| 3 |
+
set -e
|
| 4 |
+
|
| 5 |
+
echo "🚀 Starting dataset download pipeline..."
|
| 6 |
+
|
| 7 |
+
# Resolve the absolute path of the project root and dataset directory
|
| 8 |
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
| 9 |
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
| 10 |
+
DATASET_DIR="$PROJECT_ROOT/dataset"
|
| 11 |
+
|
| 12 |
+
# Ensure the dataset directory exists
|
| 13 |
+
mkdir -p "$DATASET_DIR"
|
| 14 |
+
|
| 15 |
+
# Install Kaggle CLI if it is not already installed
|
| 16 |
+
if ! command -v kaggle &> /dev/null; then
|
| 17 |
+
echo "📦 Installing Kaggle CLI..."
|
| 18 |
+
pip install -q kaggle
|
| 19 |
+
fi
|
| 20 |
+
|
| 21 |
+
# Ensure the environment variable is set
|
| 22 |
+
if [ -z "$KAGGLE_API_TOKEN" ]; then
|
| 23 |
+
echo "❌ ERROR: KAGGLE_API_TOKEN is not set."
|
| 24 |
+
echo "Please run: export KAGGLE_API_TOKEN='your_token_here' before running this script."
|
| 25 |
+
exit 1
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
# Download and unzip
|
| 29 |
+
echo "📥 Downloading Chest X-Ray dataset from Kaggle..."
|
| 30 |
+
kaggle datasets download -d paultimothymooney/chest-xray-pneumonia -p "$DATASET_DIR"
|
| 31 |
+
|
| 32 |
+
echo "🗜️ Unzipping dataset..."
|
| 33 |
+
unzip -q "$DATASET_DIR/chest-xray-pneumonia.zip" -d "$DATASET_DIR"
|
| 34 |
+
|
| 35 |
+
echo "🧹 Cleaning up zip archive..."
|
| 36 |
+
rm "$DATASET_DIR/chest-xray-pneumonia.zip"
|
| 37 |
+
|
| 38 |
+
echo "✅ Dataset successfully downloaded and extracted to: $DATASET_DIR"
|