Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@satojkovic
satojkovic / EMD.py
Created February 18, 2013 18:16
Earth Mover's Distance
#-*- encoding: utf-8 -*-
#
# Earth Mover's Distance
#
# Reference: http://aidiary.hatenablog.com/entry/20120804/1344058475
#
import numpy as np
import rpy2.robjects as robjects
def plates(stack, i, num_used, N, P, K):
# Brute force: O(K^N)
if i >= N:
return -1
current_total = -1
for n in range(K + 1):
if num_used + n > P:
break
elif num_used + n == P:
current_total = max(current_total, sum(stack[i][:n]))
@satojkovic
satojkovic / algorithms_openpose.md
Created March 20, 2019 13:52 — forked from alesolano/algorithms_openpose.md
OpenPose TensorFlow Alogrithms
@satojkovic
satojkovic / sift_match.rb
Last active March 12, 2019 15:21
image matching using SIFT
#!/usr/bin/env ruby
require 'rubygems'
require 'rmagick'
include Math
class KDTreeNode
attr_accessor :data, :left_child, :right_child
@satojkovic
satojkovic / vlfeat.rb
Created December 16, 2012 22:56
sift test
#!/usr/bin/env ruby
require 'rubygems'
require 'rmagick'
include Math
class Node
attr_accessor :location, :left_child, :right_child
@satojkovic
satojkovic / cudnn_version.cpp
Created October 18, 2017 13:02
print installed cudnn version
#include <cudnn.h>
#include <iostream>
int main(int argc, char** argv) {
std::cout << "CUDNN_VERSION: " << CUDNN_VERSION << std::endl;
return 0;
}
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World'
if __name__ == '__main__':
app.run()
@satojkovic
satojkovic / knn.R
Last active April 15, 2016 12:25
k nearest neighbor from Machine Learning for Hackers
#
# read data frame from csv
#
df <- read.csv('data/example_data.csv')
#
# produce distance matrix
#
distance.matrix <- function(df)
{
#-*- encoding: utf-8 -*-
import numpy as np
import cv2
if __name__ == '__main__':
img = cv2.imread("Ryo.jpg", 0)
params = {'ksize':(31, 31), 'sigma':1.0, 'theta':0, 'lambd':15.0,