A U-Net implementation of the EfficientNetV2.
Project description
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
-
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
-
Activate environment:
conda activate myenv
-
GPU support
Non GPU installations not tested
a. GPU support for Windows (example with conda):
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
b. GPU support for Linux -- not tested:
python3 -m pip install tensorflow[and-cuda]
c. Apple Silicon support (requires Xcode command-line tools):
xcode-select --install
conda install -c apple tensorflow-deps --force-reinstall
-
Install this library
- open a CLI, activate your environment (see above))
- (TensorFlow will be installed for Windows and macOS platforms)
pip install efficientv2-unet
-
Verify the GPU-support:
python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
or
python -c "import tensorflow as tf; print(tf.test.is_gpu_available())"
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file efficientv2_unet-0.0.2.tar.gz
.
File metadata
- Download URL: efficientv2_unet-0.0.2.tar.gz
- Upload date:
- Size: 8.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7b6acd7652fabf02565fa35eefda228183be21dd9005e4664cd7e7820062ac0 |
|
MD5 | 71d4cef15078db6521bed6c83e8d35f7 |
|
BLAKE2b-256 | fd913d864a58daac8aecd404f20a84b98d04d635a00c55eafacbb9adc9aeb295 |
File details
Details for the file efficientv2_unet-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: efficientv2_unet-0.0.2-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 769bf393098e30a0b94410d9f5564d5c47004c6b0a4d498895ef885e5bee2077 |
|
MD5 | 1aaa91b070a3bf35fbbffa569075e7c5 |
|
BLAKE2b-256 | e2433c97a632ed8643d3ee5d389b9cfd14c2bf7f52ff1da60ffe20a92e1af919 |