Skip to content

Instantly share code, notes, and snippets.

@shrubb
shrubb / run-tensorboard.sh
Created June 22, 2023 13:13
Tensorboard launch command
nohup tensorboard --logdir . --samples_per_plugin scalars=500,images=90 --port 8091 --host 0.0.0.0 > tensorboard-log.txt 2>&1 &
@shrubb
shrubb / a.py
Created January 5, 2023 10:31
Competitive programming template
import random
def partition(array, start, end, pivot_idx):
pivot = array[pivot_idx]
array[pivot_idx], array[end - 1] = array[end - 1], array[pivot_idx]
left, right = start, end - 2
# invariant:
# array[< left] < pivot
# array[> right] >= pivot
@shrubb
shrubb / a.cpp
Created February 11, 2022 10:21
Competitive programming template
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <cmath>
@shrubb
shrubb / rename.sh
Last active April 19, 2021 14:45
Rename photos with EXIF dates
# usage:
# $ ls
# 2.23.1.jpeg 2.23.jpg DSC_0383.JPG DSC_0411.JPG DSC_0439.JPG DSC_0467.JPG
# DSC_0496.JPG DSC_0524.JPG DSC_0553.JPG DSC_0582.JPG DSC_0610.JPG DSC_0638.JPG
# DSC_0384.JPG DSC_0412.JPG DSC_0440.JPG DSC_0468.JPG DSC_0497.JPG DSC_0525.JPG
# ... ... ...
# DSC_0611.JPG DSC_0639.JPG DSC_0357.NEF DSC_0385.JPG DSC_0413.JPG DSC_0441.JPG
# DSC_0554.JPG DSC_0583.JPG DSC_0358.NEF DSC_0386.JPG DSC_0414.JPG DSC_0442.JPG
# $ ./../rename.sh
@shrubb
shrubb / my-pytorch-build.sh
Last active October 17, 2021 17:27
PyTorch 1.9.1 build command
LIBS_ROOT=/nfs/hpc-4/hdd-raid/e_burkov/Libraries
# CMake variables (CMake will detect them)
CUDNN_ROOT=$LIBS_ROOT/cudnn-11.3
export CUDNN_LIBRARY_PATH=$CUDNN_ROOT/lib64/libcudnn.so
export CUDNN_LIBRARY=$CUDNN_ROOT/lib64
export CUDNN_INCLUDE_PATH=$CUDNN_ROOT/include
export CUDNN_INCLUDE_DIR=$CUDNN_ROOT/include
# Environment variables that will be detected too but aren't CMake variables
@shrubb
shrubb / measure-time-dw-conv.lua
Created August 4, 2017 21:00
A rough benchmark script for depthwise convolution
require 'cunn'
torch.setdefaulttensortype('torch.FloatTensor')
torch.manualSeed(666)
cutorch.manualSeed(666)
-- change these as needed
-- no automated testing, sorry :(
local nInputPlane, nOutputPlane, inputHeight, inputWidth = 128, 1, 52, 52
@shrubb
shrubb / beam-search-AE.py
Created May 28, 2017 19:42
Butyrka: beam search for Nikita's autoencoder
def get_next_token_probabilities(curr_token_sequence, z, embed_fn, decode_fn):
curr_tokens_embeddings = embed_fn([curr_token_sequence])
return decode_fn(curr_tokens_embeddings, z)[0][-1]
def beam_search_step(current_token_sequence, get_next_token_probabilities, depth=3, width=4):
"""
returns: next token guess
"""
candidates = [(1.0, [])] # (probability, candidate_appendix)
@shrubb
shrubb / csv_to_txt.py
Created May 28, 2017 16:08
Butyrka csv-to-txt preprocessing
# encoding: utf-8
import sys
import csv
import re
def preprocess_text(text):
text = text.replace('\t', '')
text = text.replace('ё' , 'е')
text = text.replace('…' , '...')
for c in '–—–':
@shrubb
shrubb / nla-lectures.ipynb
Created December 8, 2016 14:24
NLA lectures
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Interactive Face Recognition with GPU

To provide an example of how OpenCV's CUDA module can be used in Torch, we have implemented interactive face recognition in this application.

Important warning

In this very example, the recognition quality may be rather poor as, in fact, the OpenFace's face recognition framework is intended to work in a more complicated way. Here, we didn't locate facial landmarks and estimate head pose, although this is an essential part of the pipeline. Keep this in mind when working with this task, and consult OpenFace's website for further information.

How to use it