Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
b1bfd60
reuse spec.utils.load_image
FynnBe Jul 28, 2026
e049644
wip load zarr images
FynnBe Jul 28, 2026
c2f9126
bump pyright
FynnBe Jul 28, 2026
919c407
fix optional dask.array import
FynnBe Jul 30, 2026
d099ea2
add dask[array] as dev dependency
FynnBe Jul 31, 2026
f1cd356
CI pyright fixes
FynnBe Jul 31, 2026
6c42ef1
WIP support non-path sources in CLI
FynnBe Aug 3, 2026
91c0ffe
ruff check --fix
FynnBe Aug 3, 2026
b36e81b
ruff check --fix --unsafe-fixes
FynnBe Aug 3, 2026
8a813d2
manual ruff fixes
FynnBe Aug 3, 2026
d6b2521
allow creating singleton block shapes along missing axes
FynnBe Aug 3, 2026
4b0bd09
add eval-type-backport
FynnBe Aug 6, 2026
faab176
load_tensor bioio/imageio/clearscale/numpy
FynnBe Aug 14, 2026
8e0429e
expose missing_dims in create_sample_for_model
FynnBe Aug 18, 2026
bfc7042
add argument devices to predict
FynnBe Aug 18, 2026
f95474c
load/save zarr arrays
FynnBe Aug 19, 2026
e1002d5
load/save tiff files with metadata
FynnBe Aug 25, 2026
f483007
Merge remote-tracking branch 'origin/main' into zarr_simple
FynnBe Aug 25, 2026
571c8be
unstack while saving blockwise
FynnBe Aug 25, 2026
8dcc6c1
WIP unstacked shapes
FynnBe Aug 27, 2026
409fc9f
WIP handle multi-index batch axis
FynnBe Sep 1, 2026
41aa51f
fix predict_many
FynnBe Sep 1, 2026
b6ceaa6
patch likely omitted size references for blockwise processing
FynnBe Sep 1, 2026
bed1bda
keep track of unstacked axis order
FynnBe Sep 9, 2026
1aec384
add test_description_serializer_roundtrip
FynnBe Sep 10, 2026
b2aa745
WIP blockwise multi-index support
FynnBe Sep 11, 2026
e9787ab
gradio prediction step timeout and multi-index gradio tests
FynnBe Sep 15, 2026
ca31fea
limit block shape to shape instead of failing
FynnBe Sep 15, 2026
a6d3046
remove stride arguments
FynnBe Sep 15, 2026
12c2aea
add test_save_sample
FynnBe Sep 16, 2026
d4f2ada
WIP lazy forward
FynnBe Oct 7, 2026
f03e99b
fix halo treatment at sample edge
FynnBe Oct 9, 2026
a558b3e
WIP improve blockwise processing
FynnBe Oct 13, 2026
b42469a
WIP improve laziness
FynnBe Oct 13, 2026
524b95c
debug with PYDEVD_USE_SYS_MONITORING=0 to avoid skipping breakpoints
FynnBe Oct 15, 2026
c81a4c4
improve loading zarr arrays with bioio_ome_zarr
FynnBe Oct 15, 2026
d52466e
polish lazy prediction changes
FynnBe Oct 16, 2026
96f8d3b
fix gradio tests
FynnBe Oct 16, 2026
b179121
update test matrix
FynnBe Oct 16, 2026
85e8b54
improve clearscale testing
FynnBe Oct 19, 2026
9b3f5dc
improve typing
FynnBe Oct 19, 2026
6151c29
fix pyright errors caused by unresolvable optional clearscale import
Copilot Oct 19, 2026
2f8e085
type check with xarray >=2025.03
FynnBe Oct 19, 2026
3f619ed
ignore unknown clearscale type
FynnBe Oct 19, 2026
b2ef29f
fix tests
FynnBe Oct 19, 2026
ea946d2
Pad short serialized descriptions instead of raising
Copilot Oct 19, 2026
69045c5
order prediction method kwargs logically
FynnBe Oct 19, 2026
ed2fd45
update dev deps modifiers
FynnBe Oct 19, 2026
98eac39
add apply_input_padding and apply_output_cropping
FynnBe Oct 19, 2026
ebf96ab
default to no progressbar in github CI
FynnBe Oct 19, 2026
320a339
skip tiff related tests for py <3.12
FynnBe Oct 19, 2026
b073b19
skip bioio-ome-zarr dev dep for py<3.11
FynnBe Oct 19, 2026
bf6242a
improve test_predict_with_fixed_blocking
FynnBe Oct 19, 2026
57fb5fc
Make Zarr tests optional-aware
Copilot Oct 19, 2026
566b488
Fix Pyright failures in CI
Copilot Oct 19, 2026
8e60b25
in-memory dataset percnetile computation + pre/postproc caching + chu…
FynnBe Oct 20, 2026
47db38e
add padding to fit valid block shape
FynnBe Oct 21, 2026
11d0231
account for missing tif tags XResolution, YResolution
FynnBe Oct 21, 2026
ef57073
fix finding block_shape in _predict_with_blocking_impl for samples sm…
FynnBe Oct 21, 2026
9ac193d
add support for safetensors (fixes #497)
FynnBe Oct 22, 2026
bf398a8
skip python 3.14 and 3.15 builds for now
FynnBe Oct 22, 2026
c59aa94
increase pytest timeout
FynnBe Oct 22, 2026
19676d4
improve tensor metadata handling
FynnBe Oct 22, 2026
2357b38
Merge remote-tracking branch 'origin/copilot/fix-github-actions-job-f…
FynnBe Oct 22, 2026
d3a9abe
fix laziness and add model adapter stats
FynnBe Oct 29, 2026
98fbcd9
bump spec
FynnBe Oct 29, 2026
71dc300
add tensor io with h5py
FynnBe Oct 29, 2026
b5651ce
support unstacked extra dims in predict
FynnBe Oct 29, 2026
5f7f955
respect given 'ns' blocksize_parameter 0
FynnBe Oct 30, 2026
419604c
fix block_shape fill
FynnBe Oct 30, 2026
772053f
explicitly update zarr_atts
FynnBe Oct 30, 2026
b75f6fa
respect dims order in get_physical_scale
FynnBe Oct 30, 2026
140e83c
prettify _LocalModelAdapterStats.__str__
FynnBe Oct 30, 2026
b0278f9
set slots arg independent of python version
FynnBe Oct 30, 2026
253a3be
log tensor io messages as info
FynnBe Oct 30, 2026
de4ec73
add tests
FynnBe Nov 2, 2026
c20d909
improve tests and api
FynnBe Nov 3, 2026
b6703db
ruff check --fix
FynnBe Nov 3, 2026
f61942b
adapting to python>=3.10
FynnBe Nov 4, 2026
4ebf491
clean up and fix output with extra dims
FynnBe Nov 6, 2026
0bccd2a
avoid silent datset stats update
FynnBe Nov 6, 2026
c85ac8b
avoid slow file save due to pylance
FynnBe Nov 6, 2026
1744abf
WIP make measures aware of preceding ops
FynnBe Nov 11, 2026
244d9a9
add todo
FynnBe Nov 11, 2026
0787d29
make Operator non-generic
FynnBe Nov 11, 2026
4a7e42c
fixed local files serialization for 0.4 models in spec
FynnBe Nov 12, 2026
4b97d98
WIP cleanup applied_ops
FynnBe Nov 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
24 changes: 12 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,22 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: '3.9'
numpy-version: 1
- python-version: '3.9'
numpy-version: 2
- python-version: '3.10'
run-expensive-tests: true
report-coverage: true
save-cache: true
numpy-version: 1
- python-version: '3.11'
numpy-version: 2
- python-version: '3.12'
numpy-version: 1
- python-version: '3.12'
numpy-version: 2
spec-from-main: true
# - python-version: '3.13'
- python-version: '3.13'
numpy-version: 2
run-expensive-tests: true
report-coverage: true
save-cache: true
# - python-version: '3.14'
# numpy-version: 2
# spec-from-main: true
# - python-version: '3.15'
# numpy-version: 2

steps:
Expand All @@ -99,6 +98,7 @@ jobs:
run: |
pip install --upgrade pip
pip install -e .[dev,partners] numpy==${{matrix.numpy-version}}.*
pip install git+https://github.com/ilastik/clearscale.git # TODO: remove once clearscale is in dev deps
- name: Pyright
if: matrix.run-expensive-tests # pyright is not expensive, but we only want to run it once due to otherwise inconsistent typing
run: |
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
name: coverage.xml
- uses: orgoro/coverage@v3.2
- uses: orgoro/coverage@v3.3
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -252,7 +252,7 @@ jobs:
path: dist
- uses: actions/setup-python@v6
with:
python-version: '3.12'
python-version: '3.13'
cache: 'pip'
- run: pip install -e .[dev,docs,partners]
- name: Check doc scripts
Expand Down
22 changes: 15 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.8
hooks:
- id: ruff-check
args: [--fix, --show-fixes]
- repo: local
hooks:
- id: ruff-check
name: ruff check
entry: ruff check --fix --show-fixes
language: system
pass_filenames: true
files: ^.*\.py$
always_run: false
- id: ruff-format
name: ruff format
entry: ruff format
language: system
pass_filenames: true
files: ^.*\.py$
always_run: false
- id: pyright
name: pyright
entry: pyright
language: system
always_run: true
always_run: false
pass_filenames: true
files: ^.*\.py$
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File / Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": [
"debug-test"
],
"justMyCode": false,
"env": {
// The monitoring backend skips project files named io.py.
"PYDEVD_USE_SYS_MONITORING": "0"
}
}
]
}
59 changes: 34 additions & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
{
"window.title": "bioimageio.core",
"python.analysis.languageServerMode": "full",
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python-envs.pythonProjects": [
{
"path": "",
"envManager": "ms-python.python:conda",
"packageManager": "ms-python.python:conda"
}
],
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.unusedImports": "explicit",
"source.organizeImports": "explicit"
},
}
{
"window.title": "bioimageio.core",
"python.languageServer": "Pylance",
"python.analysis.diagnosticMode": "workspace",
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.codeActionsOnSave": {
"source.unusedImports": "never",
"source.organizeImports": "never",
"source.fixAll.pylance": "never",
"source.fixAll.ruff": "explicit",
"source.organizeImports.ruff": "explicit"
}
},
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda",
"python-envs.pythonProjects": [
{
"path": ".",
"envManager": "ms-python.python:conda",
"packageManager": "ms-python.python:conda"
}
],
}
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ and compute selected dataset statistics used for preprocessing.

[Here you find the bioimageio.core documentation.](https://bioimage-io.github.io/core-bioimage-io-python)

#### Examples
### Examples

Notebooks that save and load resource descriptions and validate their format (using <a href="https://bioimage-io.github.io/spec-bioimage-io/">bioimageio.spec</a>, a dependency of bioimageio.core)
<ul>
Expand All @@ -38,10 +38,15 @@ Use the described resources in Python with <a href="https://bioimage-io.github.i
</a></li>
</ul>

#### Presentations
### Presentations

- [Create a model from scratch](https://bioimage-io.github.io/core-bioimage-io-python/presentations/create_ambitious_sloth.slides.html) ([source](https://github.com/bioimage-io/core-bioimage-io-python/tree/main/presentations))

## Use of AI

This project is AI assisted,
see [aidecl.yaml](aidecl.yaml) (following [AI Declaration Format](https://ai-declaration.org/)) for details.

## Set up Development Environment

To set up a development environment run the following commands:
Expand Down
38 changes: 38 additions & 0 deletions aidecl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
schema_version: 1.0.0
project:
name: bioimageio.core
content_type: software
repository: https://github.com/bioimage-io/core-bioimage-io-python
version: 0.12.0
license: MIT
ai_usage:
used: true
summary: >-
GitHub Copilot and OpenAI Codex were used for writing unit tests, usage examples and initial drafts of the library
code and doc strings.
level: moderate
tools:
- name: GitHub Copilot
type: assistant
hosting: cloud_vendor
purpose: Test generation and component scaffolding
- name: OpenAI Codex
type: assistant
hosting: cloud
purpose: Test generation and component scaffolding
scope:
code_generation: true
testing: true
documentation: true
code_completion: true
refactoring: true
infrastructure: true
debugging: true
code_proportion:
ai_generated_percent: 15
ai_assisted_percent: 25
human_only_percent: 60
method: self_reported
declaration:
declared_by: Fynn Beuttenmueller
date: '2026-10-13'
13 changes: 12 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
### 0.12.0

- bump spec to 0.5.14.4
- lazy prediction (via dask graph)
- support loading zarr images
- add option to compute (percentile) dataset statistics in-memory
- add experimental caching to disk for `predict()`
- dropped `is_volume` flag from `load_image()`
- added support to load pytorch state dict weights from .safetensors file

### 0.11.0

- bump spec to 0.5.12.0
Expand Down Expand Up @@ -67,7 +77,8 @@
### 0.9.4

- bump bioimageio.spec library version to 0.5.5.6
- Replace `conda activate <env name>` with `conda run -n <env name> python --version` when checking if a conda environment exists
- Replace `conda activate <env name>` with `conda run -n <env name> python --version`
when checking if a conda environment exists
(This is closer to the actual `conda run` command we need and avoids requests by conda to rerun `conda init` (in CI).)
- remove upper xarray pin (use ops from xarray.computation.ops, fallback to xarray.core.ops for older xarray versions)

Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test:
requires:
{% for dep in pyproject['project']['optional-dependencies']['dev'] %}
{% if 'torch' not in dep %} # can't install pytorch>=2.8 from conda-forge smh
- {{ dep.replace('[mcp]', '').replace(';python_version>="3.10"', '').replace(';python_version<"3.10"', '').lower().replace('_', '-') }}
- {{ dep.replace('[array]', '').replace('[mcp]', '').replace(';python_version>="3.10"', '').replace(';python_version<"3.10"', '').lower().replace('_', '-') }}
{% endif %}
{% endfor %}
commands:
Expand Down
13 changes: 0 additions & 13 deletions conftest.py

This file was deleted.

2 changes: 0 additions & 2 deletions example/dataset_statistics_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
"outputs": [],
"source": [
"import warnings\n",
"\n",
"from pprint import pprint\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import xarray as xr\n",
"\n",
"from matplotlib.patches import Rectangle\n",
"\n",
"warnings.filterwarnings(\"ignore\")\n",
Expand Down
8 changes: 7 additions & 1 deletion example/export_cellpose_model/bioimageio_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def sha256sum(path: Path) -> str:
h.update(chunk)
return h.hexdigest()


if __name__ == "__main__":
logger.enable("bioimageio")

Expand Down Expand Up @@ -192,5 +193,10 @@ def sha256sum(path: Path) -> str:
descr, output_path=Path("output/cpsam_bioimageio.zip")
)

summary = test_model(descr, working_dir=Path("output/export_test"), absolute_tolerance=1e-3, relative_tolerance=1e-3)
summary = test_model(
descr,
working_dir=Path("output/export_test"),
absolute_tolerance=1e-3,
relative_tolerance=1e-3,
)
summary.display()
2 changes: 2 additions & 0 deletions example/export_sam3_encoder/bioimageio_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def _open(self, name, mode="r", pwd=None, *, force_zip64=False):
return _orig_open(self, name, mode, pwd, force_zip64=force_zip64)

zipfile.ZipFile.open = _open


from bioimageio.spec.model.v0_5 import (
ArchitectureFromFileDescr,
AxisId,
Expand Down
2 changes: 1 addition & 1 deletion example/export_sam3_encoder/sam3_encoder_bioimageio.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
from __future__ import annotations

import torch
import torch.nn as nn
from sam3.model_builder import build_sam3_image_model
from torch import nn


class Sam3EncoderBioImageIO(nn.Module):
Expand Down
9 changes: 6 additions & 3 deletions example/export_sam3_encoder/sam3_original.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import imageio.v3 as imageio
import numpy as np
import torch

from sam3_encoder_bioimageio import Sam3EncoderBioImageIO

# SAM 3 was trained at 1008x1008 (patch size 14 -> 72x72 feature grid).
Expand Down Expand Up @@ -53,8 +52,12 @@ def resize_to_square(img: np.ndarray, size: int) -> np.ndarray:

def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--checkpoint", default=DEFAULT_CKPT, help="SAM 3 .pt checkpoint")
parser.add_argument("--image", default="sample_input.png", help="input RGB image")
_ = parser.add_argument(
"--checkpoint", default=DEFAULT_CKPT, help="SAM 3 .pt checkpoint"
)
_ = parser.add_argument(
"--image", default="sample_input.png", help="input RGB image"
)
args = parser.parse_args()

os.chdir(Path(__file__).parent)
Expand Down
Loading