This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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...') | |
exit(-1) | |
else: | |
print(img_path, 'exists') |