Skip to content

Instantly share code, notes, and snippets.

View dboyliao's full-sized avatar

dboyliao dboyliao

View GitHub Profile
@dboyliao
dboyliao / gen_gauss_kernel.py
Created June 6, 2017 08:19
Gaussian kernel generator using numpy
#!/usr/bin/env python3
# -*- coding: utf8 -*-
#https://stackoverflow.com/questions/29731726/how-to-calculate-a-gaussian-kernel-matrix-efficiently-in-numpy
import numpy as np
def gauss_kernel(size=5, sigma=None):
if sigma is None:
sigma = size/5
xs = np.arange(-size//2 + 1, size//2 + 1)
grid_x, grid_y = np.meshgrid(xs, xs)
@dboyliao
dboyliao / smooth_derivative.py
Created June 6, 2017 11:00
Image derivative with smoothed derivative kernel
#!/usr/bin/env python3
# -*- coding: utf8 -*-
#https://stackoverflow.com/questions/29731726/how-to-calculate-a-gaussian-kernel-matrix-efficiently-in-numpy
import numpy as np
from scipy.ndimage import convolve
def gauss_kernel(size=5, sigma=None):
if sigma is None:
sigma = size/5
xs = np.arange(-size//2 + 1, size//2 + 1)
@dboyliao
dboyliao / opencv_cmd_args_example.cpp
Created June 8, 2017 08:33
OpenCV CommandLineParser Example
/*
* Adapt from this example: http://docs.opencv.org/3.0-beta/modules/core/doc/command_line_parser.html
*/
#include "opencv2/core.hpp"
#include "opencv2/core/cvstd.hpp" // cv::String
#include <iostream>
using namespace cv;
using std::cout;
using std::cerr;
@dboyliao
dboyliao / julia.pc
Last active July 11, 2017 07:25
Package Information file for pkg-config for Julia Lang on Mac
# Package Information for pkg-config
prefix=/Applications/Julia-0.6.app/Contents/Resources/julia
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/julia
Name: Julia
Description: A fresh approach to technical computing
Version: 0.6
python
*.pb
*.pbtxt
*
!*.ipynb
!.gitignore
!*.py
*_pb2.py
!requirements.txt
@dboyliao
dboyliao / .gitignore
Last active July 24, 2017 12:41
Saving graph for inference
*
!.gitignore
!*.ipynb
!*.py
!*.jpg
!synset.txt
!README.md
@dboyliao
dboyliao / .gitignore
Last active July 20, 2017 08:22
Tensorflow Serialization Part 2
*
!.gitignore
!*.ipynb
!*.py
@dboyliao
dboyliao / class_deco_example.py
Last active August 9, 2017 15:30
python class decorator example (Just for fun XDD)
# -*- coding:utf-8 -*-
from __future__ import print_function
from functools import wraps
def log_deco(func):
@wraps(func)
def wrapped(*args, **kwargs):
print("calling {}".format(func.__name__))
return func(*args, **kwargs)
#!/usr/bin/env python3
# -*- coding:utf8 -*-
def main():
a = 5
def foo():
nonlocal a;
a += 1
print(a)
print(foo())