raheebhassan's picture
Added video compression
e6997e4
#!/bin/bash
# Example commands for ROI-VAE compression
# Covers: Car, Building, Person, Boat
# Make sure you're in the roi-vae directory
cd "$(dirname "$0")"
# Create results directory if it doesn't exist
mkdir -p results
echo "ROI-VAE Compression Examples"
echo "============================="
echo
# ---------------------------------------------------------
# 1. CAR
# ---------------------------------------------------------
echo "1. CAR (YOLO)"
echo "-------------"
# 1a. Only Image
echo "a) Compressing (Image Only)..."
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/car_compressed.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes car
# 1b. With Comparison
echo "b) Compressing (With Comparison)..."
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/car_comparison.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes car \
--highlight
echo
echo "---------------------------------------------------------"
echo
# ---------------------------------------------------------
# 2. BUILDING
# ---------------------------------------------------------
echo "2. BUILDING (SegFormer)"
echo "-----------------------"
# 2a. Only Image
echo "a) Compressing (Image Only)..."
python roi_compressor.py \
--input data/images/building/000571767ec7a593.jpg \
--output results/building_compressed.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-classes building
# 2b. With Comparison
echo "b) Compressing (With Comparison)..."
python roi_compressor.py \
--input data/images/building/000571767ec7a593.jpg \
--output results/building_comparison.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-classes building \
--highlight
echo
echo "---------------------------------------------------------"
echo
# ---------------------------------------------------------
# 3. PERSON
# ---------------------------------------------------------
echo "3. PERSON (YOLO)"
echo "----------------"
# 3a. Only Image
echo "a) Compressing (Image Only)..."
python roi_compressor.py \
--input data/images/person/kodim04.png \
--output results/person_compressed.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes person
# 3b. With Comparison
echo "b) Compressing (With Comparison)..."
python roi_compressor.py \
--input data/images/person/kodim04.png \
--output results/person_comparison.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes person \
--highlight
echo
echo "---------------------------------------------------------"
echo
# ---------------------------------------------------------
# 4. BOAT
# ---------------------------------------------------------
echo "4. BOAT (YOLO)"
echo "--------------"
# 4a. Only Image
echo "a) Compressing (Image Only)..."
python roi_compressor.py \
--input data/images/boat/kodim06.png \
--output results/boat_compressed.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes boat
# 4b. With Comparison
echo "b) Compressing (With Comparison)..."
python roi_compressor.py \
--input data/images/boat/kodim06.png \
--output results/boat_comparison.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.3 \
--seg-method yolo \
--seg-classes boat \
--highlight
echo
echo "---------------------------------------------------------"
echo
# ---------------------------------------------------------
# 5. PARAMETER COMPARISON
# ---------------------------------------------------------
echo "5. PARAMETER COMPARISON"
echo "-----------------------"
# 5a. Sigma Comparison (Background Quality)
echo "a) Sigma Comparison (Background Quality)..."
# Low Sigma (High Compression)
echo " - Low Sigma (0.1)"
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/sigma_low.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.1 \
--seg-method yolo \
--seg-classes car \
--highlight
# High Sigma (Low Compression)
echo " - High Sigma (0.9)"
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/sigma_high.jpg \
--checkpoint checkpoints/tic_lambda_0.0483.pth.tar \
--sigma 0.9 \
--seg-method yolo \
--seg-classes car \
--highlight
# 5b. Lambda Comparison (Rate-Distortion)
echo "b) Lambda Comparison (Rate-Distortion)..."
# Low Lambda
echo " - Low Lambda (0.013)"
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/lambda_low.jpg \
--checkpoint checkpoints/tic_lambda_0.013.pth.tar \
--sigma 0.3 \
--lambda 0.013 \
--N 128 \
--M 192 \
--seg-method yolo \
--seg-classes car \
--highlight
# High Lambda
echo " - High Lambda (0.0932)"
python roi_compressor.py \
--input data/images/car/0016cf15fa4d4e16.jpg \
--output results/lambda_high.jpg \
--checkpoint checkpoints/tic_lambda_0.0932.pth.tar \
--sigma 0.3 \
--lambda 0.0932 \
--seg-method yolo \
--seg-classes car \
--highlight
echo
echo "---------------------------------------------------------"
echo
# -------------------------------------------------
# 5. Standalone Segmentation (Mask R-CNN)
# -------------------------------------------------
echo "--- Running Standalone Segmentation (Mask R-CNN) ---"
python roi_segmenter.py \
--input images/car/0016cf15fa4d4e16.jpg \
--output results/mask_rcnn.png \
--method maskrcnn \
--classes car \
--visualize
# -------------------------------------------------
# 6. Video Compression (Static Mode)
# -------------------------------------------------
echo "--- Running Video Compression (Static Mode) ---"
python roi_compressor.py \
--input data/videos/traffic.mp4 \
--output results/video_static.mp4 \
--quality-level 4 \
--sigma 0.4 \
--seg-method yolo \
--seg-classes car person \
--video-mode static \
--output-fps 10
# -------------------------------------------------
# 7. Video Compression (Dynamic Mode)
# -------------------------------------------------
echo "--- Running Video Compression (Dynamic Mode) ---"
python roi_compressor.py \
--input data/videos/traffic.mp4 \
--output results/video_dynamic.mp4 \
--quality-level 4 \
--seg-method yolo \
--seg-classes car person \
--video-mode dynamic \
--target-bandwidth-kbps 800 \
--min-fps 5 \
--max-fps 20
# -------------------------------------------------
# 8. Video Detection Evaluation (Static Mode)
# -------------------------------------------------
echo "--- Running Video Detection Evaluation (Static Mode) ---"
python roi_detection_eval.py \
--before data/videos/traffic.mp4 \
--video-mode static \
--sigma 0.3 \
--output-fps 10 \
--quality-level 4 \
--seg-method yolo \
--seg-classes car person \
--detectors yolo \
--max-video-frames 30 \
--video-sample-interval 3 \
--save-after results/video_eval_compressed.mp4 \
--out results/video_detection_eval.json \
--viz-dir results/video_detection_viz
# -------------------------------------------------
# 9. Video Detection Evaluation (Comparing Two Videos)
# -------------------------------------------------
echo "--- Running Video Detection Evaluation (Compare Two Videos) ---"
python roi_detection_eval.py \
--before data/videos/traffic.mp4 \
--after results/video_static.mp4 \
--detectors yolo \
--max-video-frames 30 \
--video-sample-interval 3 \
--out results/video_compare_eval.json
echo
echo "============================="
echo "All examples complete! Check results/ directory"