Skip to content

Instantly share code, notes, and snippets.

View podgorskiy's full-sized avatar
🏠
Working from home

Stanislav Pidhorskyi podgorskiy

🏠
Working from home
View GitHub Profile
#pragma once
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <functional>
namespace misc
{
std::vector<float> GaussKernel(float sigma, int kernelSize, int sampleCount = 1000);
@podgorskiy
podgorskiy / wavelength.py
Created October 27, 2020 05:09
CIE color matching functions approximation
import numpy as np
from scipy.optimize import curve_fit
from matplotlib import pyplot as plt
t = np.arange(380.0, 781.0, 5.0)
s = np.asarray([
[0.0014, 0.0000, 0.0065], [0.0022, 0.0001, 0.0105], [0.0042, 0.0001, 0.0201],
[0.0076, 0.0002, 0.0362], [0.0143, 0.0004, 0.0679], [0.0232, 0.0006, 0.1102],
[0.0435, 0.0012, 0.2074], [0.0776, 0.0022, 0.3713], [0.1344, 0.0040, 0.6456],
@podgorskiy
podgorskiy / Makefile
Created September 27, 2020 15:12
Makefile for LaTeX
TEX = max_print_line=10000 pdflatex -shell-escape -interaction=nonstopmode -file-line-error -halt-on-error
BIB = bibtex
VIEWER = evince
.PHONY: all view
view : rebuild
$(VIEWER) main.pdf &
rebuild: clean all
@podgorskiy
podgorskiy / references.bib
Created September 27, 2020 00:27
references
% Encoding: UTF-8
@article{alina2018openimages,
author = {Alina Kuznetsova and Hassan Rom and Neil Alldrin and Jasper Uijlings and Ivan Krasin and Jordi Pont-Tuset and Shahab Kamali and Stefan Popov and Matteo Malloci and Tom Duerig and Vittorio Ferrari},
title = {The Open Images Dataset V4: Unified image classification, object detection, and visual relationship detection at scale},
year = {2018},
journal = {arXiv:1811.00982}
}
@inproceedings{rodrigo2019iteractive,
author = {Rodrigo Benenson and Stefan Popov and Vittorio Ferrari},
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import contextlib
import datetime
import io
import json
import logging
import numpy as np
import os
import pycocotools.mask as mask_util
from fvcore.common.file_io import PathManager, file_lock
# Copyright 2020 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@podgorskiy
podgorskiy / rotation_matrix_optimization.py
Last active February 26, 2020 07:32
Random search for ratation matrix optimization
import numpy as np
from random import random
def optimize(f, t_scale, steps=10000, tolerance=1e-6, step_decay_exp=0.01):
def random_rotation(size):
shape = [size, size]
a = np.random.normal(-1.0, 1.0, shape)
u, s, v = np.linalg.svd(a, full_matrices=False)
return u
@podgorskiy
podgorskiy / rotation_matrix.py
Last active February 26, 2020 06:34
Torch module that represents learnable parametrized rotation matrix
import torch
from torch import nn
import numpy as np
class RotationMatrix(torch.nn.Module):
def __init__(self):
super(RotationMatrix, self).__init__()
self.betta = nn.Parameter(torch.tensor(np.random.randn(3), dtype=torch.float32), requires_grad=True)
@podgorskiy
podgorskiy / gist:542a55f70d074139a71ba3c6560719d3
Created October 18, 2019 19:29
binary search of maximum on concave function
import matplotlib.pyplot as plt
import numpy as np
import math
def find_maximum(f, min_x, max_x, epsilon=1e-3):
def binary_search(l, r, fl, fr, epsilon):
mid = l + (r - l) / 2
fm = f(mid)
binary_search.eval_count += 1
@podgorskiy
podgorskiy / batch_provider.py
Created October 16, 2018 03:38
Batch provider. Generic generator tool for multithreaded batch-iteration through data. With progress bar and custom transforms of data.
# Copyright 2018 Stanislav Pidhorskyi
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,