Skip to main content

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

./figures/torchmaxflow_maxflow2d.png

Interactive maxflow2d

./figures/torchmaxflow_intmaxflow2d.png

figures/figure_torchmaxflow.png

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchmaxflow-0.0.4.tar.gz (12.0 kB view details)

Uploaded Source

Built Distributions

torchmaxflow-0.0.4-cp39-cp39-win_amd64.whl (84.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

torchmaxflow-0.0.4-cp39-cp39-macosx_10_15_x86_64.whl (71.7 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

torchmaxflow-0.0.4-cp38-cp38-win_amd64.whl (84.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

torchmaxflow-0.0.4-cp38-cp38-macosx_10_14_x86_64.whl (71.3 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

torchmaxflow-0.0.4-cp37-cp37m-win_amd64.whl (84.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

torchmaxflow-0.0.4-cp37-cp37m-macosx_10_14_x86_64.whl (71.0 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

torchmaxflow-0.0.4-cp36-cp36m-win_amd64.whl (84.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

torchmaxflow-0.0.4-cp36-cp36m-macosx_10_14_x86_64.whl (70.9 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file torchmaxflow-0.0.4.tar.gz.

File metadata

  • Download URL: torchmaxflow-0.0.4.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for torchmaxflow-0.0.4.tar.gz
Algorithm Hash digest
SHA256 bb206de7a4c1074827367508dbcc30a77efb8e853b4208891dd3bd655f3a33c5
MD5 66b08dc61f6da052dbeae53236dadbd7
BLAKE2b-256 2d7178eb15c2ede62aaa04be3b399034fdbdcb417f8722a4c518f8d36ed03722

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 716386518357e8c99655c11751a224d229c0e30d6fcdd2fdc391b95be33055ed
MD5 2fbaa989bdac6a2975c130119372e318
BLAKE2b-256 cee0b86eb7867eea889cedcca588499415307cb0f3cc56b61d3f2b5338537465

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 1a14228615ab80fbf957c86ae34df6778c328fcd94827db4776d9625a33531f1
MD5 3d147c48ddfe2bb9d78296727a44dcdf
BLAKE2b-256 408cfb84a957304e180a5b380cabc9394cb22bf408a2abd5927715a06e88450e

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0145e2aee55b4849b88da9076eab5ce18e3fb23dd17d4284e6b9453b64210fe2
MD5 de23fb07299fd632a12b6957c1d9a3d5
BLAKE2b-256 66755967a3f04129ddaaa3dbeebf5e530651933d9cdaaaa7a21a861488d8b608

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 afb6148213d5c9d6039ef2c62df337423e21e9905e3b353dff62fc0a49d303e2
MD5 7f079c3885dcd04326cef80f63bb6bce
BLAKE2b-256 35a68790c461c6cc98868f02efe829b2f292c20def8306f40cd30ed60f1864eb

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f0eb9cd02d3cc29f81fbbb8d6cd5b2c4efc6063332567011e9236233e6759222
MD5 7107f6136c9107826cd4e36e9b43f331
BLAKE2b-256 1ef5c99ef82c9846de15633395ce5b156403d9aeaecdbcda97bf76628c403fde

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 169b814900b12a40f4219ce48a70e5de2073b79bd06a12761b080bfccf2af4c3
MD5 42c4d28bd2b93b9dc5258d853fb29935
BLAKE2b-256 9bf3cfc7b2968aeb4ddae89f9833aad711803c64cb474548d504395b01edde58

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 89467d6582ecd485887aba83e77786a5c956f45d0c7af89122d2e76f31247d91
MD5 37b7e115b3cfd7df33ed38820a606db0
BLAKE2b-256 afb1a0f7b4513e7f49d93b5526f77d31b46f1b8033abd3d6ea8e3303edcbd28d

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.4-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.4-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a0a716c4b25daeba4253d42fd2e30625ed9e5adec6956acd86b2be8c24092e61
MD5 0dd0293844bfc7554908d04b45afeb5c
BLAKE2b-256 6c31da5805863117668197b0dd2dc719005110c9fb36acd0c720fd7c6516cfdc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page