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.
If you want same functionality in Numpy, then consider Numpy-based implementation
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
File details
Details for the file torchmaxflow-0.0.7.tar.gz
.
File metadata
- Download URL: torchmaxflow-0.0.7.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff51c83cbc5bb12002e1410bf4ce7774d88ad5be13361c3cf754a8158812bba7 |
|
MD5 | ca37e24f82cf511420b100930f90477d |
|
BLAKE2b-256 | 3abbecd02ac0c4d2adef007f7d01bb45ac495340d12646bd9f318ae2f48fe3e1 |
File details
Details for the file torchmaxflow-0.0.7-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 89.2 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd22479a5b49adae1494798fd8cdf007afcee11cf582074b8e673b968d7c7e06 |
|
MD5 | 4f6c9c31d57b6d37fb8c00822f9d2033 |
|
BLAKE2b-256 | 9dc0d75eafdb9fa604f621b4d0a4c005783c4e81b4c5de13eaf1ed1dbfb3b301 |
File details
Details for the file torchmaxflow-0.0.7-cp39-cp39-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp39-cp39-macosx_10_15_x86_64.whl
- Upload date:
- Size: 72.4 kB
- Tags: CPython 3.9, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30583c71c909552c0d05232d820d58e754cde3bc51b14f88caa3baf3fdede9c3 |
|
MD5 | 1f55e66323943a50785e00eae0a1e0e9 |
|
BLAKE2b-256 | 3813479fe0d0d5d946df5400942cd774b5fb4244a4f823552cbde7f07a930e96 |
File details
Details for the file torchmaxflow-0.0.7-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 89.2 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25fd7f5ecd87ec7c0043a696fce8d9aa5ebd57102a3fa11a9de4bb7a38c1793e |
|
MD5 | 1ee8a2876c4bb22a0afaa248e1cc39fc |
|
BLAKE2b-256 | ae1f3cc17eccdc37779b06683059e4e29cd5413a80af94c81add558c9e724942 |
File details
Details for the file torchmaxflow-0.0.7-cp38-cp38-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp38-cp38-macosx_10_15_x86_64.whl
- Upload date:
- Size: 72.3 kB
- Tags: CPython 3.8, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67a8366e45187040bd184fcbef134c4a1f5083bab3187d58ace6fc489c8059dc |
|
MD5 | 68f0182a04b8082b6bcc16bfa28cd1ec |
|
BLAKE2b-256 | 61203a3925f72f9b8c56c1feb903dd0ea45e12a90aaa553d7cdd7005bda9bee8 |
File details
Details for the file torchmaxflow-0.0.7-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 89.6 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27a5e8bf932bcd1d6f9c7295cce5076c7f48e2e88554d61b1e955c9172010bdf |
|
MD5 | 6fb9dc468c3d80a4600061670c8d45fc |
|
BLAKE2b-256 | 17c907c3b4983de60dacae36ea24189e538597f41a3652e0dd7fd0d2e44fab0a |
File details
Details for the file torchmaxflow-0.0.7-cp37-cp37m-macosx_10_15_x86_64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp37-cp37m-macosx_10_15_x86_64.whl
- Upload date:
- Size: 72.1 kB
- Tags: CPython 3.7m, macOS 10.15+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e10b3455c28b892d31e43d547277d70f98afdb81e720576ad495c1a7bbfe98b |
|
MD5 | 47c9279c21c32dffe79fba0164e5451f |
|
BLAKE2b-256 | 1d8c4d06f7f04493c435e070cfa5c1efc161837686ee802fb6db8cdbb24288bb |
File details
Details for the file torchmaxflow-0.0.7-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 89.6 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8022821eb74f20735d4a2dea16b07f731784abd42306fc8e68a35373c858c0dd |
|
MD5 | ffc2ff26f9756b18cd79d8f63e07f9f5 |
|
BLAKE2b-256 | 59d28c986f8b6b5ee4c788039f4414b76db578b21f8838b19dfeea4e55c96dda |
File details
Details for the file torchmaxflow-0.0.7-cp36-cp36m-macosx_10_14_x86_64.whl
.
File metadata
- Download URL: torchmaxflow-0.0.7-cp36-cp36m-macosx_10_14_x86_64.whl
- Upload date:
- Size: 71.8 kB
- Tags: CPython 3.6m, macOS 10.14+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9045e7ceffc16094ee2df5a2f1b4d3629e170e4853dd2e239ed3efa18b0d43d |
|
MD5 | dc4f03de14c292d3191672e0530c368d |
|
BLAKE2b-256 | 447350bdbb8e967fd48fb814ae33377ea0b512cf77e15a0aee8f8cefa00c7ba3 |