A simple Canny edge detector for pytorch
Project description
Canny Edges
A simple Torch.nn.Module to return an image mask representing edges found by the
Canny Edge-Finding algorithm.
Supports:
- Linux
- PyTorch Tensor images formatted in image batches [B, C, h, w], with float32 data, and values spanning [0,1]
- Any number of image channels C
- All PyTorch types and backends
- TorchScript jit script, as well as the newer, traced torch-export, on the Canny
nn.Moduleclass
pip install
pip install canny_chenn
# or,
pixi add --pypi canny_chenn
# or,
uv add canny_chenn
then
from torch import Tensor
from canny_chenn import Canny
canny = Canny()
img_batch = Tensor([[[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]],
[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]],
[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]],
[[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]]]])
edge_mask = canny(img_batch)
# tensor([[[[0.0000, 0.6333, 0.0000, 0.0000],
# [0.0000, 0.6333, 0.0000, 0.0000],
# [0.0000, 0.6333, 0.0000, 0.0000]]]])
Dev
I use mise to handle project tools.
# clone, install tools
git clone https://github.com/chrishenn/canny.git
cd canny
mise i
# list available just recipes
just --list
Available recipes:
demo # Show canny detections on a set of test images. Kill with ctrl+c
lint # run project formatters/linters [alias: l]
test # run basic tests
unsafe # run ruff with unsafe-fixes
# build wheel, sdist pkgs locally
uv build --package canny_chenn
# push tag to trigger pypi to build pkgs and publish to pypi
git tag -a v1.0.3 -m v1.0.3 -f && git push --tags -f
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
canny_chenn-1.0.4.tar.gz
(3.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file canny_chenn-1.0.4.tar.gz.
File metadata
- Download URL: canny_chenn-1.0.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
626102575e072222c39a7cb1b3aea628cd18adcfe221fcd9a8aa20fca237ef8d
|
|
| MD5 |
92c5b5477dc00aa1733837f4ba185139
|
|
| BLAKE2b-256 |
40109388d1e514a44a1a07fb2c1aa00b27ba22841f811cecaae30ce87943eff4
|
File details
Details for the file canny_chenn-1.0.4-py3-none-any.whl.
File metadata
- Download URL: canny_chenn-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
482a246e849d67c3e3f2f9c6176d2dc9b0a0c8758034511c22e4e7c272b99e2c
|
|
| MD5 |
c4ad38a3ee5585a332486ea2376b5be5
|
|
| BLAKE2b-256 |
226ed6d74d263acc5f401174378c9256069bb4489197b1200de5824a7ae25d7b
|