Skip to content

Instantly share code, notes, and snippets.

View btlorch's full-sized avatar

btlorch

  • Universität Innsbruck
  • Innsbruck
View GitHub Profile
@btlorch
btlorch / rotation.py
Last active January 28, 2016 11:25
Rotation with NFFT
from nfft.nfft import Plan
import nibabel as nib
import numpy as np
import time
# Load image
img = nib.load("./merge_cartesian_2D_0cycles.nii.gz").get_data()
width = img.shape[1]
# Zeropadding
@btlorch
btlorch / read_hog_file.py
Last active July 1, 2022 20:45
Read HoG features file created by OpenFace
import numpy as np
import struct
def read_hog(filename, batch_size=5000):
"""
Read HoG features file created by OpenFace.
For each frame, OpenFace extracts 12 * 12 * 31 HoG features, i.e., num_features = 4464. These features are stored in row-major order.
:param filename: path to .hog file created by OpenFace
:param batch_size: how many rows to read at a time
@btlorch
btlorch / sdxl_compress_decompress.py
Created December 17, 2023 13:02
Compress images with the SDXL auto-encoder
import argparse
from PIL import Image
import numpy as np
from glob import glob
import os
from tqdm import tqdm
from diffusers import DiffusionPipeline
import torch
import torchvision.transforms as T