Skip to content

Instantly share code, notes, and snippets.

View warmspringwinds's full-sized avatar

Daniil Pakhomov warmspringwinds

View GitHub Profile
@warmspringwinds
warmspringwinds / intersection.py
Last active February 4, 2022 21:06
computes intersection between two rectangles
# Assuming the origin is in the top left corner
# x axis facing right
# y axis facing downwards
# r.x, r.y -- are top left corners of the rectangle
# with corresponding r.height and r.width
def intersection_area(r_1, r_2):
intersection = 0.0
%matplotlib inline
import tensorflow as tf
import numpy as np
import skimage.io as io
import os, sys
from PIL import Image
from matplotlib import pyplot as plt
sys.path.append("tf-image-segmentation/")
@warmspringwinds
warmspringwinds / multisession.py
Created January 24, 2017 18:31
On how to perform inferece with loading the weights only once
%matplotlib inline
from __future__ import division
import os
import sys
import tensorflow as tf
import skimage.io as io
import numpy as np
@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
%%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 / 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
import numpy as np
cimport numpy as cnp
from skimage._shared.transform cimport integrate
@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')
@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
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