torchmaxflow: Max-flow/Min-cut in PyTorch for 2D images and 3D volumes
Project description
torchmaxflow: Max-flow/Min-cut in PyTorch for 2D images and 3D volumes
Pytorch-based implementation of Max-flow/Min-cut based on the following paper:
- Boykov, Yuri, and Vladimir Kolmogorov. "An experimental comparison of min-cut/max-flow algorithms for energy minimization in vision." IEEE transactions on pattern analysis and machine intelligence 26.9 (2004): 1124-1137.
Citation
If you use this code in your research, then please consider citing:
Asad, Muhammad, Lucas Fidon, and Tom Vercauteren. "ECONet: Efficient Convolutional Online Likelihood Network for Scribble-based Interactive Segmentation." Medical Imaging with Deep Learning (MIDL), 2022.
Installation instructions
pip install torchmaxflow
or
# Clone and install from github repo
$ git clone https://github.com/masadcv/torchmaxflow
$ cd torchmaxflow
$ pip install -r requirements.txt
$ python setup.py install
Example outputs
Maxflow2d
Interactive maxflow2d
Example usage
The following demonstrates a simple example showing torchmaxflow usage:
image = np.asarray(Image.open('data/image2d.png').convert('L'), np.float32)
image = torch.from_numpy(image).unsqueeze(0).unsqueeze(0)
prob = np.asarray(Image.open('data/image2d_prob.png'), np.float32)
prob = torch.from_numpy(prob).unsqueeze(0)
lamda = 20.0
sigma = 10.0
post_proc_label = torchmaxflow.maxflow(image, prob, lamda, sigma)
For more usage examples see:
2D and 3D maxflow and interactive maxflow examples: demo_maxflow.py
References
This repository depends on the code for maxflow from latest version of OpenCV, which has been included.
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 Distributions
Hashes for torchmaxflow-0.0.4rc2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a000f67f9015271b0e0e8a3de524112911d4f1f424fb45902c01ddd32b44d6f |
|
MD5 | f7f3da4155d8be967b892c7629f579e5 |
|
BLAKE2b-256 | 05935c9834c05846310825be32b3fde4b04017911f31d9977ccfa1c71ed26378 |
Hashes for torchmaxflow-0.0.4rc2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb65b6c07af4d010f9476ff86431630ec4f8d7dd94a7a79df7710b3148149716 |
|
MD5 | 291f92b9bfc3c25e446ec9e8f6d55755 |
|
BLAKE2b-256 | 1394f944c786619bcf54e094b34e41b7edafa706ef3d9990c50ed0417779a26e |
Hashes for torchmaxflow-0.0.4rc2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6b40e624329fda87346b51500e6e31b3dd3cbedfb933d081fcb61202610f663 |
|
MD5 | b9023971d965d19eded4498e0b49cad1 |
|
BLAKE2b-256 | 410265cc37f89b7cc6c53345cd91a35bb5086b46177d19696dbde6cec953f1cf |
Hashes for torchmaxflow-0.0.4rc2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35f4578e43324fe19d0eeaefd858393c42f516a16eb151485070fa99f707766e |
|
MD5 | 5cf68348d14177ef3dcdeb62a4f01394 |
|
BLAKE2b-256 | d0e0350f8a6856da7201dff203061d1ffb543a1a4db144b4b7669999a7c9f0b1 |
Hashes for torchmaxflow-0.0.4rc2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 838e6dbad738e9f4dedfd415ad22a76186081437022944f568d9d4e554931d18 |
|
MD5 | 74e26376b1756bc71f71cb42c47d4923 |
|
BLAKE2b-256 | 09fa9ab73d14a2855b9ea59339f233339c2d541417944da11b8b1d2ccbb05866 |
Hashes for torchmaxflow-0.0.4rc2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e439d96e053266dafb5f37074a0ddd03937852ac9833d00895caeca24b7a6a11 |
|
MD5 | 66daa2a6a9831ed38b2694209188c0df |
|
BLAKE2b-256 | 32082821940e25f37fc28fd35e5ef20191ba8deaa062db0866291170ec4fd6f6 |
Hashes for torchmaxflow-0.0.4rc2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9121cb54bb64c9bc6d97ba6328b5cc14a3555cf9e7ccb672c6ee18c20ba0c93 |
|
MD5 | 2d063bcba81557503c806d66449b9146 |
|
BLAKE2b-256 | a1916a2578402d2f48a656027f389634638abbc522fabe432e2e6bcfa134f084 |
Hashes for torchmaxflow-0.0.4rc2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f183dfa96b755c061b75668267b6cada02fa1b8f8eb54a9995d1f9cbc533037 |
|
MD5 | 81882cd1a92577c3fb4db6c6fccc82bd |
|
BLAKE2b-256 | 91e3b34b6abdf090b1233290d85513e88df14aead8c8d1b6f6373ad297f525a5 |