Skip to content

Instantly share code, notes, and snippets.

View warmspringwinds's full-sized avatar

Daniil Pakhomov warmspringwinds

View GitHub Profile
@warmspringwinds
warmspringwinds / index.html
Created July 23, 2014 18:52
Example of calculating coordinates of visible tiles in Leaflet.js
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<link rel="stylesheet" href="main.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<title>Leaflet test page</title>
</head>
<body>
import numpy as np
from lib import get_scale_local_maximas_orignal, get_scale_local_maximas_vectorized
from compiled import get_scale_local_maximas_cython
lapl_dummy = np.random.rand(100,100,100)
coords = np.random.random_integers(0,99, size=(1000,3))
%timeit get_scale_local_maximas_orignal(coords, lapl_dummy)
%timeit get_scale_local_maximas_cython(coords, lapl_dummy)
import numpy as np
input = np.zeros((2, 2), dtype=complex)
input[0, 0] = 0.5 + 250j
input[0, 1] = -0.5
input[1, 0] = 0.5
input[1, 1] = -0.5 + 250j
result = np.linalg.svd(input, full_matrices=True)
import numpy as np
cimport numpy as cnp
def get_scale_local_maximas_cython(cnp.ndarray[cnp.int_t, ndim=2] cube_coordinates, cnp.ndarray[cnp.double_t, ndim=3] laplacian_cube):
"""
Check provided cube coordinate for scale space local maximas.
Returns only the points that satisfy the criteria.
A point is considered to be a local maxima if its value is greater
@warmspringwinds
warmspringwinds / gist:516772c7ddedf5b579b9
Last active September 11, 2019 12:46
Face detection
# Use local scikit-image
import sys
sys.path.insert(0, "/home/dan/University/projects/gsoc_face_detection/scikit-image/")
from skimage.feature import multiblock_local_binary_pattern
from skimage.transform import integral_image
import numpy as np
import skimage.io as io
import xml.etree.ElementTree as ET
@warmspringwinds
warmspringwinds / gist:bc2b9ddbf2c030ba83d4
Last active August 29, 2015 14:22
Cascade and sliding window
import skimage.io as io
from skimage.transform import pyramid_gaussian, rescale
from skimage.util import view_as_windows
from opencv_trainfile_test import detect_face
from matplotlib import pyplot as plt
import matplotlib.patches as patches
current_img = io.imread('roi.jpg')
%%cython -a
# cython: cdivision=True
# cython: boundscheck=False
# cython: nonecheck=False
# cython: wraparound=False
import numpy as np
cimport numpy as cnp
from skimage._shared.transform cimport integrate
@warmspringwinds
warmspringwinds / gist:12017d40d358ed03125c
Created July 9, 2015 08:47
Excessive detection window elimination.
def intersection_ratio(rect_a, rect_b):
r_a_1 = rect_a["r"]
r_a_2 = rect_a["r"] + rect_a["height"]
c_a_1 = rect_a["c"]
c_a_2 = rect_a["c"] + rect_a["width"]
r_b_1 = rect_b["r"]
r_b_2 = rect_b["r"] + rect_b["height"]
c_b_1 = rect_b["c"]
%%cython -a
# cython: cdivision=True
# cython: boundscheck=False
# cython: nonecheck=False
# cython: wraparound=False
# distutils: language = c++
from libcpp.vector cimport vector
from libcpp.pair cimport pair
import skimage.io as io
@warmspringwinds
warmspringwinds / main.py
Created December 18, 2016 03:54
Getting intermediate features from VGG-16 network in TF-Slim
%matplotlib inline
from __future__ import division
import numpy as np
import tensorflow as tf
import sys
import os
from matplotlib import pyplot as plt
import urllib2