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.3rc3-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 595c9f8e67245e4b62f0eb627385cfe1c49472861f54b47a06b4460dbccd25be |
|
MD5 | da58cf59a923be2b168932de52ae07e3 |
|
BLAKE2b-256 | b3e34652f9ccd436df3ef43f20ad191e850da9d88b7111ed385d2b94b9696983 |
Hashes for torchmaxflow-0.0.3rc3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 367553b846e6b8aa86fd22271340a027faecf003c7654a9e356dee9d01ac42e5 |
|
MD5 | 34e3598d8277d733c7fc73fff62cd68f |
|
BLAKE2b-256 | dcc6d5520552107d2fc90b0c8ad5d232a9f548d58fcdf4d0c86189c35429f1ed |
Hashes for torchmaxflow-0.0.3rc3-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b410da20a85ad04bb53656d106a937e1766beafb6659bd73dd95ec0783bb2c1 |
|
MD5 | 3b3b70614eacc274c9d239b54b1e7338 |
|
BLAKE2b-256 | eba4ffead65fd6a8f1e8831e28f9a65016a124e2bf390bbe15fe2a1d097db754 |
Hashes for torchmaxflow-0.0.3rc3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af4a3e252fd84e6b3fe8836f1a9267f8d636b170574c37cec8a70ef4b1d8980 |
|
MD5 | 3dc99d33005af94090d1d7197e2f0b4a |
|
BLAKE2b-256 | b8a59e2c6c023e70f16881bc32eff1e893d28f3cf87edad85e6328d8bea775d9 |
Hashes for torchmaxflow-0.0.3rc3-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7446939f1ccb28791cdcb141b96eb5260e70af0c16bf95482f2376556afd0390 |
|
MD5 | 9d2fda3a82656b23b5f248954dc20ef9 |
|
BLAKE2b-256 | f6c8668897d31140a37781086763378afd6516bada8e5619ddf87b6d50205fad |
Hashes for torchmaxflow-0.0.3rc3-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 398ab1a512eab4f3bc739cc027de81f6596eb8d804957d4db8753e791e4e7eb1 |
|
MD5 | 485a77c05eafdce99cce4caae3f4241c |
|
BLAKE2b-256 | 3bb50d34ee6ddeeee173eca38b4557e9ba20b1d85a5809869b5939e23467dd66 |
Hashes for torchmaxflow-0.0.3rc3-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c936999ab770a59e444d38be6b4d08995003a8e9ae3f1350904618fc83c2e134 |
|
MD5 | e3af1d1fd01c1bd93183e104c9fdeafa |
|
BLAKE2b-256 | c5ecb6c83ec5668052146603320132316df5200de1ad9f3940f11b8d4fe72d5b |
Hashes for torchmaxflow-0.0.3rc3-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b448344c6171757185dc642cf7ff74cd3ca6e07bd06ad5c2b33e2b506b92790 |
|
MD5 | 329ff91d48d2ade171c5c07d144e0b17 |
|
BLAKE2b-256 | b3153ff1fbe1e4cafe764b9bb8874538963b7850b757f0c5ee4c0fdc860afbe4 |