cuCIM Documentation

repository·main·Indexed 19 days ago

https://github.com/rapidsai/cucim

An extensible, GPU-accelerated toolkit for I/O, computer vision, and image processing of N-Dimensional images, specifically designed for large biomedical and geospatial datasets. It provides a Pythonic interface matching the OpenSlide API and supports formats including Aperio ScanScope Virtual Slide (SVS), Philips TIFF, and generic tiled multi-resolution RGB TIFF files. The library includes the cuslide2 plugin for GPU-accelerated TIFF decoding via nvImageCodec and supports GPUDirect Storage (GDS) for accelerated reads.

Tokens
14.7K
Snippets
39
Records
61
Agent score
66%

What's inside cuCIM

  1. Overview of GDS benchmarking example scripts

    main

    This directory contains scripts for benchmarking reads of uncompressed TIFF images using CPU-based tools (openslide-python, tifffile) versus accelerated reads using kvikio with GPUDirect Storage (GDS) enabled or disabled.

    Available Scripts:

    • benchmark_read.py: Benchmarks reads of a full image at a specific resolution level from an uncompressed multi-resolution TIFF.
    • benchmark_round_trip.py: Benchmarks reading from uncompressed TIFF while writing to an uncompressed Zarr file (matching tile size).
    • benchmark_zarr_write.py: Benchmarks writing a CuPy array to an uncompressed Zarr file with a specified chunk size.
    • benchmark_zarr_write_lz4_via_dask.py: Uses Dask and kvikio.zarr.GDSStore to write LZ4 lossless compressed Zarr arrays.
    • lz4_nvcomp.py: An LZ4 compressor designed for use with kvikio.zarr.GDSStore.
    • demo_implementation.py: Contains the tiled read/write implementations used by the benchmark scripts.
  2. Overview of NVIDIA cuCIM

    main

    NVIDIA cuCIM (Compute Unified Architecture Clara IMage) is an open-source library designed for accelerated computer vision and image processing of multidimensional images. It is specifically optimized for biomedical, geospatial, material/life science, and remote sensing use cases.

    Key Capabilities

    cuCIM provides GPU-accelerated I/O and primitives for N-Dimensional images, including:

    • Image Processing: Color conversion, exposure, filters, morphology, registration, restoration, segmentation, and transforms.
    • Analysis: Feature extraction, measurement, and metrics.

    Supported Image Formats

    • Aperio ScanScope Virtual Slide (SVS)
    • Philips TIFF
    • Generic Tiled, Multi-resolution RGB TIFF files (supporting No Compression, JPEG, JPEG2000, LZW, and Deflate compression).

    API Compatibility and Interoperability

    • API Design: The API mirrors scikit-image for image manipulation and OpenSlide for image loading.
    • Workflow Interoperability: Works with Albumentations, cuPY, DALI, JFX, MONAI, Numba, NumPy, PyTorch, TensorFlow, and Triton.
  3. What is cuCIM and its supported formats?

    main

    cuCIM is an open-source, GPU-accelerated library for multidimensional image processing in biomedical, geospatial, and life science use cases. It provides a Pythonic interface matching the OpenSlide API.

    Supported Formats:

    • Aperio ScanScope Virtual Slide (SVS)
    • Philips TIFF
    • Generic Tiled, Multi-resolution RGB TIFF files (supporting No Compression, JPEG, JPEG2000, LZW, and Deflate compression).
  4. Use the cuslide2 plugin

    main

    Starting with version 26.04, the cuslide plugin is deprecated and will be removed in 26.08. You should migrate to cuslide2, which uses nvImageCodec for GPU-accelerated TIFF decoding and provides tile-level caching and async batch decoding.

    To enable the cuslide2 plugin, set the ENABLE_CUSLIDE2 environment variable to 1 before running your Python script.

    ENABLE_CUSLIDE2=1 python your_script.py
  5. Convert SVS images to uncompressed TIFF using cuCIM CLI

    main

    The benchmarking scripts in this example require uncompressed data. You can convert .svs files to raw (uncompressed) TIFF images using the cucim convert command.

    Note: The example scripts have the filename resize.tiff hardcoded, so if you use a different output name, you must update the scripts accordingly.

    cucim convert --tile-size 512 --overlap 0 --num-workers 12 --output-filename resize.tiff --compression RAW TUPAC-TR-467.svs
  6. Download sample images for notebooks

    main

    If you are using the provided notebooks, you can download sample input images into the notebooks/input folder using the repository's helper script or via Docker.

    # Using the repository helper script
    ./run download_testdata
    
    # Or using Docker directly
    mkdir -p notebooks/input
    tmp_id=$(docker create gigony/svs-testdata:little-big)
    docker cp $tmp_id:/input notebooks
    docker rm -v ${tmp_id}
  7. Build the cuCIM documentation

    main

    To build the documentation locally, you need a Python environment with the dependencies specified in requirement.txt. After installing the requirements, use the make command to generate the HTML output.

    The generated documentation will be located at build/html/index.html.

    # 1. Install dependencies
    pip install -r requirement.txt
    
    # 2. Build the HTML documentation
    make html
  8. Install cuCIM via Conda

    main

    You can install cuCIM using Conda from the rapidsai or rapidsai-nightly channels. You must specify a CUDA version of 12.0 or higher.

    # Install stable version
    conda create -n cucim -c rapidsai -c conda-forge cucim cuda-version=`<CUDA version>`
    
    # Install nightly version
    conda create -n cucim -c rapidsai-nightly -c conda-forge cucim cuda-version=`<CUDA version>`
  9. Integrate cuCIM with DALI and Albumentations

    main

    cuCIM is designed for interoperability with common data loading and augmentation pipelines:

    • NVIDIA DALI: Seamlessly work with the Data Loading Library for high-performance preprocessing.
    • Albumentations: Integrate with the Albumentations library for image augmentation workflows.