Skip to content

Instantly share code, notes, and snippets.

@twmht
twmht / extract_ILSVRC.sh
Created December 28, 2020 06:27 — forked from BIGBALLON/extract_ILSVRC.sh
script for ImageNet data extract.
#!/bin/bash
#
# script to extract ImageNet dataset
# ILSVRC2012_img_train.tar (about 138 GB)
# ILSVRC2012_img_val.tar (about 6.3 GB)
# make sure ILSVRC2012_img_train.tar & ILSVRC2012_img_val.tar in your current directory
#
# https://github.com/facebook/fb.resnet.torch/blob/master/INSTALL.md
#
# train/
@twmht
twmht / seaborn_heatmap.py
Created January 10, 2020 03:04
seaborn heatmap
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sn
# only work for matplotlib = 3.1.0
matrix = np.load('/home/acer/confusion.npy')
@twmht
twmht / build_opencv.sh
Created December 12, 2019 08:29
build python3 of opencv
PYTHON3_ROOT=/home/acer/.pyenv/versions/3.7.4
# cmake -D CMAKE_BUILD_TYPE=RELEASE \
# -D BUILD_NEW_PYTHON_SUPPORT=ON \
# -D BUILD_opencv_python3=ON \
# -D HAVE_opencv_python3=ON \
# -D CMAKE_INSTALL_PREFIX=/home/acer/opencv_build \
# -D PYTHON3_EXECUTABLE=/home/acer/.pyenv/versions/3.7.4/bin/python \
# -D PYTHON_DEFAULT_EXECUTABLE=${PYTHON3_ROOT}/bin/python \
# -D PYTHON3_INCLUDE_DIR=${PYTHON3_ROOT}/include/python3.7m \
@twmht
twmht / example.cc
Last active September 29, 2019 05:59
opencl example
#include <iostream>
#ifdef __APPLE__
#include <OpenCL/cl.hpp>
#else
#include <CL/cl.hpp>
#endif
int main() {
// get all platforms (drivers), e.g. NVIDIA
std::vector<cl::Platform> all_platforms;
@twmht
twmht / Makefile
Created October 31, 2017 15:26
tensorboard
PROJECT := caffe
CONFIG_FILE := Makefile.config
# Explicitly check for the config file, otherwise make -k will proceed anyway.
ifeq ($(wildcard $(CONFIG_FILE)),)
$(error $(CONFIG_FILE) not found. See $(CONFIG_FILE).example.)
endif
include $(CONFIG_FILE)
BUILD_DIR_LINK := $(BUILD_DIR)
@twmht
twmht / deconv.py
Created October 26, 2017 17:03
deconv
# import tensorflow as tf
# # part1
# #case 2
# input = tf.Variable(tf.random_normal([3,97,97,10]))
# filter = tf.Variable(tf.random_normal([3,3,10,20]))
# x = tf.nn.conv2d(input, filter, strides=[1, 4, 4, 1], padding='SAME')
# # y = tf.nn.conv2d_transpose(x, filter, output_shape=[1,5,5,3], strides=[1,2,2,1],padding="SAME")
# with tf.Session() as sess:
# sess.run(tf.initialize_all_variables())
@twmht
twmht / linear.lua
Created September 20, 2017 16:02
torch simple neural network
# reference https://ckmarkoh.github.io/blog/2017/01/01/torch-nn-tutorial-4-backward-propagation/
# we want to learn y=x+1
require 'nn'
y = torch.Tensor(5)
mlp = nn.Sequential()
mlp:add(nn.Add(5))
function gradUpdate(mlp, x, y, criterion, learningRate)
## 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
@twmht
twmht / pr.md
Created June 25, 2017 06:34 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@twmht
twmht / DeepLearningFaces.md
Created June 8, 2017 09:19 — forked from jdsgomes/DeepLearningFaces.md
Deep Learning for Face Recognition

Deep Learning for Face Recognition (May 2016)

Popular architectures

  • FaceNet (Google)
    • They use a triplet loss with the goal of keeping the L2 intra-class distances low and inter-class distances high
  • DeepID (Hong Kong University)
    • They use verification and identification signals to train the network. Afer each convolutional layer there is an identity layer connected to the supervisory signals in order to train each layer closely (on top of normal backprop)
  • DeepFace (Facebook)
    • Convs followed by locally connected, followed by fully connected