Skip to content

Instantly share code, notes, and snippets.

@jihyeonRyu
jihyeonRyu / auto_font_size.py
Last active February 7, 2020 05:17
opencv automated fontsize
import cv2
def get_font_point_and_scale(text, x, y, h, w, thickness, font):
(text_width, text_height) = cv2.getTextSize(text, font, 1.0, thickness)[0]
scalex = w/text_width
scaley = h/text_height
scale = min(scalex, scaley)
marginx = 0 if scale == scalex else int(w *(scalex-scale)/scalex*0.5)
marginy = 0 if scale == scaley else int(h *(scaley-scale)/scaley*0.5)
#!/bin/bash
line_num=0
name_list=()
cat list.txt | while read -r line
do
echo $line
mv ./$line ./../file/$line
((line_num++))
done
@jihyeonRyu
jihyeonRyu / save_tf_model.py
Created June 19, 2018 23:25
save tensorflow model to .ckpt and .pb
"""
load model
"""
def load_model(model_dir):
start = time.time()
model_exp = os.path.expanduser(model_dir)
if (os.path.isfile(model_exp)):
print('Model filename: %s' % model_exp)
with gfile.FastGFile(model_exp, 'rb') as f:
@jihyeonRyu
jihyeonRyu / pyinstaller.sh
Last active July 5, 2018 05:55
python source to executable program
pip install pyinstaller
pip install --upgrade pyinstaller
pyinstaller -F --name program_name --noconsole my_program.py
@jihyeonRyu
jihyeonRyu / nvidia-reinstall.sh
Last active June 20, 2018 05:46 — forked from morgangiraud/nvidia-reinstall.sh
Script to reinstall manually nvidia drivers,cuda and cudnn on Ubuntu
########################################
#Ubuntu: 16.04
#NVIDIA Driver: 384.111 ver
#NVIDIA CUDA: 9.0.176 ver
#NVIDIA CUDNN: 7.0 ver
#tensorflow-gpu: 1.6.0 ver
########################################
# Remove anything linked to nvidia
sudo apt-get remove --purge nvidia*
@jihyeonRyu
jihyeonRyu / gpu_error_solution.py
Last active April 19, 2018 07:07
CUDNN_STATUS_NOT_INITIALIZED & CUDA_ERROR_OUT_OF_MEMORY
# status initialize
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1'
# out of memory
import tensorflow as tf
with tf.Graph().as_default():
gpu_options = tf.GPUOptions(allow_growth=True)
@jihyeonRyu
jihyeonRyu / renaming_dir.sh
Created March 28, 2018 01:52
renaming dir name
#!/bin/bash
cnt=0
for NAME in *; do
if [[ -d $NAME ]]; then
NEWNAME=`echo $cnt`;
`echo $NAME $NEWNAME`
mv $NAME $NEWNAME;
((cnt++))
fi
@jihyeonRyu
jihyeonRyu / classifier.sh
Last active March 27, 2018 23:18
classify files by name
#!/bin/bash
# filename: aaa-01.jpg, bbb-01.jpg
for file in *.jpg ; do
arr=(${file//-/ })
dir=dir/${arr[0]}
[[ -d $dir ]] || mkdir -p "$dir"
mv "$file" "$dir"
done
@jihyeonRyu
jihyeonRyu / module_import.py
Last active June 19, 2018 23:34
python cannot found module error
import sys
import os
sys.path.append(os.getcwd())
@jihyeonRyu
jihyeonRyu / renaming.sh
Created June 7, 2017 09:50
rename the files
#!/usr/bin/python
import sys
import os
import shutil
from wand.image import Image
name = raw_input("New Name: ")
files = os.listdir(sys.argv[1])