Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions benchmarks/image_deblurring/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@ Solvers compared:
| `PrimalDual-TV` | Isotropic total variation regularization, with or without bound constraints on the pixel values, solved with the primal-dual algorithm (PyProximal) |
| `PrimalDual-DWT2D` | L1 sparsity of the image in one or more wavelet domains (analysis form, e.g. Haar, db4 or both stacked), solved with the primal-dual algorithm (PyProximal) |
| `LinearizedADMM-rMS` | Relaxed Mumford-Shah (truncated quadratic) penalty on the image gradient, nonconvex, solved with the linearized ADMM (PyProximal) |
| `PnP-ADMM-BM3D` | Plug-and-Play prior with the BM3D denoiser in place of the proximal operator of the regularizer, solved with ADMM (PyProximal) |
| `RED-BM3D` | Regularization by Denoising with the BM3D denoiser, solved with fixed-point iterations (PyProximal) |

All wavelet transforms are `pylops.signalprocessing.DWT2D` with 3 levels.
54 changes: 54 additions & 0 deletions benchmarks/image_deblurring/solvers/pnp_admm_bm3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import numpy as np
from benchopt import BaseSolver
from pyproximal import L2
from pyproximal.optimization.pnp import PlugAndPlay
from pyproximal.optimization.primal import ADMM

from pylops_bench.denoisers import bm3d_denoise


class Solver(BaseSolver):
r"""Plug-and-Play prior with the BM3D denoiser, solved with ADMM.

The proximal operator of the regularizer in
:func:`pyproximal.optimization.primal.ADMM` is replaced by the BM3D
denoiser (:func:`pylops_bench.denoisers.bm3d_denoise`), with noise
standard deviation :math:`\sigma \tau` relative to the 0-255 range of the
image (:func:`pyproximal.optimization.pnp.PlugAndPlay`). The proximal
operator of the data term :math:`\frac{1}{2} \|y - Op x\|_2^2` is
evaluated with a few warm-started inner iterations.
"""

name = "PnP-ADMM-BM3D"

requirements = ["pip::pylops", "pip::pyproximal", "pip::bm3d"]
sampling_strategy = "run_once"

parameters = {
"sigma": [0.004],
"tau": [15.0],
"niter": [60],
}

def set_objective(self, Op, y, meta):
self.dims = meta["dims"]
self.Op = Op
self.y = y
self.x0 = np.zeros(Op.shape[1], dtype=Op.dtype)

def run(self, _):
# warm-started proximal operators keep state between calls: build
# them at every run so that repeated runs give the same result
proxf = L2(Op=self.Op, b=self.y, niter=20, warm=True)
self.x = PlugAndPlay(
proxf,
lambda x, tau: bm3d_denoise(x, self.sigma * tau, scale=255.0),
self.dims,
x0=self.x0,
solver=ADMM,
tau=self.tau,
niter=self.niter,
)[0]

def get_result(self):
return dict(x=self.x.reshape(self.dims))
70 changes: 70 additions & 0 deletions benchmarks/image_deblurring/solvers/red_bm3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
from functools import partial

import numpy as np
from benchopt import BaseSolver
from pyproximal import L2
from pyproximal import RED as REDTerm
from pyproximal.optimization.red import RED

from pylops_bench.denoisers import bm3d_denoise


class Solver(BaseSolver):
r"""Regularization by Denoising (RED) with the BM3D denoiser, solved
with fixed-point iterations.

.. math::
\min_x \frac{1}{2} \|y - Op x\|_2^2
+ \sigma x^T (x - f_{\sigma_d}(x))

where :math:`f_{\sigma_d}` is the BM3D denoiser
(:func:`pylops_bench.denoisers.bm3d_denoise`) with noise standard
deviation :math:`\sigma_d` relative to the 0-255 range of the image.
Solved with :func:`pyproximal.optimization.red.RED` and
``solver="fixedpoint"``: each iteration denoises the current estimate and
solves the normal equations
:math:`(Op^H Op + \sigma I) x = Op^H y + \sigma f_{\sigma_d}(x)` with
``niter_inner`` LSQR iterations started from the current estimate.
"""

name = "RED-BM3D"

requirements = ["pip::pylops", "pip::pyproximal", "pip::bm3d"]
sampling_strategy = "run_once"

parameters = {
"sigma": [0.02],
"sigmad": [0.08],
"niter": [60],
"niter_inner": [50],
}

def set_objective(self, Op, y, meta):
self.dims = meta["dims"]
self.Op = Op
self.y = y
self.x0 = np.zeros(Op.shape[1], dtype=Op.dtype)

def run(self, _):
# the RED term keeps state between calls: build it at every run so
# that repeated runs give the same result (the fixed-point solver
# only uses the operator and data of the L2 term)
proxf = L2(Op=self.Op, b=self.y)
red = REDTerm(
partial(bm3d_denoise, scale=255.0),
self.dims,
sigma=self.sigma,
sigmad=self.sigmad,
call=False,
)
self.x = RED(
proxf,
red,
x0=self.x0,
solver="fixedpoint",
niter=self.niter,
niter_inner=self.niter_inner,
)

def get_result(self):
return dict(x=self.x.reshape(self.dims))
14 changes: 14 additions & 0 deletions benchmarks/image_denoising/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,23 @@ Solvers compared:
| `PrimalDual-DWT2D` | L1 sparsity of the image in one or more wavelet domains (analysis, e.g. Haar, db4 or both stacked), solved with the primal-dual algorithm (PyProximal) |
| `PrimalDual-TV-DWT2D` | Isotropic total variation plus L1 sparsity in the wavelet domain, solved with the primal-dual algorithm (PyProximal) |
| `FISTA-Patch2D` | L1 sparsity in overlapping local 2D DCT or FFT windows (`pylops.signalprocessing.Patch2D`), solved with FISTA |
| `PnP-ADMM-BM3D` | Plug-and-Play prior with the BM3D denoiser in place of the proximal operator of the regularizer, solved with ADMM (PyProximal) |
| `RED-BM3D` | Regularization by Denoising with the BM3D denoiser, solved with fixed-point iterations (PyProximal) |

All gradients are first-order forward differences and all wavelet
transforms are `pylops.signalprocessing.DWT2D`. Solvers that share a
formulation solve the same problem, so they converge to the same image:
their weights are tuned so that this image has the highest PSNR, and their
iterations so that they have converged.

`PnP-ADMM-BM3D` and `RED-BM3D` use the BM3D denoiser (hard-thresholding
stage, `pylops_bench.denoisers.bm3d_denoise`). Since the operator is the
identity, a single call of BM3D with the noise standard deviation of the data
(about 0.115) is already a strong baseline (29.6 dB). `PnP-ADMM-BM3D`
reaches the same PSNR: its best denoiser strength is close to the noise
level, and the iterations do not improve on a single call. `RED-BM3D` behaves
differently: its fixed point balances the data with a weak denoiser applied
repeatedly, and it is best with a large RED weight and a denoiser strength
well below the noise level (`sigma=5`, `sigmad=0.03`), reaching about 0.5 dB
less than a single BM3D call. Both solvers outperform the total variation
and wavelet solvers.
49 changes: 49 additions & 0 deletions benchmarks/image_denoising/solvers/pnp_admm_bm3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import numpy as np
from benchopt import BaseSolver
from pyproximal import L2
from pyproximal.optimization.pnp import PlugAndPlay
from pyproximal.optimization.primal import ADMM

from pylops_bench.denoisers import bm3d_denoise


class Solver(BaseSolver):
r"""Plug-and-Play prior with the BM3D denoiser, solved with ADMM.

The proximal operator of the regularizer in
:func:`pyproximal.optimization.primal.ADMM` is replaced by the BM3D
denoiser (:func:`pylops_bench.denoisers.bm3d_denoise`), with noise
standard deviation :math:`\sigma \tau`
(:func:`pyproximal.optimization.pnp.PlugAndPlay`). The proximal operator
of the data term :math:`\frac{1}{2} \|y - x\|_2^2` is in closed form.
"""

name = "PnP-ADMM-BM3D"

requirements = ["pip::pylops", "pip::pyproximal", "pip::bm3d"]
sampling_strategy = "run_once"

parameters = {
"sigma": [0.11],
"tau": [1.0],
"niter": [10],
}

def set_objective(self, Op, y, meta):
self.dims = meta["dims"]
self.proxf = L2(b=y)
self.x0 = np.zeros(Op.shape[1], dtype=Op.dtype)

def run(self, _):
self.x = PlugAndPlay(
self.proxf,
lambda x, tau: bm3d_denoise(x, self.sigma * tau),
self.dims,
x0=self.x0,
solver=ADMM,
tau=self.tau,
niter=self.niter,
)[0]

def get_result(self):
return dict(x=self.x.reshape(self.dims))
66 changes: 66 additions & 0 deletions benchmarks/image_denoising/solvers/red_bm3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from benchopt import BaseSolver
from pyproximal import L2
from pyproximal import RED as REDTerm
from pyproximal.optimization.red import RED

from pylops_bench.denoisers import bm3d_denoise


class Solver(BaseSolver):
r"""Regularization by Denoising (RED) with the BM3D denoiser, solved
with fixed-point iterations.

.. math::
\min_x \frac{1}{2} \|y - x\|_2^2
+ \sigma x^T (x - f_{\sigma_d}(x))

where :math:`f_{\sigma_d}` is the BM3D denoiser
(:func:`pylops_bench.denoisers.bm3d_denoise`) with noise standard
deviation :math:`\sigma_d`.
Solved with :func:`pyproximal.optimization.red.RED` and
``solver="fixedpoint"``: each iteration denoises the current estimate and
solves :math:`(1 + \sigma) x = y + \sigma f_{\sigma_d}(x)` (one LSQR
iteration, exact for the identity operator), starting from the noisy
image.
"""

name = "RED-BM3D"

requirements = ["pip::pylops", "pip::pyproximal", "pip::bm3d"]
sampling_strategy = "run_once"

parameters = {
"sigma": [5.0],
"sigmad": [0.03],
"niter": [30],
}

def set_objective(self, Op, y, meta):
self.dims = meta["dims"]
self.Op = Op
self.y = y
self.x0 = y.copy()

def run(self, _):
# the RED term keeps state between calls: build it at every run so
# that repeated runs give the same result (the fixed-point solver
# only uses the operator and data of the L2 term)
proxf = L2(Op=self.Op, b=self.y)
red = REDTerm(
bm3d_denoise,
self.dims,
sigma=self.sigma,
sigmad=self.sigmad,
call=False,
)
self.x = RED(
proxf,
red,
x0=self.x0,
solver="fixedpoint",
niter=self.niter,
niter_inner=1,
)

def get_result(self):
return dict(x=self.x.reshape(self.dims))
2 changes: 2 additions & 0 deletions benchmarks/seismic_poststack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ Solvers compared:
| `ADMML2-TV` | Isotropic total variation regularization, solved with ADMM specialized for an L2 misfit (PyProximal) |
| `ADMM-TV` | Total variation regularization, solved with ADMM with an iterative TV proximal operator (PyProximal) |
| `PrimalDual-TV` | Isotropic total variation regularization, solved with the primal-dual algorithm (PyProximal) |
| `PnP-ADMM-BM3D` | Plug-and-Play prior with the BM3D denoiser in place of the proximal operator of the regularizer, solved with ADMM (PyProximal) |
| `RED-BM3D` | Regularization by Denoising with the BM3D denoiser, solved with fixed-point iterations (PyProximal) |

All total variation solvers use `pylops.Gradient` with forward differences.
54 changes: 54 additions & 0 deletions benchmarks/seismic_poststack/solvers/pnp_admm_bm3d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
from benchopt import BaseSolver
from pyproximal import L2
from pyproximal.optimization.pnp import PlugAndPlay
from pyproximal.optimization.primal import ADMM

from pylops_bench.denoisers import bm3d_denoise


class Solver(BaseSolver):
r"""Plug-and-Play prior with the BM3D denoiser, solved with ADMM.

The proximal operator of the regularizer in
:func:`pyproximal.optimization.primal.ADMM` is replaced by the BM3D
denoiser (:func:`pylops_bench.denoisers.bm3d_denoise`), with noise
standard deviation :math:`\sigma \tau`
(:func:`pyproximal.optimization.pnp.PlugAndPlay`), starting from the
background model. The proximal operator of the data term
:math:`\frac{1}{2} \|y - Op x\|_2^2` is evaluated with 20 warm-started
LSQR iterations.
"""

name = "PnP-ADMM-BM3D"

requirements = ["pip::pylops", "pip::pyproximal", "pip::bm3d"]
sampling_strategy = "run_once"

parameters = {
"sigma": [0.2],
"tau": [1.0],
"niter": [30],
}

def set_objective(self, Op, y, meta):
self.dims = meta["dims"]
self.Op = Op
self.y = y
self.x0 = meta["mback"].ravel()

def run(self, _):
# warm-started proximal operators keep state between calls: build
# them at every run so that repeated runs give the same result
proxf = L2(Op=self.Op, b=self.y, x0=self.x0, niter=20, warm=True)
self.x = PlugAndPlay(
proxf,
lambda x, tau: bm3d_denoise(x, self.sigma * tau),
self.dims,
x0=self.x0,
solver=ADMM,
tau=self.tau,
niter=self.niter,
)[0]

def get_result(self):
return dict(x=self.x.reshape(self.dims))
Loading
Loading