Spaces:
Sleeping
Sleeping
| # Exit immediately if a command exits with a non-zero status | |
| set -e | |
| echo "π Starting dataset download pipeline..." | |
| # Resolve the absolute path of the project root and dataset directory | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" | |
| DATASET_DIR="$PROJECT_ROOT/dataset" | |
| # Ensure the dataset directory exists | |
| mkdir -p "$DATASET_DIR" | |
| # Install Kaggle CLI if it is not already installed | |
| if ! command -v kaggle &> /dev/null; then | |
| echo "π¦ Installing Kaggle CLI..." | |
| pip install -q kaggle | |
| fi | |
| # Ensure the environment variable is set | |
| if [ -z "$KAGGLE_API_TOKEN" ]; then | |
| echo "β ERROR: KAGGLE_API_TOKEN is not set." | |
| echo "Please run: export KAGGLE_API_TOKEN='your_token_here' before running this script." | |
| exit 1 | |
| fi | |
| # Download and unzip | |
| echo "π₯ Downloading Chest X-Ray dataset from Kaggle..." | |
| kaggle datasets download -d paultimothymooney/chest-xray-pneumonia -p "$DATASET_DIR" | |
| echo "ποΈ Unzipping dataset..." | |
| unzip -q "$DATASET_DIR/chest-xray-pneumonia.zip" -d "$DATASET_DIR" | |
| echo "π§Ή Cleaning up zip archive..." | |
| rm "$DATASET_DIR/chest-xray-pneumonia.zip" | |
| echo "β Dataset successfully downloaded and extracted to: $DATASET_DIR" | |