Skip to content

Instantly share code, notes, and snippets.

Working from home

Hao Xi haoxi911

Working from home
  • Marietta, GA
Block or report user

Report or block haoxi911

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 dataset_structure
n04507155 1300 umbrella
n03633091 1300 ladle
n03982430 1300 pool table, billiard table, snooker table
n01877812 1300 wallaby, brush kangaroo
n04486054 1300 triumphal arch
n02840245 1300 binder, ring-binder
n04065272 1300 recreational vehicle, RV, R.V.
n01843065 1300 jacamar
n03028079 1300 church, church building
n04330267 1300 stove
haoxi911 /
Created May 8, 2018
Script to convert TensorFlow GraphDef to TensorFlow Lite
bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=/home/ubuntu/pps_output/output_graph.pb \
--output_file=/home/ubuntu/pps_output/output_graph.tflite \
--input_arrays=Placeholder \
--output_arrays=final_result \
--inference_type=FLOAT \
--input_shapes=1,224,224,3 \
--input_format=TENSORFLOW_GRAPHDEF \
haoxi911 /
Created Mar 16, 2018
Convert Mobilenet_v1 weights from TensorFlow to CoreML format
import os
import tfcoreml as tf_converter
tf_model_path = os.path.join(os.getcwd(), 'output_graph.pb')
mlmodel_path = os.path.join(os.getcwd(), 'output_graph.mlmodel')
mlmodel = tf_converter.convert(
tf_model_path = tf_model_path,
mlmodel_path = mlmodel_path,
output_feature_names = ['final_result:0'],
input_name_shape_dict = {'input:0':[1,224,224,3]},
haoxi911 /
Last active Mar 15, 2018
Retrain Mobilenet_v1 with Oxford IIIT Pet dataset
# Train
cd ~/tensorflow/
source ./bin/activate
python tensorflow/tensorflow/examples/image_retraining/ \
--image_dir $(pwd)/datasets/oxford-iiit-pet/images/ \
--learning_rate=0.001 \
--testing_percentage=20 \
--validation_percentage=20 \
--train_batch_size=32 \
--validation_batch_size=-1 \
haoxi911 /
Created Mar 15, 2018
Remove invalid images from Oxford IIIT Pet dataset
from PIL import Image
import os
path = os.getcwd()
for folder in os.listdir(path):
if os.path.isdir(os.path.join(path, folder)):
for file in os.listdir(os.path.join(path, folder)):
extension = file.split('.')[-1]
if extension == 'jpg':
fileLoc = os.path.join(path, folder)+'/'+file
img =
haoxi911 /
Created Mar 15, 2018
Split images into subfolders on Oxford IIIT Pet dataset
# /bin/sh
# this script categorize image files by moving them into subfolders
# using the name of animals.
for f in *.jpg; do
name=`echo "$f"|sed 's/ -.*//'`
dir=`echo "${name%_*}"|tr '_' ' '| tr '[A-Z]' '[a-z]'`
mkdir -p "$dir"
mv "$f" "$dir"
You can’t perform that action at this time.