Skip to content

Instantly share code, notes, and snippets.

View dalgu90's full-sized avatar

Juyong Kim dalgu90

View GitHub Profile
@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 / 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 / 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"
# 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 / 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