Skip to content

Instantly share code, notes, and snippets.

View velikodniy's full-sized avatar
:octocat:

Vadim Velicodnii velikodniy

:octocat:
View GitHub Profile
@velikodniy
velikodniy / ray_marching.glsl
Last active December 21, 2020 13:36
Ray marching example
const int MAX_STEPS = 200;
const float MAX_DEPTH = 20.0;
const float EPS = 0.0001;
const float DIFF_EPS = 0.0001;
const float VERT_FOV = radians(40.0);
const vec3 K_a = vec3(0.1, 0.3, 0.0);
const vec3 K_d = vec3(0.3, 0.7, 0.5);
const vec3 K_s = vec3(1.0, 1.0, 1.0);
const float K_shine = 4.0;
use clap::{crate_name, crate_version, App, Arg};
use indicatif::{ParallelProgressIterator, ProgressStyle};
use murmur3::murmur3_x64_128;
use rayon::iter::{IntoParallelRefIterator, ParallelIterator};
use std::fs::metadata;
use std::fs::File;
use std::io::prelude::*;
use std::sync::{Arc, Mutex};
use walkdir::WalkDir;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@velikodniy
velikodniy / dlib_aligning.py
Created June 5, 2020 10:02
dlib-like aligning
import skimage
import numpy as np
LANDMARKS_SRC = np.array([[0.30392274, 0.29713595],
[0.68197238, 0.29713595],
[0.53872643, 0.57810357],
[0.38641786, 0.67528929],
[0.60154214, 0.76057500]])
@velikodniy
velikodniy / convert_and_resize.py
Last active February 20, 2020 06:30
An example of converting images with asyncio/joblib (just an example, don't use in production)
import argparse
import asyncio
import time
from concurrent.futures.thread import ThreadPoolExecutor
from functools import partial
from pathlib import Path
import uvloop
from PIL import Image
@velikodniy
velikodniy / torch_delete.ipynb
Created January 21, 2020 10:29
np.delete ported to PyTorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@velikodniy
velikodniy / assocplot.ipynb
Last active November 29, 2019 12:35
assocplot from R implemented in Python
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@velikodniy
velikodniy / parallel_copy.py
Created October 3, 2019 11:00
Parallel copy
from pathlib import Path
import shutil
from tqdm import tqdm
from joblib import Parallel, delayed
def pcopy(dir_in, dir_out, files_list, processes=8):
dir_in = Path(dir_in)
dir_out = Path(dir_out)
copy_list = [
@velikodniy
velikodniy / zigsaw.py
Created June 26, 2019 00:52
Split and shuffle
def zigsaw(image, num_cuts, random_state=None, **kwargs):
"""Split and shuffle
Args:
image: Input image, currently, only RGB, uint8 images are supported.
num_cuts: number of cuts per side. Image is split `into num_cuts * num_cuts` pieces
random_state:
**kwargs:
Returns:
Image with reshuffled patches.
"""