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.6rc1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 470bfe855ccc52712ccb096891a5c0e07af57861eedc95a1952c867dd1abd60e |
|
MD5 | e8ba266cdf517f2ae532be8f309cf5c1 |
|
BLAKE2b-256 | 78263ed270b46911ad1807d942496cfb4faf58ba7a0c89afe0e44f9d4e3701b0 |
Hashes for torchmaxflow-0.0.6rc1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d606ce7157ff1cd3a5410c5779b9f6631ffcfefe5806b9e1d8cc93286813aee4 |
|
MD5 | e5d026691c24c613a21650c2cf38ddff |
|
BLAKE2b-256 | 4634e19e34b356ae12a2fddefa7ad7f3bf1b1ccc7d4787bb71cdaf2af2fbf157 |
Hashes for torchmaxflow-0.0.6rc1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73da2edd6d72733ef6a837924256362cad6d118b2f8804334c96f69f8bfb9bcf |
|
MD5 | 81d36970d21696901696dfb364447615 |
|
BLAKE2b-256 | 55979b439a93b8d53a952a86e9ea1424691c995cad61eaa5a6528fbe5d387975 |
Hashes for torchmaxflow-0.0.6rc1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bf5976841af580eeef3579853fabc8cf7fa5893ba18158fbc6a33deba0a4de0 |
|
MD5 | 6e347a910c511f97abebc1859c918289 |
|
BLAKE2b-256 | 0d8d47d85a087ff55bbff393e85bd8142fddf2f5d25965ad1365ff66c64b4c43 |
Hashes for torchmaxflow-0.0.6rc1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 109b848ebada9080d912ef214672ec77125c2c096d6d1e33c6890617bb6e8f4c |
|
MD5 | e1901a0eb7a4df38b5c534175708ba1d |
|
BLAKE2b-256 | 4b9d4149615215b1c43efb5d72a894eaeaf5448aa9a15089e65521df39972c6e |
Hashes for torchmaxflow-0.0.6rc1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c2adb092e4e6fafc82943fcc3e0db27b090ecd92ca7cd9ebaee637a85cf5eb3 |
|
MD5 | 3324d575b4649b18a614456509b2327e |
|
BLAKE2b-256 | 8660d8df1d4507eee39f5542723f59ac0afa31a4988d1bd4e777001d70726f77 |
Hashes for torchmaxflow-0.0.6rc1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e34c55761e89e0918a0f16b5898a3b735ced30b6af06afefed67b345ad92905 |
|
MD5 | f2a99d4f5e625e38ac5eba8ac5deb8fc |
|
BLAKE2b-256 | 0f456f3ddd9a515480b47a405b172a841d59c924d3844a2e62d2d5f74f912a0a |
Hashes for torchmaxflow-0.0.6rc1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03abf8f7ce07c0c8fd90e89da51dd98a81184616ac8c5e3344690dd31c7ead26 |
|
MD5 | 98754128c00421d62fba956b641d5719 |
|
BLAKE2b-256 | 56c88136221979968da7ca63581f869e3f9aaa81ec9159ea86522c87ff5e0ed9 |