Skip to content

Instantly share code, notes, and snippets.

@valgur
valgur / elb_grids.py
Last active Mar 16, 2021
Estonian Land Board map sheet (grid) index formulas / Maa-ameti kaardilehtede järjekorranumbrite teisendusvalemid
View elb_grids.py
# x - easting, y - northing
def grid20k(x, y):
x = int(x) // 1000 - 200
y = int(y) // 1000 - 5900
idx = (y // 100) * 1000 + (y // 10 % 10) * 10
idx += (x // 100) * 100 + (x // 10 % 10)
return idx
def grid10k(x, y):
@valgur
valgur / torch_add_hash.sh
Created May 23, 2020
Add a checksum string to a state file name for Torch Hub
View torch_add_hash.sh
#!/bin/bash
mv "$1" "${1%.*}"-$(sha256sum "$1" | cut -c1-8).pt
View surface_normal_taichi.py
import numpy as np
import taichi as ti
from skimage.io import imread, imsave
ti.init(arch=ti.cuda)
@ti.kernel
def normals_from_depth_kernel(f: ti.f32, cx: ti.f32, cy: ti.f32, window_size: ti.u16, max_rel_depth_diff: ti.f32):
height, width = ti_depth.shape()
@valgur
valgur / kitti_raw_data_downloader.sh
Last active Apr 15, 2020
More user-friendly KITTI raw dataset download script - extract in background and replace noisy stdout with clear progress info
View kitti_raw_data_downloader.sh
#!/bin/bash
files=(
2011_09_26_calib.zip
2011_09_26_drive_0001
2011_09_26_drive_0002
2011_09_26_drive_0005
2011_09_26_drive_0009
2011_09_26_drive_0011
2011_09_26_drive_0013
@valgur
valgur / raw2odom-report.ipynb
Last active Apr 16, 2020
Reverse-engineering of KITTI raw to odom dataset conversion for https://github.com/tomas789/kitti2bag/issues/11 discussion. WIP.
View raw2odom-report.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@valgur
valgur / install_cuda.sh
Last active May 21, 2020
Automatically install CUDA, cuDNN and appropriate drivers
View install_cuda.sh
#!/bin/bash
set -e -u -o pipefail -o noglob
set -x
CUDA_VERSION=${CUDA_VERSION:-10.2}
CUDNN_VERSION=${CUDNN_VERSION:-7}
TENSORRT_VERSION=${TENSORRT_VERSION:-7}
UBUNTU_RELEASE=$(lsb_release -rs) # 18.04
DISTRO=ubuntu${UBUNTU_RELEASE//\./} # ubuntu1804
@valgur
valgur / update-alternatives-clang.sh
Last active Jul 6, 2019 — forked from gburca/update-alternatives-clang.sh
Automatically find and 'update-alternatives --install' installed clang versions
View update-alternatives-clang.sh
#!/bin/bash
BIN=/usr/bin
MAN=/usr/share/man/man1
function register_clang_version {
BINV=$1
PRIORITY=`echo $BINV | awk '{print int($1 * 10)}'`
update-alternatives --install $BIN/clang clang $BIN/clang-$BINV $PRIORITY \
--slave $BIN/clang++ clang++ $BIN/clang++-$BINV
@valgur
valgur / get_cuda_gencode.cpp
Last active Apr 24, 2019
Generate CUDA -gencode parameters for available GPU devices. Usage: chmod +x get_cuda_gencode.cpp && ./get_cuda_gencode.cpp
View get_cuda_gencode.cpp
//usr/bin/env nvcc --run "$0" -o /tmp/get_cuda_gencode; rm /tmp/get_cuda_gencode; exit
#include <cuda_runtime_api.h>
#include <iostream>
#include <set>
int main(int argc, char *argv[]) {
cudaDeviceProp prop;
cudaError_t status;
int device_count;
status = cudaGetDeviceCount(&device_count);
View leaky_relu.patch
--- src/leakyrelu.cc (revision 830d5ef7a5b1f33de2aa95405787c03e4de77306)
+++ src/leakyrelu.cc (date 1554811334000)
@@ -22,7 +22,7 @@
using namespace tensorflow;
-REGISTER_OP("LeakyRelu")
+REGISTER_OP("LeakyReluLmb")
.Attr("T: {float, double}")
.Attr("leak: float = 0.1")
View geo_lest.cpp
#include <cmath>
#include <utility>
// Input: WGS84 longitude and latitude
// Output: x - easting, y - northing in L-EST97 (EPSG:3301)
// Source: http://www.maaamet.ee/rr/geo-lest/files/geo-lest_function_php.txt
std::pair<double, double> geo_lest(const double lon, const double lat) {
using namespace std;
constexpr double deg2rad = M_PI / 180.;
constexpr double a = 6378137.;