FFHQ-Aging-Dataset / scripts /06_batch_segmap_resize.sh
PIEthonista's picture
update
452723c
#!/bin/bash
# Script to perform segmentation map resizing at scale via multiprocessing.
# ===== Start of Configuration ====================================================
INPUT_DIR="segmaps/segmaps512x512"
OUTPUT_DIR="segmaps/segmaps256x256"
EXT="png"
TARGET_SIZE_W=256
TARGET_SIZE_H=256
MODE="nearest" # nearest | bilinear | bicubic | lanczos (NEAREST only to preserve int classes)
NUM_WORKERS=-1 # -1 to use all cpu cores
# ===== End of Configuration ====================================================
log_dir="logs"
mkdir -p $log_dir
timestamp=$(date +"%Y%m%d_%H%M%S")
log_file="$log_dir/$timestamp.log"
start_time=$(date +"%Y-%m-%d %H:%M:%S")
start_sec=$(date +%s)
echo "Script started at: $start_time" | tee -a "$log_file"
python -m src.batch_image_resize \
--input_dir "$INPUT_DIR" \
--output_dir "$OUTPUT_DIR" \
--ext "$EXT" \
--mode "$MODE" \
--size $TARGET_SIZE_W $TARGET_SIZE_H \
--workers "$NUM_WORKERS" 2>&1 | tee -a "$log_file" # pipe outputs & err to log file too
end_time=$(date +"%Y-%m-%d %H:%M:%S")
end_sec=$(date +%s)
echo "Script ended at: $end_time" | tee -a "$log_file"
# Calculate duration in different formats
duration_sec=$((end_sec - start_sec))
duration_min=$(echo "scale=2; $duration_sec / 60" | bc)
duration_hr=$(echo "scale=2; $duration_sec / 3600" | bc)
echo "Total duration: " | tee -a "$log_file"
echo "- In hours: ${duration_hr} hours" | tee -a "$log_file"
echo "- In minutes: ${duration_min} minutes" | tee -a "$log_file"
echo "- In seconds: ${duration_sec} seconds" | tee -a "$log_file"