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.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 690c25cca4698e89fa805e931167a1da2166c65528cbe606851d2cad1d382a02 |
|
MD5 | 6ddd0e643ada1c64ee37082e0b62d6a6 |
|
BLAKE2b-256 | c2414e115da5c901218d248f20b233de95e07d3d112eafc73ba7a35acf638de8 |
Hashes for torchmaxflow-0.0.5-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eec68aa2250aadc0e142132ee23e70e8a3095623b8eec6c92450867785607e91 |
|
MD5 | d3130896de722f99bfce041e19bde7fe |
|
BLAKE2b-256 | 4be55fa52eab9776ab97287dbb002a6eeef88af7db3d640bf6b2c4221477d343 |
Hashes for torchmaxflow-0.0.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cff61854d76f8416f21c3a4c6156c1205d9feb36dcba5eebf75586927957dab1 |
|
MD5 | 85996849cedbf740dcfd69f8de52c61a |
|
BLAKE2b-256 | 494a060f2974911ff15d3db7df35cc9104ba980cba76cc8c4aad284bf3157183 |
Hashes for torchmaxflow-0.0.5-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b2963ab8e27b91a14aa9fbdd2a002a2434c2957a87ebb52e9e737fd9cde1378 |
|
MD5 | b1539a75e05bfe9005271b15c0198214 |
|
BLAKE2b-256 | 885cd55c9156901a09e59e1a90c23689f25927580f9457abd046472ac644c55e |
Hashes for torchmaxflow-0.0.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 613fa0d4676f6a7ed899260bf04ee4e7cd7373f7b73155c77b68805612f52d6f |
|
MD5 | 2ec7ff74382dc0c559e20122acf387dc |
|
BLAKE2b-256 | b88b730eb09a277af31392c68ad1ca8f76d72bdf894fa6cdc9010a49318dc0c6 |
Hashes for torchmaxflow-0.0.5-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9b56c957d28ea4e46b21a7ae2739c67a493ac0cd356debe6a35a241d0894054 |
|
MD5 | 52baea3a4cc830e4ea5481f185caa496 |
|
BLAKE2b-256 | 37de34559ae06edb2083c18c549df77f1678c65b59f1ead737e68e7b4c3e263f |
Hashes for torchmaxflow-0.0.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16054e75a50dc47b0745f343b79ee115c06cbe9300b5214959ca09cebc4cb78f |
|
MD5 | 6530732e2447c6b091e180b9cd712767 |
|
BLAKE2b-256 | c55fc47cc38fa7e763e9f34d9665e3f4f10c4bd526617efde17826a0d29a5231 |
Hashes for torchmaxflow-0.0.5-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 112810fbecf660da90ee8cd2ee627567f2b5a3e78b6551caa96ec47ca304b0b8 |
|
MD5 | 46e6dedc2a7cfb4f401d2396bec468a8 |
|
BLAKE2b-256 | 2115489b5278863c5dfd0430e9472488e7e1051db075accdc650d98b34adc6c9 |