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
@podgorskiy
podgorskiy / FrustumCull.h
Created July 12, 2017 10:33
Ready to use frustum culling code. Depends only on GLM. The input is only bounding box and ProjectionView matrix. Based on Inigo Quilez's code.
#include <glm/matrix.hpp>
class Frustum
{
public:
Frustum() {}
// m = ProjectionMatrix * ViewMatrix
Frustum(glm::mat4 m);
#pragma once
#include <Eigen/Dense>
#include <glm/matrix.hpp>
template<typename T, int m, int n>
inline glm::mat<m, n, float, glm::precision::highp> E2GLM(const Eigen::Matrix<T, m, n>& em)
{
glm::mat<m, n, float, glm::precision::highp> mat;
for (int i = 0; i < m; ++i)
{
@podgorskiy
podgorskiy / aabb.h
Last active October 27, 2020 20:49
Drop in templated AABB class build on top of glm.
#pragma once
#include <glm/glm.hpp>
#include <limits>
namespace glm
{
template <int Dim, typename Type>
class aabb
{
public:
@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,
@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 / 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 / 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
# 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,
# 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
@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},