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

Add universal image loader #234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

minhtien-trinh
Copy link

Features include:

  • Dask array conversion for flexible chunking
  • VRAM check to ensure memory sufficiency
  • Zarr-backed optimization check for efficient handling of large images

This PR is part of the issue from spatialdata.

Note: This is a work in progress; initial testing is complete, but further validation is needed.

Features include:
- Dask array conversion for flexible chunking
- VRAM check to ensure memory sufficiency
- Zarr-backed optimization check for efficient handling of large images

Note: This is a work in progress; initial testing is complete, but further validation is needed.
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.87%. Comparing base (cff4896) to head (00d360e).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #234      +/-   ##
==========================================
- Coverage   45.50%   35.87%   -9.64%     
==========================================
  Files          22       22              
  Lines        2149     2149              
==========================================
- Hits          978      771     -207     
- Misses       1171     1378     +207     

see 5 files with indirect coverage changes

@lucas-diedrich
Copy link

Hi! This PR and its related issue were referenced here.

We also work with large imaging datasets that exceed memory capacity, particularly CZI and whole-slide imaging files. A strategy that has worked well for us is:

  1. Lazily loading data in small chunks using a custom image reader wrapped with dask.delayed,
  2. Passing the chunks to dask.array (via dask.array.from_delayed), which is memory-mapped and avoids memory overflow,
  3. Reassembling the chunks into a dask.array or Image2DModel.

You can find our implementation here.

For TIFF files, tifffile.memmap could potentially be used for lazy loading, as it returns a memory-mapped NumPy array. This approach does not extend to jpeg and png files. Would love to hear your thoughts!

@LucaMarconato LucaMarconato marked this pull request as draft February 10, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants