Skip to content

Instantly share code, notes, and snippets.

View isaaccorley's full-sized avatar
🌴

Isaac Corley isaaccorley

🌴
View GitHub Profile
@calebrob6
calebrob6 / lbp.py
Created August 3, 2025 02:07
PyTorch local binary pattern histograms
def batch_histogram(data_tensor, num_classes=-1):
"""
From https://discuss.pytorch.org/t/batched-torch-histc/179741
Computes histograms of integral values, even if in batches (as opposed to torch.histc and torch.histogram).
Arguments:
data_tensor: a D1 x ... x D_n torch.LongTensor
num_classes (optional): the number of classes present in data.
If not provided, tensor.max() + 1 is used (an error is thrown if tensor is empty).
Returns: