Skip to content

Instantly share code, notes, and snippets.

@jhjin
jhjin / jpeg-sanity-check.lua
Created February 13, 2016 02:14
JPEG sanity check
require('image')
local function iterate(src)
for dir in paths.iterdirs(src) do
local subdir = path.join(src, dir)
print(subdir)
for file in paths.iterfiles(subdir) do
local filepath = path.join(subdir, file)
local ok, img = pcall(image.loadJPG, filepath, 3, 'float')
if not ok then
#include <stdio.h>
#include <stdlib.h>
// CUDA: grid stride looping
#define CUDA_KERNEL_LOOP(i, n) \
for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < (n); i += blockDim.x * gridDim.x)
// Use 1024 threads per block, which requires cuda sm_2x or above
const int CUDA_NUM_THREADS = 1024;
@jhjin
jhjin / convert-model.lua
Last active February 24, 2016 02:39
A script to convert a parallel and distributed network to a single stream model with removal of training-dependent modules (BN, dropout)
torch.setdefaulttensortype('torch.FloatTensor')
require('torch')
require('pl')
require('nn')
require('cunn')
require('cudnn')
local opt = lapp([[
@jhjin
jhjin / align-dataset.lua
Last active February 24, 2016 02:38
A script to align faces in the images located in a folder of folders (dlib required)
#!/usr/bin/env th
--
-- *Face alignment on dataset
--
-- For given (source dataset) path, it traverses all subdirectories and
-- align/crop faces from all images and save them in the destination path.
--
-- Author: Jonghoon Jin
--
require('pl')
@jhjin
jhjin / create-dataset.lua
Last active February 24, 2016 02:36
A script to create a dataset for imagenet-multiGPU.torch training script
require('pl')
require('xlua')
require('image')
local dir = require('pl.dir')
local path = require('pl.path')
local opt = lapp([[
Required parameters
--src (default '.') path for source image root directory
@jhjin
jhjin / wget-ieee.sh
Last active February 7, 2018 19:02
wget IEEE paper
# Download IEEE article via a server that has IEEE text access (Usage: $ ieee 5738219)
function ieee() {
local cmd="'wget \"http://ieeexplore.ieee.org/stampPDF/getPDF.jsp?tp=&isnumber=&arnumber=${@}\" -O paper.pdf'"
ssh elab5 eval ${cmd}
scp elab5:~/paper.pdf $@.pdf
ssh elab5 'rm -f paper.pdf'
}
@jhjin
jhjin / deeplearningbook.bash
Created May 31, 2016 03:47
Easy downloading script for deep learning book
#!/usr/bin/bash
iterator=1
url="http://www.deeplearningbook.org/contents/"
array=(
TOC.html
acknowledgements.html
notation.html
intro.html
part_basics.html
linear_algebra.html
@jhjin
jhjin / Makefile.config
Last active October 20, 2016 05:30
Caffe Makefile config for Mac without opencv3 + no NVIDIA GPU
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!
# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1
# CPU-only switch (uncomment to build without GPU support).
CPU_ONLY := 1
# uncomment to disable IO dependencies and corresponding data layers
@jhjin
jhjin / install-caffe-on-mac.sh
Last active October 20, 2016 05:30
a quick script for installing Caffe on Mac
brew install python
brew install wget
brew install protobuf
brew install boost-python
brew install lmdb
brew install leveldb
brew install snappy
brew install gflags
brew install glog
brew tap homebrew/science
@jhjin
jhjin / spatialize-net.py
Created August 29, 2016 23:31
simple script to spatialize caffe model
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
import caffe
caffe.set_mode_cpu()
path_src = 'src.caffemodel'
path_dst = 'dst.caffemodel'
net_src = caffe.Net('src.prototxt', path_src, caffe.TEST)