Skip to content

Instantly share code, notes, and snippets.

View tnarihi's full-sized avatar

Takuya Narihira tnarihi

  • Sony
  • Tokyo, Japan
View GitHub Profile
@tnarihi
tnarihi / mydockerrc
Last active July 26, 2017 14:40
My Docker bashrc
alias docker_build="docker build --build-arg http_proxy=${http_proxy} --build-arg https_proxy=${https_proxy}"
alias docker_run="nvidia-docker run -ehttp_proxy=${http_proxy} -ehttps_proxy=${https_proxy} -eftp_proxy=${ftp_proxy} --rm"
docker_run_user () {
tempdir=$(mktemp -d)
getent passwd > ${tempdir}/passwd
getent group > ${tempdir}/group
nvidia-docker run -ehttp_proxy=${http_proxy} -ehttps_proxy=${https_proxy} -eftp_proxy=${ftp_proxy} -v${HOME}:${HOME} -w$(pwd) --rm -u$(id -u):$(id -g) $(for i in $(id -G); do echo -n ' --group-add='$i; done)\
-v ${tempdir}/passwd:/etc/passwd:ro -v ${tempdir}/group:/etc/group:ro "$@"
}
@tnarihi
tnarihi / dockerbuild.in.py
Created May 6, 2017 23:00
Docker build with template
#! /usr/bin/env python
"""
<usage> ./dockerbuild.in <dockerfile.in> [dockerfile.in variables...] [docker build options...]
dockerfile.in variables can be passed in a format of "var:=value".
For example, if Dockerfile.in is the following:
```
FROM ubuntu:{ubuntu_version}
@tnarihi
tnarihi / Preference.sublime-settings
Last active March 30, 2016 01:54
My preferences of Sublime pro 2/3
{
"font_size": 10,
"ignored_packages":
[
"Vintage"
],
"rulers":
[
80,
100,
@tnarihi
tnarihi / whdr.py
Created September 29, 2015 03:53
Compute WHDR
import numpy as np
def compute_hdr_whdr_core(pred, tar, w):
"""Compute HDR and WHDR of pairs in a single image
Args:
pred : 1d array, predicition
tar : 1d array, target
w : 1d array, weights (confidence)
from __future__ import print_function
import argparse
import random
parser = argparse.ArgumentParser()
parser.add_argument('text_input', help='Path to input file')
parser.add_argument('--seed', type=int, default=313,
help='Seed of random')
parser.add_argument('--stack', type=int, default=9,
help='Number of stack (default: 9)'),
@tnarihi
tnarihi / README.md
Last active August 27, 2015 01:21
Stacking caffenet N times in channels direction.

Stack CaffeNet

Stacking caffenet N times in channels direction.

Example usage

This will generate 9 times stacked caffenet.

PYTHONPATH=$HOME/workspace/caffe-latest/python python stack_caffenet.py $HOME/caffe/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel 9

Run python stack_caffenet.py -h for more details.

import numpy as np
from sklearn.metrics import confusion_matrix
preds = ()
labels = ()
n_samples = ... number of examples in test set ...
batch_size = ... batch size ...
net = ... caffe test net ...
n_batch = int(np.ceil(n_samples / batch_size))
for i in range(n_batch):
net.forward()
@tnarihi
tnarihi / example-saving-vgg16-weights.ipynb
Created April 21, 2015 01:35
Saving the weights of VGG-16 as Matlab format
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnarihi
tnarihi / upsampling-with-deconv-layer.ipynb
Last active March 19, 2019 16:11
Upsampling with DeconvolutionLayer in Caffe. Open as a notebook here: http://nbviewer.ipython.org/gist/tnarihi/54744612d35776f53278
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tnarihi
tnarihi / README.md
Last active September 29, 2015 00:48
Batch Python installation script for dependencies of tnarihi Caffe .

Batch Python installation script for dependencies of tnarihi Caffe

This will install the Anaconda distribution of Python and enable opencv2 features and some CUDA wrappers. This script is tested on my Ubuntu 14.04.

This script is not well-designed and has no error handling, so I recommend you to run the commands in the script step-by-step.