Skip to content

Instantly share code, notes, and snippets.


Tianwei Shen hlzz

Block or report user

Report or block hlzz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:63b0574f1b24972c28203bce0c5c493d
import sys
import cv2
for img_path in all_image_path:
one_img = cv2.imread(img_path, -1 | 128)
if one_img == None:
print(img_path, 'has problem, exit...')
print(img_path, 'exists')
View gist:f0604e4bd2ce9cc6511048b1ba665788
def recover_from_pretrained(sess, net, ckpt_path=None, ckpt_step=-1, np_model_path=None):
recover from pretrained ckpt graph or numpy net parameters
:param sess: the current session
:param net: the feature tower
:param ckpt_path: the ckpt root path (if there is any)
:param ckpt_step: the ckpt step number (if there is any)
:param np_model_path: the numpy model path (if there is any)
:return: the correct step index for the current
hlzz /
Last active Mar 28, 2018
List many many files from a folder
#!/usr/bin/env python
# Copyright 2016, Tianwei Shen, HKUST.
A handy script to execute a command recursively in a folder,
such as 'ls' or 'rm' files.
import os
View gist:db68fb6f401fe8a60586b19222d4f2b9
# some bash tricks (Ubuntu 16.04)
## show the smallest 500 files
ll | awk '{print $5" "$NF}' | sort | head -500
## if find some empty files, you can output them to a file named empty_files.txt
## then rm them using this pipe
cat empty_files.txt | awk '{print "index/"$2}' | xargs rm
## rank file size from largest to smallest and show top 100
hlzz / gist:ba6da6e692beceb4da8b4d5387a8eacc
Created Feb 28, 2018
Generate sprite images for tensorboard
View gist:ba6da6e692beceb4da8b4d5387a8eacc
from PIL import Image
import math
test_image_list = '/home/tianwei/Data/sfm_data/test_image_list' # path to the image list
with open(test_image_list, 'r') as f:
test_images = f.readlines()
test_images = map(str.strip, test_images)
You can’t perform that action at this time.