Skip to content

Instantly share code, notes, and snippets.

View dalgu90's full-sized avatar

Juyong Kim dalgu90

View GitHub Profile
@dalgu90
dalgu90 / ycm_install_guide.txt
Created May 4, 2016 11:43
YCM installation guide(ver. wookayin dotfiles)
(http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/ 따라서 완전히 그대로 해도 될 것 같긴 하지만)
1. ~/.vim/plugins.vim 에
Plug 'Valloric/YouCompleteMe'
라인 추가
2. vim +PlugInstall
3. cd ~/.vim/plugged/YouCompleteMe
./install.sh --clang-completer
# Apply proximal gradient for the variables with l1 lasso loss
# Non-negative weights constraint
if L1_LOSS_WEIGHT > 0:
for var in tf.get_collection(utils.LASSO_KEY):
th_t = tf.fill(tf.shape(var), tf.convert_to_tensor(L1_LOSS_WEIGHT) * lr)
zero_t = tf.zeros(tf.shape(var))
var_temp = var - th_t * tf.sign(var)
assign_op = var.assign(tf.select(tf.less(tf.abs(var), th_t), zero_t, var_temp))
l1_op_list.append(assign_op)
print('\tL1 loss added: %s(strength: %f)' % (var.name, L1_LOSS_WEIGHT))
@dalgu90
dalgu90 / fix_ilsvrc12_imgs.py
Last active October 2, 2018 16:17
This convert some of ILSVRC 2012 images to make all the images be JPEG RGB images.
#!/usr/bin/env python
from PIL import Image
import os
# image_root = '/nas/dataset/ILSVRC2012/train/'
image_root = '/data/common_datasets/ILSVRC2012/train/'
cmyk_img_subpaths = ["n01739381/n01739381_1309.JPEG"
,"n02077923/n02077923_14822.JPEG"
@dalgu90
dalgu90 / clean_up_ckpt.py
Last active March 20, 2017 09:34
Delete caffe/tensorflow checkpoint files with the non-last iteration. usage: python clean_up_ckpt.py --root_dir ~/workspace --ckpt_type tensorflow
import os
import argparse
import re
import numpy as np
parser = argparse.ArgumentParser()
parser.add_argument("--root_dir", help="The uppermost directory to clean up")
parser.add_argument("--ckpt_type", help="Ckpt type(tensorflow, caffe)")
args = parser.parse_args()
@dalgu90
dalgu90 / check_jpeg_dataset.py
Last active August 3, 2016 11:31
Traverse dataset directories and check JPEG files, and print out filenames with invalid JPEG header.
from __future__ import print_function
import sys
import os
import re
argv = sys.argv[1:]
if not argv:
sys.stderr.write('Usage: python check_dataset_valid.py [IMAGE_ROOT] [OUTPUT_FNAME]\n')
sys.exit(1)
@dalgu90
dalgu90 / protomean_to_npy.py
Created August 27, 2016 14:24
convert from proto mean file to npy file
import sys
CAFFE_ROOT = '../../'
sys.path.insert(0, CAFFE_ROOT + 'python/')
import caffe
import numpy as np
if len(sys.argv) != 3:
print "Usage: python protomean_to_npy.py proto.mean out.npy"
sys.exit()
@dalgu90
dalgu90 / pdf_even_page.py
Last active August 22, 2022 09:25
Make all PDF files to have even pages, inserting a blank page at the end of each file. PyPDF2 package needed(pip install pypdf2)
#!/bin/usr/env python
# Usage: python pdf_even_page.py
import os
import PyPDF2
import re
def make_even_page(in_fpath, out_fpath):
reader = PyPDF2.PdfFileReader(in_fpath)
@dalgu90
dalgu90 / count_ckpt_param.py
Last active September 8, 2022 00:40
Count the number of parameter in a TensorFlow checkpoint file. (Usage: python count_ckpt_param.py path-to-ckpt)
#!/usr/bin/env python
import sys
import tensorflow as tf
import numpy as np
if len(sys.argv) == 2:
ckpt_fpath = sys.argv[1]
else:
print('Usage: python count_ckpt_param.py path-to-ckpt')
@dalgu90
dalgu90 / install_tree_local.sh
Created February 19, 2018 03:03
Install linux tree command on local path
#!/bin/sh
PREFIX="$HOME/.local/"
install_tree() {
# The project page of linux "tree" command is located at http://mama.indstate.edu/users/ice/tree
TMP_TREE_DIR="/tmp/$USER/tree"; mkdir -p $TMP_TREE_DIR
wget -nc -O $TMP_TREE_DIR/tree.tgz "http://mama.indstate.edu/users/ice/tree/src/tree-1.7.0.tgz"
tar -xvzf $TMP_TREE_DIR/tree.tgz -C $TMP_TREE_DIR --strip-components 1
@dalgu90
dalgu90 / install_ctags_local.sh
Last active March 22, 2018 06:05
Install linux ctags on local path
#!/bin/sh
PREFIX="$HOME/.local/"
install_ctags() {
# The project page of linux "ctags" command is located at http://ctags.sourceforge.net/
TMP_CTAGS_DIR="/tmp/$USER/ctags"; mkdir -p $TMP_CTAGS_DIR
wget -nc -O $TMP_CTAGS_DIR/ctags.tar.gz "http://prdownloads.sourceforge.net/ctags/ctags-5.8.tar.gz"
tar -xvzf $TMP_CTAGS_DIR/ctags.tar.gz -C $TMP_CTAGS_DIR --strip-components 1