Skip to main content

A U-Net implementation of the EfficientNetV2.

Project description

License PyPI Python Version CI codecov

A U-Net implementation of the EfficientNetV2.

EfficientV2-UNet

This package is a U-Net implementation of the EfficientNetV2, using TensorFlow.

EfficientNetV2 improves speed and parameter efficiency. This implementation also uses the ImageNet weights for training new models.

It is intended for segmentation of histological images (RGB) that are not saved in pyramidal file format (WSI).

The output segmentation are foreground / background. Multi-class segmentation is not (yet) possible.

It works on TIF images (and probably also PNG).

Installation

  1. Create a python environment (e.g. with conda, python=3.9 and 3.10 work), in a CLI:

    conda create --name myenv python=3.9

  2. Activate environment:

    conda activate myenv

  3. GPU support for Windows (Non GPU installations not extensively tested)

    a. Install the cudatoolkit and cudnn, e.g. with conda:

    conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0

    • Windows requires a specific version of TensorFlow (i.e. v2.10.1, higher versions are not supported on Windows), which will be installed by this package.

    • Linux GPU support and Apple Silicon support will be resolved by installing this library.

  4. Install this library

    pip install efficientv2-unet

  5. Verify the GPU-support:

    python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))" >> lists your active GPU

    or

    python -c "import tensorflow as tf; print(tf.test.is_gpu_available())" >> prints true if GPU enabled

Data preparation

Mask should have background values of 0, and foreground values of 1.

At least 3 image/mask TIF pairs are required to train a model, and should be located in separate folders.

Folder Structure:

├── images
   ├── image1.tif
   ├── image2.tif
   ├── image3.tif
   └── ...
└── masks
   ├── image1.tif
   ├── image2.tif
   ├── image3.tif
   └── ...

Training a model will split the data into train, validation and test images (by default 70%, 15%, 15%, respectively). And the images will be moved to corresponding sub-folders.

Training is performed not on the full images but on tiles (with no overlap), which will be saved into corresponding sub-folders.

Usage

Command-line:

ev2unet --help

# train example:
ev2unet --train --images path/to/images --masks path/to/masks --basedir . --name myUNetName --basemodel b2 --epochs 50

# predict example:
ev2unet --predict --dir path/to/images --model ./models/myUnetName/myUNetName.h5 --resolution 1 --threshold 0.5

Jupyter notebooks

Examples are also available from this repository.

QuPath extension

Get the QuPath extension!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

efficientv2_unet-0.0.4.tar.gz (8.9 MB view details)

Uploaded Source

Built Distribution

efficientv2_unet-0.0.4-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file efficientv2_unet-0.0.4.tar.gz.

File metadata

  • Download URL: efficientv2_unet-0.0.4.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for efficientv2_unet-0.0.4.tar.gz
Algorithm Hash digest
SHA256 22e6aa3e6da8bbe4b6880fcc945f9181e02d03b8f8d92dc927c208f0aabdbb86
MD5 4d98f95f7d72948ac7edea7dc4c3e93e
BLAKE2b-256 a7d37945aa91c3c730a79f9a145e91daa96bf7b54d43d80c6a9d19ca8fedfd6c

See more details on using hashes here.

File details

Details for the file efficientv2_unet-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for efficientv2_unet-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 79bd2625b8eb148263165a4757ced371a80913bc03c64e115a9a8bfde46525de
MD5 48f219a0011f1dde09f2e988e7cd2f5a
BLAKE2b-256 57c81589e3b4556e9011d9faf121aa99c7ff327f2e6cd967269c053893d9ea6e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page