Skip to main content

Pytorch-Filters

A collection of image edge detection filters built with PyTorch — fully vectorized, GPU-compatible, and easy to drop into any pytorch pipeline.

Filters

  • Canny — classic multi-stage edge detector with Gaussian blur, Sobel gradients, non-maximum suppression, and hysteresis
  • DoG (Difference of Gaussians) — fast approximation of the Laplacian of Gaussian for edge detection
  • XDoG (Extended Difference of Gaussians) — stylized edge detection with soft thresholding, great for non-photorealistic rendering

Installation

pip install pytorch-filters

Quick Start

import torch
import torchvision.transforms.functional as TF
from PIL import Image
from pytorch_filters import canny, difference_of_gaussians, ex_difference_of_gaussians

# Load image as tensor [1, 1, H, W]
img = TF.to_tensor(Image.open("photo.jpg").convert("L")).unsqueeze(0)

edges = canny(img)
dog   = difference_of_gaussians(img, sigma=1.4, k=1.6)
xdog  = ex_difference_of_gaussians(img, sigma=1.0, tau=0.99, phi=100)

Demo

pip install -r requirements.txt
python demo.py images/demo1.jpg

This will display the original image alongside Canny, DoG, and XDoG results side by side.

demo output

Requirements

  • Python 3.10+
  • PyTorch 2.0+
  • torchvision
  • NumPy

Metadata

Release files for pytorch-filters 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytorch-filters 0.1.1
File Size Uploaded Provenance Actions
pytorch_filters-0.1.1.tar.gz 5.0 kB Without provenance Details for pytorch_filters-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytorch-filters 0.1.1
File Interpreter ABI Platform Actions
pytorch_filters-0.1.1-py3-none-any.whl Python 3 none any Details for pytorch_filters-0.1.1-py3-none-any.whl

Total release size: 10.3 kB

Release files / pytorch_filters-0.1.1.tar.gz

Download URL pytorch_filters-0.1.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
86dd545efaffed5e423b6f1a32121ade7ca1a9dc62705408e106b6cb8b5bfae9
BLAKE2b-256 checksum
How to use checksums
2bee5da461ef1647ba3f1b51466841b1fa5b33af399c201c2881fe0ca4d96124
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / pytorch_filters-0.1.1-py3-none-any.whl

Download URL pytorch_filters-0.1.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
747d8a4553b262df025c4a675858b10788b31bd046cbfb7481685f5271174e25
BLAKE2b-256 checksum
How to use checksums
04e6238ff012d550998a594ed182a2307dd8041751d96226d9126c6fab88aa42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for pytorch-filters 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page