Skip to content

Instantly share code, notes, and snippets.

View ducha-aiki's full-sized avatar

Dmytro Mishkin ducha-aiki

View GitHub Profile
@ducha-aiki
ducha-aiki / svd_crash.cc
Created May 25, 2022 21:07
Minimal example to reproduce cv::SVD::solveZ crash
#include <opencv2/core.hpp>
int main(int argc, char** argv) {
double x[117][43] = {{-890.2075142966416, -91.49514585853208, -1519.470669123981, -4378.297874749891, 288.75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{
328.0247571268432, -1514.656408530106, -525.5454067319092, -4091.284249468227, 841.8749389648438, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{
0.4572510884940519, -0.04269169026717295, -0.8883123671621016, -4.565511104557279, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{
-774.7308902380352, -63.73590155633997, -1582.833433156421, -4813.378878037186, 0, 406.8749694824219, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},{
437.1122295425562, -1473.381008340528, -562.1952994931905, -4437.79235664477, 0, 931.874938964843
@ducha-aiki
ducha-aiki / grayscale-dilation-example.ipynb
Created December 4, 2019 16:16
Grayscale dilation in kornia
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ducha-aiki
ducha-aiki / spatial-grad-bug.ipynb
Created July 29, 2019 18:07
kornia spatial grad bug
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ducha-aiki
ducha-aiki / matplotlib-fig-no-margins.py
Created July 18, 2019 11:17
Save matplotlib no margins
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from PIL import Image
fname = '../../test-graf/img1.png'
img = Image.open(fname).convert('RGB')
img = np.array(img)
@ducha-aiki
ducha-aiki / pyrdown-test.ipynb
Created July 16, 2019 12:53
Pyrdown bugreport
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ducha-aiki
ducha-aiki / compact_bilinear_pooling.py
Created February 1, 2019 11:41 — forked from vadimkantorov/compact_bilinear_pooling.py
Compact Bilinear Pooling in PyTorch using the new FFT support
import torch
class CompactBilinearPooling(torch.nn.Module):
def __init__(self, input_dim1, input_dim2, output_dim, sum_pool = True):
super(CompactBilinearPooling, self).__init__()
self.output_dim = output_dim
self.sum_pool = sum_pool
generate_sketch_matrix = lambda rand_h, rand_s, input_dim, output_dim: torch.sparse.FloatTensor(torch.stack([torch.arange(input_dim, out = torch.LongTensor()), rand_h.long()]), rand_s.float(), [input_dim, output_dim]).to_dense()
self.sketch_matrix1 = torch.nn.Parameter(generate_sketch_matrix(torch.randint(output_dim, size = (input_dim1,)), 2 * torch.randint(2, size = (input_dim1,)) - 1, input_dim1, output_dim))
self.sketch_matrix2 = torch.nn.Parameter(generate_sketch_matrix(torch.randint(output_dim, size = (input_dim2,)), 2 * torch.randint(2, size = (input_dim2,)) - 1, input_dim2, output_dim))
@ducha-aiki
ducha-aiki / install_orbslam_stuff.sh
Created January 29, 2019 14:09
Install ORBSLAM + python bindings
#!/bin/bash
DIR1=$(pwd)
MAINDIR=$(pwd)/3rdparty
mkdir ${MAINDIR}
cd ${MAINDIR}
conda create -y -n "NavAgents" python=3.6
source activate NavAgents
conda install opencv -y
conda install pytorch torchvision -c pytorch -y
@ducha-aiki
ducha-aiki / res_article_hardnet
Created October 26, 2018 15:04
res_article_hardnet.m
hb_setup();
%%
res = rproc.read('scoresroot', ...
fullfile(hb_path, 'matlab', 'scores', 'default'));
norm_splits = {};
norms_path = fullfile(hb_path, 'matlab', 'data', 'best_normalizations.csv');
norms = readtable(norms_path, 'delimiter', ',');
norms.Properties.RowNames = norms.descriptor;
@ducha-aiki
ducha-aiki / batched_grid_sampling_pytorch.py
Created March 5, 2018 12:36
Batched version of grid sampling for saving memory
import torch
import torch.nn.functional as F
from torch.autograd import Variable
def batched_grid_apply(img, grid, batch_size):
n_patches = len(grid)
if n_patches > batch_size:
bs = batch_size
n_batches = n_patches / bs + 1
for batch_idx in range(n_batches):
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 2 dim: 1 dim: 65 dim: 65 } }
}
layer {
name: "Gx"
type: "Convolution"