| #!/usr/bin/env bash |
| set -euo pipefail |
|
|
| |
| |
|
|
| ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| cd "$ROOT_DIR" |
|
|
| GPU_ID="${GPU_ID:-1}" |
| EPOCHS_ABL="${EPOCHS_ABL:-5}" |
| MAX_SAMPLES="${MAX_SAMPLES:-10000}" |
|
|
| ABL_ROOT="results/ablation_study" |
| CKPT_DIR="$ABL_ROOT/checkpoints" |
| RUN_DIR="$ABL_ROOT/runs" |
| LOG_DIR="$ABL_ROOT/logs" |
| mkdir -p "$CKPT_DIR" "$RUN_DIR" "$LOG_DIR" |
|
|
| export PYTHONPATH=. |
|
|
| run() { |
| local name="$1" |
| shift |
| echo |
| echo "============================================================" |
| echo "[$(date '+%F %T')] START: $name" |
| echo "CMD: $*" |
| echo "============================================================" |
| "$@" |
| echo "[$(date '+%F %T')] DONE: $name" |
| } |
|
|
| |
| run "train_no_lora_256" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \ |
| --output_dir "$CKPT_DIR/no_lora_256" \ |
| --disable_lora \ |
| --target_tokens 256 \ |
| --epochs "$EPOCHS_ABL" \ |
| --max_samples "$MAX_SAMPLES" \ |
| --mix_root data \ |
| --mix_images_subdir ref_screenshots \ |
| --mix_gt_subdir gt_html \ |
| --max_html_tokens 8192 |
|
|
| run "eval_no_lora_256" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \ |
| --method uipress \ |
| --checkpoint "$CKPT_DIR/no_lora_256/latest.pt" \ |
| --target_tokens 256 \ |
| --max_samples 50 \ |
| --data_dir data \ |
| --output_dir "$RUN_DIR/no_lora_256" |
|
|
| run "clip_no_lora_256" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \ |
| --method_dir "$RUN_DIR/no_lora_256/uipress_256" \ |
| --ref_dir data/ref_screenshots \ |
| --clip_device cuda |
|
|
| |
| for tok in 64 128 512; do |
| run "train_token_${tok}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \ |
| --output_dir "$CKPT_DIR/token_${tok}" \ |
| --target_tokens "$tok" \ |
| --epochs "$EPOCHS_ABL" \ |
| --max_samples "$MAX_SAMPLES" \ |
| --mix_root data \ |
| --mix_images_subdir ref_screenshots \ |
| --mix_gt_subdir gt_html \ |
| --max_html_tokens 8192 |
|
|
| run "eval_token_${tok}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \ |
| --method uipress \ |
| --checkpoint "$CKPT_DIR/token_${tok}/latest.pt" \ |
| --target_tokens "$tok" \ |
| --max_samples 50 \ |
| --data_dir data \ |
| --output_dir "$RUN_DIR/token_${tok}" |
|
|
| run "clip_token_${tok}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \ |
| --method_dir "$RUN_DIR/token_${tok}/uipress_${tok}" \ |
| --ref_dir data/ref_screenshots \ |
| --clip_device cuda |
| done |
|
|
| |
| for lr in 1e-4 2e-4 4e-4; do |
| safe_lr="${lr//./p}" |
| run "train_lr_${safe_lr}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/train_compressor.py \ |
| --output_dir "$CKPT_DIR/lr_${safe_lr}" \ |
| --target_tokens 256 \ |
| --lr_compressor "$lr" \ |
| --epochs "$EPOCHS_ABL" \ |
| --max_samples "$MAX_SAMPLES" \ |
| --mix_root data \ |
| --mix_images_subdir ref_screenshots \ |
| --mix_gt_subdir gt_html \ |
| --max_html_tokens 8192 |
|
|
| run "eval_lr_${safe_lr}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/eval_all.py \ |
| --method uipress \ |
| --checkpoint "$CKPT_DIR/lr_${safe_lr}/latest.pt" \ |
| --target_tokens 256 \ |
| --max_samples 50 \ |
| --data_dir data \ |
| --output_dir "$RUN_DIR/lr_${safe_lr}" |
|
|
| run "clip_lr_${safe_lr}" \ |
| env CUDA_VISIBLE_DEVICES="$GPU_ID" python scripts/step_clip_batch.py \ |
| --method_dir "$RUN_DIR/lr_${safe_lr}/uipress_256" \ |
| --ref_dir data/ref_screenshots \ |
| --clip_device cuda |
| done |
|
|
| echo |
| echo "All GPU1 ablation jobs completed at $(date '+%F %T')." |
|
|