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.
Metadata
Release files for torchmaxflow 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torchmaxflow-0.0.7.tar.gz | 14.0 kB | Without provenance | Details for torchmaxflow-0.0.7.tar.gz |
Built distributions (wheels)
Total release size: 660.3 kB
Release files / torchmaxflow-0.0.7.tar.gz
| Download URL | torchmaxflow-0.0.7.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ff51c83cbc5bb12002e1410bf4ce7774d88ad5be13361c3cf754a8158812bba7
|
|
BLAKE2b-256 checksum How to use checksums |
3abbecd02ac0c4d2adef007f7d01bb45ac495340d12646bd9f318ae2f48fe3e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp39-cp39-win_amd64.whl
| Download URL | torchmaxflow-0.0.7-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 89.2 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
cd22479a5b49adae1494798fd8cdf007afcee11cf582074b8e673b968d7c7e06
|
|
BLAKE2b-256 checksum How to use checksums |
9dc0d75eafdb9fa604f621b4d0a4c005783c4e81b4c5de13eaf1ed1dbfb3b301
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp39-cp39-macosx_10_15_x86_64.whl
| Download URL | torchmaxflow-0.0.7-cp39-cp39-macosx_10_15_x86_64.whl |
|---|---|
| Size | 72.4 kB |
| Tags | CPython 3.9 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
30583c71c909552c0d05232d820d58e754cde3bc51b14f88caa3baf3fdede9c3
|
|
BLAKE2b-256 checksum How to use checksums |
3813479fe0d0d5d946df5400942cd774b5fb4244a4f823552cbde7f07a930e96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp38-cp38-win_amd64.whl
| Download URL | torchmaxflow-0.0.7-cp38-cp38-win_amd64.whl |
|---|---|
| Size | 89.2 kB |
| Tags | CPython 3.8 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
25fd7f5ecd87ec7c0043a696fce8d9aa5ebd57102a3fa11a9de4bb7a38c1793e
|
|
BLAKE2b-256 checksum How to use checksums |
ae1f3cc17eccdc37779b06683059e4e29cd5413a80af94c81add558c9e724942
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp38-cp38-macosx_10_15_x86_64.whl
| Download URL | torchmaxflow-0.0.7-cp38-cp38-macosx_10_15_x86_64.whl |
|---|---|
| Size | 72.3 kB |
| Tags | CPython 3.8 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
67a8366e45187040bd184fcbef134c4a1f5083bab3187d58ace6fc489c8059dc
|
|
BLAKE2b-256 checksum How to use checksums |
61203a3925f72f9b8c56c1feb903dd0ea45e12a90aaa553d7cdd7005bda9bee8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp37-cp37m-win_amd64.whl
| Download URL | torchmaxflow-0.0.7-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 89.6 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
27a5e8bf932bcd1d6f9c7295cce5076c7f48e2e88554d61b1e955c9172010bdf
|
|
BLAKE2b-256 checksum How to use checksums |
17c907c3b4983de60dacae36ea24189e538597f41a3652e0dd7fd0d2e44fab0a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp37-cp37m-macosx_10_15_x86_64.whl
| Download URL | torchmaxflow-0.0.7-cp37-cp37m-macosx_10_15_x86_64.whl |
|---|---|
| Size | 72.1 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
5e10b3455c28b892d31e43d547277d70f98afdb81e720576ad495c1a7bbfe98b
|
|
BLAKE2b-256 checksum How to use checksums |
1d8c4d06f7f04493c435e070cfa5c1efc161837686ee802fb6db8cdbb24288bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp36-cp36m-win_amd64.whl
| Download URL | torchmaxflow-0.0.7-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 89.6 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8022821eb74f20735d4a2dea16b07f731784abd42306fc8e68a35373c858c0dd
|
|
BLAKE2b-256 checksum How to use checksums |
59d28c986f8b6b5ee4c788039f4414b76db578b21f8838b19dfeea4e55c96dda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / torchmaxflow-0.0.7-cp36-cp36m-macosx_10_14_x86_64.whl
| Download URL | torchmaxflow-0.0.7-cp36-cp36m-macosx_10_14_x86_64.whl |
|---|---|
| Size | 71.8 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
f9045e7ceffc16094ee2df5a2f1b4d3629e170e4853dd2e239ed3efa18b0d43d
|
|
BLAKE2b-256 checksum How to use checksums |
447350bdbb8e967fd48fb814ae33377ea0b512cf77e15a0aee8f8cefa00c7ba3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for torchmaxflow 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.