Skip to content

Instantly share code, notes, and snippets.

View ahangchen's full-sized avatar
🎯
Focusing

梦里茶 ahangchen

🎯
Focusing
View GitHub Profile
@ahangchen
ahangchen / mnist_estimator.py
Created October 6, 2018 13:53 — forked from elgehelge/mnist_estimator.py
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.5"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
# Show debugging output
tf.logging.set_verbosity(tf.logging.DEBUG)
# Set default flags for the output directories
@ahangchen
ahangchen / iou.py
Created August 25, 2018 07:45
compute iou of two box
#RT:RightTop
#LB:LeftBottom
def IOU(rectangle A, rectangleB):
xs = [A.RT.x, A.LB.x, B.RT.x, B.LB.x]
ys = [A.RT.y, A.LB.y, B.RT.y, B.LB.y]
s_x = sorted(xs)
s_y = sorted(ys)
if s_x[1] in [A.LB.x, B.LB.x] or s_y[1] in [A.LB.y, B.LB.y]:
return 0
@ahangchen
ahangchen / mpii_mat2json.m
Created July 27, 2018 03:11 — forked from farrajota/mpii_mat2json.m
Convert mpii annotations from .mat to .json format
function mpii_convert_json( )
% convert mpii annotations .mat file to .json
%% load annotation file
fprintf('Load annotations... ')
data = load('/media/HDD2/Datasets/Human_Pose/mpii/mpii_human_pose_v1_u12_2/mpii_human_pose_v1_u12_1.mat');
fprintf('Done.\n')
%% open file
fprintf('Open file mpii_human_pose_annotations.json\n')
@ahangchen
ahangchen / label_xml.py
Created March 16, 2018 07:29
Convert image label file to coco style xml
def label2xml(list_path, category_id, ANN_DIR='data/Annotations/', IMG_DIR='data/images/', SET_DIR='data/ImageSets/',
train=True):
set_file_list = [SET_DIR + 'train.txt', SET_DIR + 'minival.txt', SET_DIR + 'testdev.txt', SET_DIR + 'test.txt']
TYPEPREFIX = 'train' if train else 'val'
lines = read_lines(list_path)
line_i = 0
last_name = ''
E = None
img_annotation = None
@ahangchen
ahangchen / map_rank1_faster_eval.py
Created September 24, 2017 03:41
Faster evaluation for computting mAP, rank1_acc in reid problem
def map_rank_faster_eval(query_info, test_info, result_argsort):
# about 10% lower than matlab result
# for evaluate rank1 and map
match = []
junk = []
for q_index, (qp, qc) in enumerate(query_info):
tmp_match = []
tmp_junk = []
for t_index in range(len(test_info)):
@ahangchen
ahangchen / make_parallel.py
Created July 9, 2017 05:29 — forked from ypwhs/make_parallel.py
Keras 多 GPU 同步训练
from keras.layers.merge import Concatenate
from keras.layers.core import Lambda
from keras.models import Model
import tensorflow as tf
def make_parallel(model, gpu_count):
def get_slice(data, idx, parts):
shape = tf.shape(data)
size = tf.concat([ shape[:1] // parts, shape[1:] ],axis=0)