Skip to content

Commit 90f7620

Browse files
committed
julian comments
1 parent 9d28b63 commit 90f7620

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

deepinv/models/ram.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@
1414

1515
class RAM(Reconstructor, Denoiser):
1616
r"""
17-
Reconstruct Anything Model.
17+
Reconstruct Anything Model (RAM) foundation model.
1818
19-
This model (proposed in `this paper <https://arxiv.org/abs/2503.08915>`_) is a convolutional neural network (CNN)
20-
designed for image reconstruction tasks.
19+
Convolutional neural network model :footcite:t:`terris2025reconstruct` that has been trained to work on a large variety
20+
of linear image reconstruction tasks and datasets (deblurring, inpainting, denoising, tomography, MRI, etc.).
21+
22+
See :ref:`sphx_glr_auto_examples_unfolded_demo_ram.py` for examples on the performance of RAM and how to fine-tune the
23+
foundation model on a specific problem and dataset.
24+
25+
The model works both as a reconstructor or denoiser:
26+
27+
* Reconstructor: RAM takes a :ref:`physics operator <physics>` `model(y, physics)` with an optional noise model defined in the physics
28+
* Denoiser: RAM takes optional Gaussian and/or Poisson noise levels (optionally set to 0) `model(y, sigma=sigma, gamma=gamma)`
29+
30+
.. note::
31+
32+
The physics operator should be normalized (i.e. have unit norm) for best results.
33+
Use :func:`physics.compute_norm() <deepinv.physics.LinearPhysics.compute_norm>` to check this.
2134
2235
:param list in_channels: Number of input channels. If a list is provided, the model will have separate heads for each channel.
2336
:param str device: Device to which the model should be moved. If None, the model will be created on the default device.
@@ -241,10 +254,10 @@ def forward(self, y, physics=None, sigma=None, gain=None):
241254

242255
x_in = physics.A_adjoint(y)
243256

244-
sigma = self.threshold_snr(sigma, y, physics, threshold=self.sigma_threshold)
257+
sigma = self.threshold_snr(x_temp, sigma, threshold=self.sigma_threshold)
245258
sigma = self._handle_sigma(sigma)
246259

247-
gain = self.threshold_snr(gain, y, physics, threshold=self.gain_threshold)
260+
gain = self.threshold_snr(x_temp, gain, threshold=self.gain_threshold)
248261
gain = self._handle_sigma(gain)
249262

250263
out = self.forward_unet(x_in, sigma=sigma, gain=gain, physics=physics, y=y)
@@ -253,15 +266,14 @@ def forward(self, y, physics=None, sigma=None, gain=None):
253266

254267
return out
255268

256-
def threshold_snr(self, val, y, physics, threshold=1e-2, eps=1e-6):
269+
def threshold_snr(self, Aty, val, threshold=1e-2, eps=1e-6):
257270
r"""
258271
Performs the operation
259272
260273
.. math::
261274
\text{threshold\_snr}(x) = \max(\frac{\text{val}}{\|A^\top y\|/\sqrt{m} + \epsilon}, \text{threshold}) * \|A^\top y\|/\sqrt{m}
262275
263276
"""
264-
Aty = physics.A_adjoint(y)
265277
num = Aty.pow(2).mean(dim=tuple(range(1, Aty.ndim))).sqrt()
266278
val_threshold = torch.maximum(val / (num + eps), torch.tensor(threshold)) * num
267279
return val_threshold

docs/source/refs.bib

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,4 +992,11 @@ @inproceedings{pajot2019unsupervised
992992
author={Pajot, Arthur and De B{\'e}zenac, Emmanuel and Gallinari, Patrick},
993993
booktitle={International conference on learning representations},
994994
year={2019}
995+
}
996+
997+
@article{terris2025reconstruct,
998+
title={Reconstruct Anything Model: a lightweight foundation model for computational imaging},
999+
author={Terris, Matthieu and Hurault, Samuel and Song, Maxime and Tachella, Juli{\'a}n},
1000+
journal={arXiv preprint arXiv:2503.08915},
1001+
year={2025}
9951002
}

0 commit comments

Comments
 (0)