This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""@xvdp | |
Fourier 1D convs are constant speed with support size increase. HW optimized Sliding W are faster for small supports <20. | |
Vec (conv) kernel = ifft(fft(Vec) * fft(kernel)) | |
I used these to RIR (Room Impusle Response) to audio augmentation. | |
I filed issue to pytorch https://github.com/pytorch/pytorch/issues/79222, I just noticed I had not gisted it. | |
""" | |
from typing import Optional | |
import time | |
import torch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Morton codes should never be done in python, but in cpp, as they require looping | |
Still, to understand them here are 2 different implementations/ They both assume 3d points of shape (...,3] | |
1. More general computes a pyramid, using np or torch | |
>> get_morton_codes() | |
>> get_points_from_morton() | |
2. easier to read, uses morton to compute knn | |
>> knn() | |
Sources and further reading, morton code based voxelization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Conversion from WGS-84 to Transverse Mercator | |
WGS-84 is World Geodetic System data from 1984, utilized by GPS standard. | |
Transverse mercator is a general Mercator projection (projection of the oblate spheroid of earth onto a cylinder) that is used in most mapping systems. | |
These short codes allow user to specify center latitude and longitude. | |
Contains a simpler projection assuming earth is a sphere | |
>>> tmercator_meters_to_gps(coords, center) | |
>>> tmercator_gps_to_meters(coords, center) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# change cache paths for huggingface, torch, openai (uses ~/.cache/ by default) | |
# use: set_model_caches.sh /mnt/my/model/cache/path | |
cache_path=$1 | |
# Check if the argument is provided | |
if [ -z "$cache_path" ]; then | |
echo "Error: Cache path argument is missing." | |
echo "Usage: $0 /path_to_cache" | |
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" @xvdp | |
Simple solution to Show frame number and frame time with VLC or other video players | |
Make a subtitle file | |
caveats: | |
only tested in linux | |
requires ffmpeg / only tested with ffmpeg 4.3 | |
only tested with limited number of .mov and .mkv files | |
it may fail if ffprobe reports nb_frames, DURATION or frame_rate with keys not parsed here. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""@xvdp | |
reciprocals for torch.cumsum and torch.cumprod | |
I noticed that torch has cumsum and cumprod but not their reciprocals | |
even thought cumdif and cumdiv have meanings in analysis and probability | |
and are routinely used. | |
Are these interpretations correct? | |
> cumsum can be thought of as a discrete integral | |
> cumdif as discrete derivative |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
>>> import interpolation_diff as idf | |
>>> algs = ("pil", "tensorflow") # ("pil", "torch") | |
>>> save = "/home/z/share/benchestchirescat_%s_%s"%algs | |
>>> idf.test_dif(dtype="float32", mode="bilinear", show=True, algs=algs, crop=(170,370, 180, 380), save=save) | |
# re https://discuss.pytorch.org/t/nn-interpolate-function-unexpected-behaviour/106684/6 | |
""" | |
import io | |
import os |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder