Skip to content

Instantly share code, notes, and snippets.

def save_model(sess, saver, checkpoint_dir, model_name, step):
if not os.path.exists(checkpoint_dir):
os.makedirs(checkpoint_dir)
saver.save(sess, os.path.join(checkpoint_dir, model_name), global_step=step)
def load_model(sess, saver, checkpoint_dir):
print("[*] Reading checkpoints...")
ckpt = tf.train.get_checkpoint_state(checkpoint_dir)
if ckpt and ckpt.model_checkpoint_path:
ckpt_name = os.path.basename(ckpt.model_checkpoint_path)
@codingPingjun
codingPingjun / data_gen.py
Created March 2, 2017 08:05
Providing Data for Segmentation
def generate_arrays_from_file(path):
while 1:
f = open(path)
for line in f:
# create numpy arrays of input data
# and labels, from each line in the file
x, y = process_line(line)
img = load_images(x)
yield (img, y)
f.close()
@codingPingjun
codingPingjun / create_prior_box.py
Created January 27, 2017 03:11
SSD prior box creation
import pickle
import numpy as np
import pdb
img_width, img_height = 300, 300
box_configs = [
{'layer_width': 38, 'layer_height': 38, 'num_prior': 3, 'min_size': 30.0,
'max_size': None, 'aspect_ratios': [1.0, 2.0, 1/2.0]},
{'layer_width': 19, 'layer_height': 19, 'num_prior': 6, 'min_size': 60.0,
'max_size': 114.0, 'aspect_ratios': [1.0, 1.0, 2.0, 1/2.0, 3.0, 1/3.0]},
@codingPingjun
codingPingjun / tmux-cheatsheet.markdown
Created December 5, 2016 21:45 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@codingPingjun
codingPingjun / pdb.md
Last active November 10, 2016 02:59
PDB debugger

python debugger command

@codingPingjun
codingPingjun / git.md
Last active October 26, 2016 02:07
Git and GitHub Usage

1. setup the user.name and user.email

git config user.name USERNAME

git config user.email USERNAME@example.com

git config --list # list all configurations

~/.gitconfig # path of git config file

2. Set remote url (multiple account)

@codingPingjun
codingPingjun / vim.md
Last active February 12, 2019 10:16
Vim Command

Vim Cheat Sheet

File Operation

:o file - open file

:w file - save file as

:close - close current pane

Cursor Movement

@codingPingjun
codingPingjun / linux.md
Last active May 20, 2017 01:19
Linux Command

0. Command help

man cd

1. Find string "abc" in subfolders

grep -rin "abc" .

2. Search specified file

locate abc.txt

3. Unzip compressed file

tar -zxvf abc.tar.gz

tar -jxvf abc.tar.bz2

@codingPingjun
codingPingjun / heroku.sh
Last active October 26, 2016 01:53
Heroku Common Command
login in: heroku login
create: heroku create [HelloFlask]
depoly: git push heroku master
open: heroku open
delete: heroku apps:destroy --app [sleepy-hamlet-63859]
email:codingpingjun@gmail.com passwd: !G****
@codingPingjun
codingPingjun / ipython_remote_acess.md
Last active December 6, 2016 17:17
IPython Notebook Remote Access

Open Notebook on server

ipython notebook --no-browser --port=7007

Set Mapping in client

ssh -N -f -L localhost:5005:localhost:7007 username@ip

Open Remote Notebook in client

http://localhost:5005

Kill Local Port

lsof -i:5005[port num] kill -9 55514[pid]