Skip to main content

Differentiable contour to mask and contour to distance map implementation with PyTorch

Project description

torch_contour

Example of torch contour on a circle when varying the number of nodes

Example of torch contour on a circle when varying the number of nodes

This library contains 2 pytorch layers for performing the diferentiable operations of :

  1. contour to mask
  2. contour to distance map.

It can therefore be used to transform a polygon into a binary mask or distance map in a completely differentiable way. In particular, it can be used to transform the detection task into a segmentation task. The two layers have no learnable weight, so all it does is apply a function in a derivative way.

Input (Float):

A polygon of size $2 \times n$ with
with $n$ the number of nodes

Output (Float):

A mask or distance map of size $1 \times H \times W$.
with $H$ and $W$ respectively the Heigh and Width of the distance map or mask.

Important:

The polygon must have values between 0 and 1. It is therefore important to apply a sigmoid function before the layer.*.

The predicted polygon must be ordered in counter-clockwise.

Example:

check out example.ipnb

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

torch_contour-0.0.4.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

torch_contour-0.0.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: torch_contour-0.0.4.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.10

File hashes

Hashes for torch_contour-0.0.4.tar.gz
Algorithm Hash digest
SHA256 c69186e99bb3112a3bed88cb2c98b1cbce904110ad6a66b46f84159610535e25
MD5 1065c371e16882b5c3b49b17a03dce5c
BLAKE2b-256 55731c695bb8dddbe0c81e814b47e47531bd70b8199c14bf9daf6eb3d400d30e

See more details on using hashes here.

File details

Details for the file torch_contour-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_contour-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cebe69ab14354bc1436aa6e47b97bb4a123890799208ed4cbd45910b848e5573
MD5 5d5bbd4dd2a3e8c1137126a97d816044
BLAKE2b-256 f744e60d8a47ed726371ecbcbc0f7e5102884928b31e4c235e94c8dbee713c47

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