This repository contains our implementation and experiments for accelerating DiffDehaze toward deployment-oriented image dehazing for autonomous systems.
The work is documented in Final_report.pdf and focuses on:
- low-latency diffusion dehazing through step reduction
- AccSamp-based accelerated inference
- INT8 quantization-aware training (QAT)
- safety-proxy evaluation for autonomous perception pipelines
The codebase builds on the original Learning Hazing to Dehazing / DiffDehaze implementation and extends it with profiling, evaluation, and QAT-oriented inference/training utilities.
Diffusion dehazing models produce strong restoration quality, but their iterative reverse process is expensive for real-time systems. This project studies how far DiffDehaze can be accelerated without making the outputs unsuitable for safety-critical perception.
The report introduces two main acceleration directions:
- Step reduction for reverse diffusion
- Quantization-aware training for reduced-precision deployment
To evaluate whether faster dehazing remains usable for autonomous systems, the project also introduces a safety-proxy evaluation framework based on image-level Safety Performance Indicators (SPIs).
From the final report:
- up to
4.2xinference speedup - only
1.9%degradation in SPI metrics 20-stepinference gives a2.2xspeedup with only a small SPI drop relative to the vanilla setting
Core model and sampler code:
diffbir/: diffusion model, ControlLDM, samplers, utilitiesdatasets.py: stage-1 and stage-2 dataset definitionsconfigs/: train and inference configs
Training and inference entry points:
train_stage1.py: train haze generation stagetrain_stage2.py: train dehazing stagetrain_stage2_QAT.py: stage-2 quantization-aware traininginference_stage1.py: stage-1 haze generationinference_stage2.py: standard dehazing inferenceinference_accsamp.py: accelerated dehazing with AccSampinference_accsamp_qat.py: accelerated inference for QAT/plain checkpointsinference_stage2_profile.py: profiling for standard dehazinginference_accsamp_profile.py: profiling for accelerated dehazing
Evaluation:
eval/evaluator.py: safety-proxy evaluator with visibility, hallucination, and photometric checks
The repository works with the DiffDehaze pipeline, which uses a latent diffusion model with ControlLDM + IRControlNet.
The acceleration study in the report is centered on:
- reducing the denoising step count
- using AccSamp restart parameters
tauandomega - evaluating reduced-precision execution through QAT
- measuring the latency-quality trade-off with SPIs instead of restoration metrics alone
The report describes the denoiser as the dominant bottleneck, accounting for roughly 96% of end-to-end latency.
The report introduces a deployment-oriented evaluation framework for autonomous systems. In code, this is implemented in eval/evaluator.py.
The evaluator combines three groups of signals:
SPI-1: visibility improvementSPI-2: hallucination risk through structure or high-frequency inflationSPI-3: photometric stability
The evaluator reports:
- overall score
- verdict:
good,acceptable,borderline, orhigh-risk - haze index, contrast, edge density, Laplacian variance, clipping rate, exposure, and color cast
- optional pairwise ratios when a hazy reference is available
Clone the repository and create an environment:
git clone https://github.com/JWLMay/Project-285.git
cd Project-285
conda create -n diffdehaze-av python=3.10
conda activate diffdehaze-av
pip install -r requirements.txtrequirements.txt targets:
- Python
3.10 - PyTorch
2.2.2 - CUDA
11.8 acceleratexformers- TensorBoard
Place checkpoints in weights/ unless you change paths in the YAML configs.
Expected files include:
weights/v2-1_512-ema-pruned.ckpt- stage-1 checkpoint for haze generation
- stage-2 checkpoint for dehazing
- optional QAT checkpoint for
inference_accsamp_qat.py
Most configs already assume the Stable Diffusion backbone checkpoint and local experiment folders.
configs/train/stage1.yaml uses HybridTrainingData and expects:
- synthetic clean images in
rgb_500/ - corresponding depth maps in
depth_500/ - real hazy
.jpgimages for unpaired haze supervision
This matches the original HazeGen setup inherited from the base project.
configs/train/stage2.yaml and configs/train/stage2_qat.yaml use StaticPairedData and expect:
hazy_folderclean_folder
The current dataset loader assumes:
- hazy images are named like
name_index.* - the matching clean image is
name.jpg
If your filenames differ, update datasets.py.
Put images in inputs/ unless you change image_folder in the config.
python inference_stage2.py --config configs/inference/stage2.yamlOptional controls:
python inference_stage2.py \
--config configs/inference/stage2.yaml \
--steps 50 \
--eta 1.0python inference_accsamp.py --config configs/inference/stage2_accsamp.yamlImportant config fields:
tauomegacontrolnet_pathresult_folder
The default accelerated script uses 30 diffusion steps.
python inference_accsamp_qat.py --config configs/inference/stage2_accsamp_qat.yamlThis script can load either:
- a plain controlnet checkpoint
- a QAT checkpoint with fake-quant weights
Configure Hugging Face Accelerate first:
accelerate configaccelerate launch train_stage1.py --config configs/train/stage1.yamlaccelerate launch train_stage2.py --config configs/train/stage2.yamlaccelerate launch --num_processes 1 train_stage2_QAT.py --config configs/train/stage2_qat.yamlThe QAT config includes:
qat: trueqat_observer_freeze_step: 40000
Profile inference:
python inference_stage2_profile.py --config configs/inference/stage2.yaml --steps 50
python inference_accsamp_profile.py --config configs/inference/stage2_accsamp.yaml --steps 30Run the safety-proxy evaluator by importing AVSafetyProxyEvaluator from eval/evaluator.py or adapting the example block in that file.
The final report evaluates the system with:
- model:
DiffDehaze (ControlLDM + IRControlNet) - train dataset:
RESIDE OTS - validation dataset:
nuScenes with synthesized haze - GPU:
NVIDIA RTX A6000 - prompt:
"remove dense fog" - inference steps:
{50, 40, 30, 20, 10} - restart parameters:
tau in {0.8, 0.6},omega in {0.6, 0.4} - guidance: weighted SSIM, scale
0.1
- Several scripts hard-code
CUDA_VISIBLE_DEVICESnear the top. Adjust them for your machine. - Some paths in configs point to local experiment folders. Review YAML files before running.
- The repository still contains stage-1 haze generation code from the original project, but the final report’s main contribution is the accelerated stage-2 dehazing pipeline and its safety-aware evaluation.
- Quantization results in the report are presented mainly as an accuracy-feasibility study; hardware-level INT8 latency gains were not fully validated on specialized accelerators.
This project is built on:
- DiffBIR
- the
Learning Hazing to Dehazing/DiffDehazework by Wang et al.
If you need the original base paper behind the inherited dehazing pipeline:
@inproceedings{wang2025learning,
title={Learning Hazing to Dehazing: Towards Realistic Haze Generation for Real-World Image Dehazing},
author={Wang, Ruiyi and Zheng, Yushuo and Zhang, Zicheng and Li, Chunyi and Liu, Shuaicheng and Zhai, Guangtao and Liu, Xiaohong},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={23091--23100},
year={2025}
}Apache License 2.0. See LICENSE.