Non Official PyTorch Implementation of the HoG Descriptor
Project description
torch-hog
Non Official PyTorch Implementation of the HoG Descriptor
Recent updates:
- 0.0.1: Basic HoG calcuation was added
Contents
Installation
Plain and simple:
pip install torch-hog
Basice Use
Import
Use as a PyTorch Module:
from torch_hog import HoG
hog = HoG(num_bins=9, cell_size=8, padding="reflect")
Or as a function:
from torch_hog.functional import hog
Dense Feature Extraction
either way, the API is the same. To get the features at every possible coordinate, just feed in the batch:
# Create a random batch of images
B, C, H, W = 5, 3, 360, 480
img = torch.randn((B, C, H, W))
dense_hog_features = hog(img) # returns a tensor of shape (B, H*W, bins)
Sparse Feature Extraction
You can specify the desired coordinates for every image in the batch.
# specify the desired coordinates
coords = torch.tensor([
[20, 15],
[17.7, 18.9], # yes we're accepting floats too
[150, 170],
])
# Create a random batch of images
B, C, H, W = 5, 3, 360, 480
img = torch.randn((B, C, H, W))
hog_features = hog(img, coords=coords) # returns a tensor of shape (B, 3, bins)
You can also specify different number of coordinates for every image:
# specify the desired coordinates
coords1 = torch.tensor([
[20, 15],
[17.7, 18.9], # yes we're accepting floats too
[150, 170],
])
coords2 = torch.tensor([
[41, 38],
[69, 85],
])
coords = [coords1, coords2]
# Create a random batch of images
B, C, H, W = 5, 3, 360, 480
img = torch.randn((B, C, H, W))
hog_features = hog(img, coords=coords) # returns a list of tensors as with the shapes: [(3, bins), (2, bins)]
Cite Us
Please use the following bibtex record if you're using this project in your research:
@misc{TorchHog2025,
author = {Abe, Amit},
title = {Torch-HoG},
year = {2025},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/wamitw/torch-hog}},
}
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
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 torch_hog-0.0.1.tar.gz.
File metadata
- Download URL: torch_hog-0.0.1.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bc130f4e51be6fc955e79452209aa7b9a3be3d95c7dd9ed48ddc43c980f1cf9
|
|
| MD5 |
91caf3f7188c1b2d0ed673f9ec14dd1c
|
|
| BLAKE2b-256 |
78879b462b37d91756c864524aedd429470a8d5533af68a86aba044cae77395c
|
File details
Details for the file torch_hog-0.0.1-py3-none-any.whl.
File metadata
- Download URL: torch_hog-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfced3a119a200fa92a4a43391aa6e7e13ddff01aa519945f4d31133c1a36ed0
|
|
| MD5 |
3743cf535ffa4224a48ee4544e5fcf6d
|
|
| BLAKE2b-256 |
2a6ab0a4f42f8f6d2e936bf9903ee06f3285dad28450e6177c1c8d255c34c8d6
|