Image edge detection filters built with PyTorch
Project description
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.
Requirements
- Python 3.10+
- PyTorch 2.0+
- torchvision
- NumPy
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytorch_filters-0.1.1.tar.gz
(5.0 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 pytorch_filters-0.1.1.tar.gz.
File metadata
- Download URL: pytorch_filters-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
86dd545efaffed5e423b6f1a32121ade7ca1a9dc62705408e106b6cb8b5bfae9
|
|
| MD5 |
33e1001a41011680f5b4ceb1dea54e19
|
|
| BLAKE2b-256 |
2bee5da461ef1647ba3f1b51466841b1fa5b33af399c201c2881fe0ca4d96124
|
File details
Details for the file pytorch_filters-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pytorch_filters-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
747d8a4553b262df025c4a675858b10788b31bd046cbfb7481685f5271174e25
|
|
| MD5 |
4b900f932024fb71170162d2efcee663
|
|
| BLAKE2b-256 |
04e6238ff012d550998a594ed182a2307dd8041751d96226d9126c6fab88aa42
|