Skip to content
/ rihog Public

Vectorized PyTorch implementation of Rotation Invariant Histogram of Oriented Gradients

License

Notifications You must be signed in to change notification settings

DSAureli/rihog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rihog

Vectorized PyTorch implementation of M. Cheon et al., Rotation Invariant Histogram of Oriented Gradients, International Journal of Fuzzy Logic and Intelligent Systems, vol. 11, no. 4, December 2011.

Install

pip install rihog

Usage

import rihog
import torch

img_b: torch.Tensor  # shape: (b 1 h w)

# class-based interface
rihog_fextr = rihog.RIHOG(...)
img_rihog_b = rihog_fextr(img_b)  # shape: (b wc nc*bc)
# wc: window count, nc: neighborhood count, bc: bin count

# functional interface
img_rihog_b = rihog.rihog(img_b, ...)  # shape: (b wc nc*bc)

Benchmark

Comparison of RIHOG1 and RIHOG3 against HOG and SIFT on the Original Brodatz Texture database. All algorithms are evaluated on the cosine distance-weighted k-NN accuracy computed from the average feature of each image, across three sizes of the feature vector (dimension). Following the evaluation procedure from the paper, 12 rotated versions are generated for each image (30° steps from 0° to 330°) and split into training set (first N rotations) and testing set (remaining rotations).

All benchmarks are run on the following hardware:

  • CPU: i9-11900KF @ 3.50GHz
  • RAM: 64GB @ 2400Mhz CL 17
  • GPU: RTX 3090 24GiB

Following is a run time comparison of the vectorized implementation on CPU and CUDA against the naive (non-vectorized) implementation across three hyper-parameter spaces: number of neighborhoods computed for each pixel (nbhd_steps parameter), batch size and image size.

License

MIT

About

Vectorized PyTorch implementation of Rotation Invariant Histogram of Oriented Gradients

Resources

License

Stars

Watchers

Forks