Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #369

Merged
merged 5 commits into from
Nov 30, 2022
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
1 change: 0 additions & 1 deletion examples/examples_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
astra-toolbox
bm4d>=4.0.0
colour_demosaicing
xdesign>=0.5.5
ray[tune]>=2.0.0
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ scipy>=1.6.0
tifffile
imageio>=2.17
matplotlib
jaxlib>=0.3.0,<=0.3.24
jax>=0.3.0,<=0.3.24
jaxlib>=0.3.0,<=0.3.25
jax>=0.3.0,<=0.3.25
flax>=0.4.0
bm3d>=3.0.9
bm3d>=4.0.0
bm4d>=4.2.2
svmbir>=0.3.0
pyabel>=0.8.5
35 changes: 2 additions & 33 deletions scico/denoiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,8 @@
# user license can be found in the 'LICENSE' file distributed with the
# package.

"""
Interfaces to standard denoisers.

**Warning**: The :func:`bm4d` function is implemented as an interface
to the `bm4d <https://pypi.org/project/bm4d>`__ package. The current
version of this package, 4.0.0, appears to be compiled with compiler
options that `change the behavior of the floating point unit
<https://moyix.blogspot.com/2022/09/someones-been-messing-with-my-subnormals.html>`__
in a way that results in lower numerical accuracy, and that persist
for the duration of the process that loads it. If this package is
installed, simply loading this module (:mod:`scico.denoiser`), is
sufficient to inflict this loss of numerical precision on all other
calculations run within the same process, even if :func:`bm4d` is not
actually used. Users who are not making use of :func:`bm4d` are
advised not to install the corresponding package. For additional
information, see `scico issue #342
<https://github.com/lanl/scico/issues/342>`__.
"""

import warnings
"""Interfaces to standard denoisers."""


import numpy as np

Expand All @@ -43,19 +25,6 @@
have_bm4d = False
else:
have_bm4d = True
finfo = np.finfo(np.float32) # type: ignore
if hasattr(finfo, "smallest_subnormal"): # can't test with older numpy versions
if finfo.smallest_subnormal == 0.0:
warnings.warn(
"Importing module bm4d has had an adverse affect on floating point "
"accuracy. See the documentation for module scico.denoiser, and "
"scico issue #342."
)
warnings.filterwarnings(
action="ignore",
message="^The value of the smallest subnormal",
category=UserWarning,
)

import scico.numpy as snp
from scico._flax import DnCNNNet, load_weights
Expand Down
6 changes: 3 additions & 3 deletions scico/test/functional/test_denoiser_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def setup_method(self):
def test_gry(self):
y0 = self.f_gry.prox(self.x_gry, 1.0)
y1 = denoiser.bm3d(self.x_gry, 1.0)
np.testing.assert_allclose(y0, y1, rtol=1e-5)
assert np.linalg.norm(y1 - y0) < 1e-3

def test_rgb(self):
y0 = self.f_rgb.prox(self.x_rgb, 1.0)
y1 = denoiser.bm3d(self.x_rgb, 1.0, is_rgb=True)
np.testing.assert_allclose(y0, y1, rtol=1e-5)
assert np.linalg.norm(y1 - y0) < 1e-3


# bm4d is known to be broken on OSX 11.6.5. It may be broken on earlier versions too,
Expand All @@ -44,7 +44,7 @@ def setup_method(self):
def test(self):
y0 = self.f.prox(self.x, 1.0)
y1 = denoiser.bm4d(self.x, 1.0)
np.testing.assert_allclose(y0, y1, rtol=1e-5)
assert np.linalg.norm(y1 - y0) < 1e-3


class TestDnCNN:
Expand Down
8 changes: 4 additions & 4 deletions scico/test/test_denoiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def test_shape(self):
def test_gry(self):
no_jit = bm3d(self.x_gry, 1.0)
jitted = jax.jit(bm3d)(self.x_gry, 1.0)
np.testing.assert_allclose(no_jit, jitted, rtol=1e-3)
assert np.linalg.norm(no_jit - jitted) < 1e-3
assert no_jit.dtype == np.float32
assert jitted.dtype == np.float32

def test_rgb(self):
no_jit = bm3d(self.x_rgb, 1.0)
jitted = jax.jit(bm3d)(self.x_rgb, 1.0, is_rgb=True)
np.testing.assert_allclose(no_jit, jitted, rtol=1e-3)
assert np.linalg.norm(no_jit - jitted) < 1e-3
assert no_jit.dtype == np.float32
assert jitted.dtype == np.float32

Expand Down Expand Up @@ -74,13 +74,13 @@ def test_shape(self):
def test_jit(self):
no_jit = bm4d(self.x1, 1.0)
jitted = jax.jit(bm4d)(self.x1, 1.0)
np.testing.assert_allclose(no_jit, jitted, rtol=1e-3)
assert np.linalg.norm(no_jit - jitted) < 1e-3
assert no_jit.dtype == np.float32
assert jitted.dtype == np.float32

no_jit = bm4d(self.x2, 1.0)
jitted = jax.jit(bm4d)(self.x2, 1.0)
np.testing.assert_allclose(no_jit, jitted, rtol=1e-3)
assert np.linalg.norm(no_jit - jitted) < 1e-3
assert no_jit.dtype == np.float32
assert jitted.dtype == np.float32

Expand Down