Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8de5d2f
docs: change project name to HoloPASWIN
electricalgorithm Nov 22, 2025
473bba8
docs: refine project description in README.md
electricalgorithm Nov 22, 2025
fd5f0ea
feat: add version 2 - complex field support
electricalgorithm Dec 11, 2025
7e335ff
feat: add third experiment results with complex field
electricalgorithm Dec 12, 2025
a9407eb
fix(inference): adopt the inference script to v2
electricalgorithm Dec 12, 2025
6abfe17
feat: add residual connection to swin
electricalgorithm Dec 12, 2025
0877d12
feat(train): add interrupt-saves for fallbacks
electricalgorithm Dec 12, 2025
9a4e5f8
feat: improve loss by adding phase and amp
electricalgorithm Dec 13, 2025
ba8f358
feat: add experiment results
electricalgorithm Dec 13, 2025
0a6e031
feat: add experiment 8 that uses 224x224 dataset
electricalgorithm Dec 13, 2025
c24276e
refactor: remove outdated notebooks
electricalgorithm Dec 14, 2025
b9a64e6
chore: fix linting and types for pre-commit
electricalgorithm Dec 14, 2025
f187493
chore: track pth files with git-lfs
electricalgorithm Dec 14, 2025
a7fe148
feat(exp9): Complete Experiment 9 (25k samples, 8 configs) with SOTA …
electricalgorithm Jan 15, 2026
9ca4e23
feat(scripts): add hf publisher
electricalgorithm Jan 15, 2026
14bed96
docs(arch): add network arch ascii diagram
electricalgorithm Jan 31, 2026
1870a96
feat: add ablation for loss weights
electricalgorithm Jan 31, 2026
fa7567a
feat: add inference fps benchmark
electricalgorithm Jan 31, 2026
39c12ab
feat: add zoom figure producer
electricalgorithm Jan 31, 2026
a36d27a
feat: add b/s metric
electricalgorithm Jan 31, 2026
a581c5a
refactor: move scripts to scripts dir
electricalgorithm Jan 31, 2026
8e06aa3
refactor: apply ruff formatter and linters
electricalgorithm Jan 31, 2026
e171dc3
feat(testing): add ablation study scripts
electricalgorithm Feb 3, 2026
04c31d4
fix(robustness): use the correct propagator on robustness test
electricalgorithm Feb 3, 2026
a81fe8f
feat: add script for architectural comparison
electricalgorithm Feb 3, 2026
659162b
feat: add more experiments
electricalgorithm Feb 4, 2026
76c9b01
feat: add experiment 12
electricalgorithm Feb 19, 2026
f9b095b
feat: add old experiment results
electricalgorithm Feb 19, 2026
b8a81da
feat: add baseline comparison
electricalgorithm Feb 20, 2026
0eece8d
feat: add ablation study results except robustness
electricalgorithm Feb 20, 2026
1292ac2
refactor: fix ruff issues
electricalgorithm Feb 20, 2026
988f50f
feat: add hrnet holographic model on baselines
electricalgorithm Feb 20, 2026
9ef687b
docs: add github pages
electricalgorithm Feb 28, 2026
f111845
refactor: remove unused images
electricalgorithm Feb 28, 2026
8285892
docs: update website links and add BibTeX
electricalgorithm Mar 8, 2026
194c72d
docs: improve README for better visibility and quick reading
electricalgorithm Mar 12, 2026
69df9c0
docs: re-word the overview section to be more natural
electricalgorithm Mar 12, 2026
3ddcbf2
docs: add brief technical explanation of the network architecture
electricalgorithm Mar 12, 2026
eb016ef
docs: user edits to README
electricalgorithm Mar 12, 2026
2c76a25
docs: separate installation from usage and detail train, test, and in…
electricalgorithm Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.venv
__pycache__
**/*.parquet
checkpoints/
logs/
.DS_Store
.env
.pytest_cache/
.ruff_cache/
.cursor/
.cursor/
**/*egg-info*
94 changes: 83 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,95 @@
# HOLO-PASWIN: In-Line Holographical Physics-Aware SWIN Transformer
<div align="center">

A research-grade deep learning project for eliminating the **twin-image problem in in-line holography** using a **physics-aware Swin-UNet architecture** trained with synthetic holograms generated via the Angular Spectrum Method.
# HoloPASWIN

Build a modern, high-performing, physics-aware neural architecture capable of reconstructing complex object fields ( $\hat{O} = \hat{O}_{real} + i\hat{O}_{imag}$ ) from inline holograms while robustly suppressing **twin-image artifacts**, **noise**, and **aberrations**.
**Robust Inline Holographic Reconstruction via Physics-Aware Swin Transformers**

## Development Setup
[![Paper](https://img.shields.io/badge/arXiv-2603.04926-b31b1b.svg)](https://arxiv.org/abs/2603.04926)
[![Model](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Models-FFD21E)](https://huggingface.co/gokhankocmarli/holopaswin-v3)
[![Dataset](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Dataset-FFD21E)](https://huggingface.co/datasets/gokhankocmarli/inline-digital-holography-v3)
[![Website](https://img.shields.io/badge/Project-Website-blue)](https://electricalgorithm.github.io/holopaswin/)

### Installing Git Hooks
<img src="./docs/images/comparison.png" width="800">

This repository includes pre-commit hooks that automatically run code quality checks (ruff and mypy) before each commit. To install them:
*HoloPASWIN recovers clean phase and amplitude mappings from a single intensity hologram, directly eliminating twin-image artifacts.*
</div>

## Overview

HoloPASWIN is a deep learning framework designed to eliminate the twin-image artifact in inline digital holography. While inline holography is an effective lensless imaging technique, the loss of phase information during capturing causes an out-of-focus duplicate (twin-image) to permanently degrade the reconstructed object.

This repository implements a Physics-Aware Swin Transformer U-Net that inherently corrects and removes these artifacts. By integrating a forward physics model (the Angular Spectrum Method) with the Swin Transformer's global attention, HoloPASWIN achieves robust phase recovery and high structural fidelity across varying noise levels and distances.


## Network Architecture

<img src="./docs/images/architecture.png" width="800">

HoloPASWIN utilizes a U-shaped architecture based on Swin Transformer blocks. The model first processes an input intensity hologram using the backward Angular Spectrum Method (ASM) to obtain an initial, artifact-heavy complex field. A 4-stage Swin Encoder-Decoder network then extracts multi-scale features to predict a residual correction. By adding this correction to the initial field and training with both frequency-domain constraints and a physics-based forward propagation loss, the network robustly recovers the clean phase and amplitude.


## Installation

This project uses [uv](https://github.com/astral-sh/uv) for fast and reliable dependency management.

1. **Install uv** (if not already installed):
```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2. **Sync Dependencies**:
Navigate to the `holopaswin` directory and run:
```bash
uv sync
```
This creates a virtual environment and installs all locked dependencies from `uv.lock`.

## Usage

### Training

To train the model from scratch on the dataset, run:

```bash
uv run src/train.py
```

### Inference & Testing

To evaluate a trained model and generate visualization results on test samples, run:

```bash
uv run src/inference.py
```

To calculate full quantitative metrics (SSIM, PSNR, MSE) over the test dataset, run:

```bash
uv run src/test.py
```

### Development

This repository includes pre-commit hooks that automatically run code quality checks (`ruff` and `mypy`) before each commit. To install them:

```bash
./scripts/install-hooks.sh
```

This will set up the hooks from `.githooks/` to `.git/hooks/`. The hooks will:
- Run `ruff check` on `src/`
- Run `ruff format --check` on `src/`
- Run `mypy --strict` on `src/`
If any check fails, the commit will be blocked.

## Citation

If any check fails, the commit will be blocked. You can bypass the hook with `git commit --no-verify` (not recommended).
If you find this code, dataset, or model useful for your research, please cite our paper:

```bibtex
@misc{kocmarli2026holopaswinrobustinlineholographic,
title={HoloPASWIN: Robust Inline Holographic Reconstruction via Physics-Aware Swin Transformers},
author={Gökhan Koçmarlı and G. Bora Esmer},
year={2026},
eprint={2603.04926},
archivePrefix={arXiv},
primaryClass={eess.IV},
url={https://arxiv.org/abs/2603.04926},
}
```
Binary file added docs/images/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/detailed_comparison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/z_mismatch_plot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading