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 Distributions
Built Distributions
Hashes for torchmaxflow-0.0.3rc2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdaac76389964fbd7df65fdd39229869103aa2c3d93748e1ca83eda88cca5bbd |
|
MD5 | bcccbea3e5b0cc754769a67828d2c162 |
|
BLAKE2b-256 | ed6d537afb79fc38151491bbfbc2788120e0aa0c8cd2bba4d4911efd1e391557 |
Hashes for torchmaxflow-0.0.3rc2-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed9d3c35f0ed6ee7385ba9660e14da2c615b7eab2e09be281fa8491333db8af4 |
|
MD5 | 29f061f7735a28a6289d622343977cf8 |
|
BLAKE2b-256 | e7349516b2cfa6d18096492ef902101bb6b8b81c805648c8b02208c7688ea26f |
Hashes for torchmaxflow-0.0.3rc2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9e8ef634ec1571ec7ba9bbf52133cf757fedf07e57689e20834d5ed96e3bf8 |
|
MD5 | 93a93f76711240e1d843a45ff78aeb91 |
|
BLAKE2b-256 | 7f8ffd4f0ec408515a1b31a7c8dc5207d6115005762e069091043a561cb2974a |
Hashes for torchmaxflow-0.0.3rc2-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 177168d0404616387640cee0cb0ebc3c338ad96ad6ec72c30d99a4c96b34aebf |
|
MD5 | 61a4f639805d51628e61b7c02f8c3fa9 |
|
BLAKE2b-256 | 9bb0ec929e60f5f531f5987bc1930effa6cb4e1ad07064a86ec73765db7a31c6 |
Hashes for torchmaxflow-0.0.3rc2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c1e142cb2d3a50fae94cc5681cf91ce71035a11df0bde6ba972f6710e875618 |
|
MD5 | 274da92dd122b5fcc4bd6e218bb12b4c |
|
BLAKE2b-256 | c07c2a45eaf241286a0d0371961ce2cc4a95a8b16e0665ceaecd362f7cfea2ef |
Hashes for torchmaxflow-0.0.3rc2-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2453408b803a0494e1cba37bdb33ee91768fd236a725bc6f100fe9c38d34f98 |
|
MD5 | da0e0a261bed1fcb9373a237588589c2 |
|
BLAKE2b-256 | 4238f57be6969babe891b6334a7407507b6669e8c6ef3c3df3fb1cd8367651f7 |
Hashes for torchmaxflow-0.0.3rc2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42d86793358e2d13f63478d1d13a42ce6bdb1fbd5daa181a27328507cac7c2fb |
|
MD5 | d2db62f6b49a90de106d006cbf4d5076 |
|
BLAKE2b-256 | 15950e0b3165bb6ed21350e9ef2c1578aad7022a2c04d11b25c57b62cdd477dd |
Hashes for torchmaxflow-0.0.3rc2-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16c1fb3c3c9ff4d2ebbe050e6a2c1b96289de2cfc93ffa0515a1673259cbe3c2 |
|
MD5 | 5f0a386eb39720f56bc283574c5e0932 |
|
BLAKE2b-256 | 68884ff9e44073ab9186d7eebb1a26cc59ba4da6b6c81829ef3f64878d2589ba |