Skip to content

Commit

Permalink
Merge pull request #240 from stardist/dev
Browse files Browse the repository at this point in the history
Changes for 0.8.4 release
  • Loading branch information
uschmidt83 committed Jul 18, 2023
2 parents 468c605 + 74f2bfe commit ebbc7ad
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 39 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/cibuildwheel.yml
Expand Up @@ -22,8 +22,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
py: [cp36, cp37, cp38, cp39, cp310]
os: [ubuntu-20.04, windows-2019, macos-11]
py: [cp36, cp37, cp38, cp39, cp310, cp311]

steps:
- uses: actions/checkout@v3
Expand All @@ -37,6 +37,7 @@ jobs:
- name: Install cibuildwheel
run: python -m pip install cibuildwheel

# https://scikit-learn.org/stable/developers/advanced_installation.html#macos
- name: Setup OpenMP (macOS)
if: startsWith(matrix.os, 'macos')
shell: bash
Expand All @@ -47,9 +48,9 @@ jobs:
tee -a $GITHUB_ENV << END
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CFLAGS=${CFLAGS} -I${HOMEBREW_PREFIX}/include
CXXFLAGS=${CXXFLAGS} -I${HOMEBREW_PREFIX}/include
LDFLAGS=${LDFLAGS} -Wl,-rpath,${HOMEBREW_PREFIX}/lib -L${HOMEBREW_PREFIX}/lib -lomp
CFLAGS=${CFLAGS} -I${HOMEBREW_PREFIX}/opt/libomp/include
CXXFLAGS=${CXXFLAGS} -I${HOMEBREW_PREFIX}/opt/libomp/include
LDFLAGS=${LDFLAGS} -Wl,-rpath,${HOMEBREW_PREFIX}/opt/libomp/lib -L${HOMEBREW_PREFIX}/opt/libomp/lib -lomp
END
- name: Build wheels for CPython (macOS)
Expand Down Expand Up @@ -128,4 +129,4 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
# password: ${{ secrets.TESTPYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# repository-url: https://test.pypi.org/legacy/
17 changes: 12 additions & 5 deletions .github/workflows/tests.yml
Expand Up @@ -19,16 +19,18 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
tensorflow: [1, 2]
exclude:
# https://www.tensorflow.org/install/pip#system-requirements
# https://www.tensorflow.org/install/source#tested_build_configurations
- python-version: '3.8'
tensorflow: 1
- python-version: '3.9'
tensorflow: 1
- python-version: '3.10'
tensorflow: 1
- python-version: '3.11'
tensorflow: 1
- os: windows-latest
tensorflow: 1

Expand All @@ -51,7 +53,7 @@ jobs:
if: matrix.python-version == 3.9
run: pip install edt "numpy>=1.20"

# # should also work with clang, but there are
# # should also work with clang, but there are
# # openmp-related symbol issues just when using Python 3.6?
# - name: Use GCC on macOS
# if: startsWith(matrix.os, 'macos')
Expand All @@ -66,8 +68,13 @@ jobs:

- name: Install bioimage.io dependencies
if: |
matrix.python-version >= 3.7 &&
matrix.python-version == 3.7 &&
matrix.tensorflow == 1
run: pip install ".[bioimageio]"

- run: pytest -v --durations=50 -m "not gpu"
- name: Disable PytestReturnNotNoneWarning (Python 3.7+)
if: matrix.python-version != 3.6
run: echo "PYTEST_ADDOPTS='-W ignore::pytest.PytestReturnNotNoneWarning'" >> $GITHUB_ENV
shell: bash

- run: pytest -m "not gpu"
15 changes: 11 additions & 4 deletions .github/workflows/tests_cron.yml
Expand Up @@ -14,16 +14,18 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
tensorflow: [1, 2]
exclude:
# https://www.tensorflow.org/install/pip#system-requirements
# https://www.tensorflow.org/install/source#tested_build_configurations
- python-version: '3.8'
tensorflow: 1
- python-version: '3.9'
tensorflow: 1
- python-version: '3.10'
tensorflow: 1
- python-version: '3.11'
tensorflow: 1
- os: windows-latest
tensorflow: 1

Expand Down Expand Up @@ -65,8 +67,13 @@ jobs:
- name: Install bioimage.io dependencies
if: |
matrix.python-version >= 3.7 &&
matrix.python-version == 3.7 &&
matrix.tensorflow == 1
run: pip install "stardist[bioimageio]"

- run: pytest -v --durations=50 -m "not gpu"
- name: Disable PytestReturnNotNoneWarning (Python 3.7+)
if: matrix.python-version != 3.6
run: echo "PYTEST_ADDOPTS='-W ignore::pytest.PytestReturnNotNoneWarning'" >> $GITHUB_ENV
shell: bash

- run: pytest -m "not gpu"
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -3,6 +3,7 @@
[![Test](https://github.com/stardist/stardist/workflows/Test/badge.svg)](https://github.com/stardist/stardist/actions?query=workflow%3ATest)
[![Test (PyPI)](https://github.com/stardist/stardist/workflows/Test%20(PyPI)/badge.svg)](https://github.com/stardist/stardist/actions?query=workflow%3A%22Test+%28PyPI%29%22)
[![Image.sc forum](https://img.shields.io/badge/dynamic/json.svg?label=forum&url=https%3A%2F%2Fforum.image.sc%2Ftags%2Fstardist.json&query=%24.topic_list.tags.0.topic_count&colorB=brightgreen&suffix=%20topics&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAABPklEQVR42m3SyyqFURTA8Y2BER0TDyExZ+aSPIKUlPIITFzKeQWXwhBlQrmFgUzMMFLKZeguBu5y+//17dP3nc5vuPdee6299gohUYYaDGOyyACq4JmQVoFujOMR77hNfOAGM+hBOQqB9TjHD36xhAa04RCuuXeKOvwHVWIKL9jCK2bRiV284QgL8MwEjAneeo9VNOEaBhzALGtoRy02cIcWhE34jj5YxgW+E5Z4iTPkMYpPLCNY3hdOYEfNbKYdmNngZ1jyEzw7h7AIb3fRTQ95OAZ6yQpGYHMMtOTgouktYwxuXsHgWLLl+4x++Kx1FJrjLTagA77bTPvYgw1rRqY56e+w7GNYsqX6JfPwi7aR+Y5SA+BXtKIRfkfJAYgj14tpOF6+I46c4/cAM3UhM3JxyKsxiOIhH0IO6SH/A1Kb1WBeUjbkAAAAAElFTkSuQmCC)](https://forum.image.sc/tags/stardist)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/stardist)](https://pypistats.org/packages/stardist)

# *StarDist* - Object Detection with Star-convex Shapes

Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
@@ -1,8 +1,8 @@
FROM tensorflow/tensorflow:1.15.4-gpu-py3-jupyter
FROM tensorflow/tensorflow:2.11.0-gpu-jupyter

LABEL maintainer="ko.sugawara@ens-lyon.fr"

ARG NVIDIA_DRIVER_VERSION=455
ARG NVIDIA_DRIVER_VERSION=470

RUN apt-get update && apt-get install -y --no-install-recommends \
ocl-icd-dev \
Expand Down
14 changes: 8 additions & 6 deletions docker/README.md
Expand Up @@ -4,24 +4,26 @@ With this Docker image, you can run *StarDist* with [GPU support](https://www.te

[gputools](https://github.com/maweigert/gputools) and [Multi-Label Anisotropic 3D Euclidean Distance Transform (MLAEDT-3D)](https://github.com/seung-lab/euclidean-distance-transform-3d) are also included.

This Docker image is extended from `tensorflow/tensorflow:1.15.4-gpu-py3-jupyter`, which is based on `Ubuntu 18.04` with `CUDA 10.0` and `Python 3.6.9`.
This Docker image is extended from `tensorflow/tensorflow:2.11.0-gpu-jupyter`, which is based on `Ubuntu 20.04.5 LTS` with `CUDA 11.2` and `Python 3.8.10`.

### Prerequisites

- [Docker 19.03](https://docs.docker.com/install/)
- NVIDIA Driver
- [NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker)

For further information, see the [TensorFlow Docker documentation](https://www.tensorflow.org/install/docker).

### Building image

# assuming that you are in the docker/ directory
docker build -t stardist --build-arg NVIDIA_DRIVER_VERSION=455 .
docker build -t stardist --build-arg NVIDIA_DRIVER_VERSION=470 .

Please change the `NVIDIA_DRIVER_VERSION` depending on your environment.

This argument is used to install an appropriate package for running OpenCL.
Try `nvidia-smi | grep "Driver Version"` or `cat /proc/driver/nvidia/version` to find your driver version.

The default value is `455` and `390`|`410`|`418`|`430`|`435`|`440`|`450`|`455`|`460` are available.
This argument is used to install an appropriate package for running OpenCL.

### Usage example

Expand All @@ -32,6 +34,6 @@ This command will launch a jupyter notebook as root, binding the project root di

### Notes

- Please see the [Dockerfile](Dockerfile) and [its parent image](https://hub.docker.com/layers/tensorflow/tensorflow/1.15.4-gpu-py3-jupyter/images/sha256-ef81875f4f24bec719e3b064ad8b83d8ed0e602981a19499d65d31f67424e645) for details.
- Please see the [Dockerfile](Dockerfile) and [its parent image](https://hub.docker.com/layers/tensorflow/tensorflow/2.11.0-gpu-jupyter/images/sha256-fc519621eb9a54591721e9019f1606688c9abb329b16b00cc7107c23f14a6f24) for details.
- Please follow the instructions for the usage of [Docker + NVIDIA Container Toolkit](https://github.com/NVIDIA/nvidia-docker).
- Previous versions of Docker + nvidia-docker2 might work as well but we have not tested.
- Previous versions of Docker + nvidia-docker2 might work as well but have not been tested.
12 changes: 11 additions & 1 deletion pyproject.toml
@@ -1,3 +1,13 @@
[build-system]
requires = ["setuptools>=40.8.0", "wheel", "oldest-supported-numpy"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"

[tool.pytest.ini_options]
addopts = "-v --durations=50"
testpaths = [
"tests",
]
# only works for pytest >= 7.2.0, which isn't available for Python 3.6
# filterwarnings = [
# "ignore::pytest.PytestReturnNotNoneWarning"
# ]
2 changes: 1 addition & 1 deletion setup.cfg
@@ -1,2 +1,2 @@
[metadata]
description-file = README.md
description_file = README.md
10 changes: 7 additions & 3 deletions setup.py
Expand Up @@ -122,18 +122,22 @@ def compile_patched(obj, src, ext, cc_args, extra_postargs, pp_opts):
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],

install_requires=[
'csbdeep>=0.6.3',
'csbdeep>=0.7.4',
'scikit-image',
'numba',
'imageio',
],

extras_require={
"tf1": ["csbdeep[tf1]>=0.6.3"],
"test": ["pytest"],
"tf1": ["csbdeep[tf1]>=0.7.4"],
"test": [
"pytest; python_version< '3.7'",
"pytest>=7.2.0; python_version>='3.7'",
],
"bioimageio": ["bioimageio.core>=0.5.0","importlib-metadata"],
},

Expand Down
8 changes: 5 additions & 3 deletions stardist/models/base.py
Expand Up @@ -179,7 +179,7 @@ def __init__(self, X, Y, n_rays, grid, batch_size, patch_size, length,
from gputools import max_filter
self.max_filter = lambda y, patch_size: max_filter(y.astype(np.float32), patch_size)
else:
from scipy.ndimage.filters import maximum_filter
from scipy.ndimage import maximum_filter
self.max_filter = lambda y, patch_size: maximum_filter(y, patch_size, mode='constant')

self.maxfilter_patch_size = maxfilter_patch_size if maxfilter_patch_size is not None else self.patch_size
Expand Down Expand Up @@ -467,6 +467,7 @@ def _predict_generator(self, img, axes=None, normalizer=None, n_tiles=None, show
"""

predict_kwargs.setdefault('verbose', 0)
x, axes, axes_net, axes_net_div_by, _permute_axes, resizer, n_tiles, grid, grid_dict, channel, predict_direct, tiling_setup = \
self._predict_setup(img, axes, normalizer, n_tiles, show_tile_progress, predict_kwargs)

Expand Down Expand Up @@ -534,6 +535,7 @@ def _predict_sparse_generator(self, img, prob_thresh=None, axes=None, normalizer
"""
if prob_thresh is None: prob_thresh = self.thresholds.prob

predict_kwargs.setdefault('verbose', 0)
x, axes, axes_net, axes_net_div_by, _permute_axes, resizer, n_tiles, grid, grid_dict, channel, predict_direct, tiling_setup = \
self._predict_setup(img, axes, normalizer, n_tiles, show_tile_progress, predict_kwargs)

Expand Down Expand Up @@ -1066,8 +1068,8 @@ def _compute_receptive_field(self, img_size=None):
x = np.zeros((1,)+img_size+(self.config.n_channel_in,), dtype=np.float32)
z = np.zeros_like(x)
x[(0,)+mid+(slice(None),)] = 1
y = self.keras_model.predict(x)[0][0,...,0]
y0 = self.keras_model.predict(z)[0][0,...,0]
y = self.keras_model.predict(x, verbose=0)[0][0,...,0]
y0 = self.keras_model.predict(z, verbose=0)[0][0,...,0]
grid = tuple((np.array(x.shape[1:-1])/np.array(y.shape)).astype(int))
assert grid == self.config.grid
y = zoom(y, grid,order=0)
Expand Down
3 changes: 2 additions & 1 deletion stardist/models/model2d.py
Expand Up @@ -234,7 +234,8 @@ def __init__(self, axes='YX', n_rays=32, n_channel_in=1, grid=(1,1), n_classes=N
self.train_n_val_patches = None
self.train_tensorboard = True
# the parameter 'min_delta' was called 'epsilon' for keras<=2.1.5
min_delta_key = 'epsilon' if LooseVersion(keras.__version__)<=LooseVersion('2.1.5') else 'min_delta'
# keras.__version__ was removed in tensorflow 2.13.0
min_delta_key = 'epsilon' if LooseVersion(getattr(keras, '__version__', '9.9.9'))<=LooseVersion('2.1.5') else 'min_delta'
self.train_reduce_lr = {'factor': 0.5, 'patience': 40, min_delta_key: 0}

self.use_gpu = False
Expand Down
3 changes: 2 additions & 1 deletion stardist/models/model3d.py
Expand Up @@ -272,7 +272,8 @@ def __init__(self, axes='ZYX', rays=None, n_channel_in=1, grid=(1,1,1), n_classe
self.train_n_val_patches = None
self.train_tensorboard = True
# the parameter 'min_delta' was called 'epsilon' for keras<=2.1.5
min_delta_key = 'epsilon' if LooseVersion(keras.__version__)<=LooseVersion('2.1.5') else 'min_delta'
# keras.__version__ was removed in tensorflow 2.13.0
min_delta_key = 'epsilon' if LooseVersion(getattr(keras, '__version__', '9.9.9'))<=LooseVersion('2.1.5') else 'min_delta'
self.train_reduce_lr = {'factor': 0.5, 'patience': 40, min_delta_key: 0}

self.use_gpu = False
Expand Down
8 changes: 4 additions & 4 deletions stardist/utils.py
Expand Up @@ -7,8 +7,8 @@
from tqdm import tqdm
from collections import defaultdict
from zipfile import ZipFile, ZIP_DEFLATED
from scipy.ndimage.morphology import distance_transform_edt, binary_fill_holes
from scipy.ndimage.measurements import find_objects
from scipy.ndimage import distance_transform_edt, binary_fill_holes
from scipy.ndimage import find_objects
from scipy.optimize import minimize_scalar
from skimage.measure import regionprops
from csbdeep.utils import _raise
Expand Down Expand Up @@ -365,9 +365,9 @@ def mask_to_categorical(y, n_classes, classes, return_cls_dict=False):
for cls, labels in cls_dict.items():
if cls is None:
# prob == -1 will be used in the loss to ignore object
y_mask[np.isin(y, labels)] = -1
y_mask[np.isin(y, labels), :] = -1
elif np.issubdtype(type(cls), np.integer) and 0 <= cls <= n_classes:
y_mask[...,cls] = np.isin(y, labels)
y_mask[np.isin(y, labels), cls] = 1
else:
raise ValueError(f"Wrong class id '{cls}' (for n_classes={n_classes})")

Expand Down
2 changes: 1 addition & 1 deletion stardist/version.py
@@ -1 +1 @@
__version__ = '0.8.3'
__version__ = '0.8.4'
2 changes: 1 addition & 1 deletion tests/utils.py
Expand Up @@ -2,7 +2,7 @@
import numpy as np
from tifffile import imread
from skimage.measure import label
from scipy.ndimage.filters import gaussian_filter
from scipy.ndimage import gaussian_filter
from pathlib import Path
from timeit import default_timer
from csbdeep.utils.tf import keras_import
Expand Down

0 comments on commit ebbc7ad

Please sign in to comment.