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.3rc3.tar.gz (12.1 kB view details)

Uploaded Source

Built Distributions

torchmaxflow-0.0.3rc3-cp39-cp39-win_amd64.whl (84.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

torchmaxflow-0.0.3rc3-cp39-cp39-macosx_10_15_x86_64.whl (71.8 kB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

torchmaxflow-0.0.3rc3-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.3rc3-cp37-cp37m-win_amd64.whl (84.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

torchmaxflow-0.0.3rc3-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.3rc3-cp36-cp36m-win_amd64.whl (84.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

torchmaxflow-0.0.3rc3-cp36-cp36m-macosx_10_14_x86_64.whl (71.0 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file torchmaxflow-0.0.3rc3.tar.gz.

File metadata

  • Download URL: torchmaxflow-0.0.3rc3.tar.gz
  • Upload date:
  • Size: 12.1 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.3rc3.tar.gz
Algorithm Hash digest
SHA256 b5a4c638ac8aad32f21af02548c4e0efa201dfe30606e21749bfea81b3cc78b6
MD5 986a6df31f59bf4f6555107e146c92d8
BLAKE2b-256 4abc61b7e267c4586c33266bf0c491d66c08282674ca4c6ea8584ba6738abca2

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 595c9f8e67245e4b62f0eb627385cfe1c49472861f54b47a06b4460dbccd25be
MD5 da58cf59a923be2b168932de52ae07e3
BLAKE2b-256 b3e34652f9ccd436df3ef43f20ad191e850da9d88b7111ed385d2b94b9696983

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 367553b846e6b8aa86fd22271340a027faecf003c7654a9e356dee9d01ac42e5
MD5 34e3598d8277d733c7fc73fff62cd68f
BLAKE2b-256 dcc6d5520552107d2fc90b0c8ad5d232a9f548d58fcdf4d0c86189c35429f1ed

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0b410da20a85ad04bb53656d106a937e1766beafb6659bd73dd95ec0783bb2c1
MD5 3b3b70614eacc274c9d239b54b1e7338
BLAKE2b-256 eba4ffead65fd6a8f1e8831e28f9a65016a124e2bf390bbe15fe2a1d097db754

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4af4a3e252fd84e6b3fe8836f1a9267f8d636b170574c37cec8a70ef4b1d8980
MD5 3dc99d33005af94090d1d7197e2f0b4a
BLAKE2b-256 b8a59e2c6c023e70f16881bc32eff1e893d28f3cf87edad85e6328d8bea775d9

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 7446939f1ccb28791cdcb141b96eb5260e70af0c16bf95482f2376556afd0390
MD5 9d2fda3a82656b23b5f248954dc20ef9
BLAKE2b-256 f6c8668897d31140a37781086763378afd6516bada8e5619ddf87b6d50205fad

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 398ab1a512eab4f3bc739cc027de81f6596eb8d804957d4db8753e791e4e7eb1
MD5 485a77c05eafdce99cce4caae3f4241c
BLAKE2b-256 3bb50d34ee6ddeeee173eca38b4557e9ba20b1d85a5809869b5939e23467dd66

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 c936999ab770a59e444d38be6b4d08995003a8e9ae3f1350904618fc83c2e134
MD5 e3af1d1fd01c1bd93183e104c9fdeafa
BLAKE2b-256 c5ecb6c83ec5668052146603320132316df5200de1ad9f3940f11b8d4fe72d5b

See more details on using hashes here.

File details

Details for the file torchmaxflow-0.0.3rc3-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for torchmaxflow-0.0.3rc3-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8b448344c6171757185dc642cf7ff74cd3ca6e07bd06ad5c2b33e2b506b92790
MD5 329ff91d48d2ade171c5c07d144e0b17
BLAKE2b-256 b3153ff1fbe1e4cafe764b9bb8874538963b7850b757f0c5ee4c0fdc860afbe4

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