No project description provided
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.
This repository depends on the code for maxflow from OpenCV v2.4: https://github.com/opencv/opencv/blob/2.4/modules/imgproc/src/gcgraph.hpp, which has been included. It has same license, i.e. BSD-3 Clause, as torchmaxflow.
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
- OpenCV's Graphcut implementation:https://github.com/opencv/opencv/blob/2.4/modules/imgproc/src/gcgraph.hpp
- SimpleCRF's maxflow implementation: https://github.com/HiLab-git/SimpleCRF
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.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 716386518357e8c99655c11751a224d229c0e30d6fcdd2fdc391b95be33055ed |
|
MD5 | 2fbaa989bdac6a2975c130119372e318 |
|
BLAKE2b-256 | cee0b86eb7867eea889cedcca588499415307cb0f3cc56b61d3f2b5338537465 |
Hashes for torchmaxflow-0.0.4-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a14228615ab80fbf957c86ae34df6778c328fcd94827db4776d9625a33531f1 |
|
MD5 | 3d147c48ddfe2bb9d78296727a44dcdf |
|
BLAKE2b-256 | 408cfb84a957304e180a5b380cabc9394cb22bf408a2abd5927715a06e88450e |
Hashes for torchmaxflow-0.0.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0145e2aee55b4849b88da9076eab5ce18e3fb23dd17d4284e6b9453b64210fe2 |
|
MD5 | de23fb07299fd632a12b6957c1d9a3d5 |
|
BLAKE2b-256 | 66755967a3f04129ddaaa3dbeebf5e530651933d9cdaaaa7a21a861488d8b608 |
Hashes for torchmaxflow-0.0.4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afb6148213d5c9d6039ef2c62df337423e21e9905e3b353dff62fc0a49d303e2 |
|
MD5 | 7f079c3885dcd04326cef80f63bb6bce |
|
BLAKE2b-256 | 35a68790c461c6cc98868f02efe829b2f292c20def8306f40cd30ed60f1864eb |
Hashes for torchmaxflow-0.0.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0eb9cd02d3cc29f81fbbb8d6cd5b2c4efc6063332567011e9236233e6759222 |
|
MD5 | 7107f6136c9107826cd4e36e9b43f331 |
|
BLAKE2b-256 | 1ef5c99ef82c9846de15633395ce5b156403d9aeaecdbcda97bf76628c403fde |
Hashes for torchmaxflow-0.0.4-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 169b814900b12a40f4219ce48a70e5de2073b79bd06a12761b080bfccf2af4c3 |
|
MD5 | 42c4d28bd2b93b9dc5258d853fb29935 |
|
BLAKE2b-256 | 9bf3cfc7b2968aeb4ddae89f9833aad711803c64cb474548d504395b01edde58 |
Hashes for torchmaxflow-0.0.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89467d6582ecd485887aba83e77786a5c956f45d0c7af89122d2e76f31247d91 |
|
MD5 | 37b7e115b3cfd7df33ed38820a606db0 |
|
BLAKE2b-256 | afb1a0f7b4513e7f49d93b5526f77d31b46f1b8033abd3d6ea8e3303edcbd28d |
Hashes for torchmaxflow-0.0.4-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0a716c4b25daeba4253d42fd2e30625ed9e5adec6956acd86b2be8c24092e61 |
|
MD5 | 0dd0293844bfc7554908d04b45afeb5c |
|
BLAKE2b-256 | 6c31da5805863117668197b0dd2dc719005110c9fb36acd0c720fd7c6516cfdc |