def UpdateModels(self): loader = model_loader.ModelLoader(DEVICE_MODEL_DATA) added, updated = loader.Update() if added or updated: memcache.delete(memcache_keys.INDEX_INFO) memcache.delete(memcache_keys.PRODUCT_COUNT_KEY) memcache.delete(memcache_keys.MANUFACTURER_MODEL_COUNTS) memcache.delete(memcache_keys.CATEGORY_MODEL_COUNTS) memcache.delete(memcache_keys.TAG_MODEL_COUNTS) UpdateModificationTime(timestamp_keys.DEVICES) return ('Models:\nAdded: %s\nUpdated: %s' % (', '.join(added), ', '.join(updated)))
import sys import tensorflow as tf from os import getcwd MODULE_DIR = getcwd() + '/tfmodules' sys.path.insert(0, MODULE_DIR) import path_manager import model_loader as ld import trainer as tr import train_config as tr_config sys.path.insert(0, path_manager.EXPORT_DIR) model_export_dir = '/runtrain-20180613-yglee' import_meta_filename = model_export_dir + '/net.ckpt.meta' export_pb_filename = 'net.pb' model_loader = ld.ModelLoader(subdir_and_filename=import_meta_filename) model_graph_def = model_loader.load_model(clear_devices=True) # converting to pb / pbdef files train_config = tr_config.TrainConfig() trainer = tr.Trainer(model_graph=model_graph_def, config=train_config) trainer.export_graphdef_as_pb(subdir=model_export_dir, filename=export_pb_filename)
stepvalues = [3000, 5000] base_lr = 0.000002 rate_decay = 0.1 snapshot = 1000 display = 20 save_summary = 10 dataset_root = '/home/yfji/benchmark/Keypoint/fashionAI_key_points_train_20180227/train/' with tf.device('/gpu:2'): g = tf.Graph() with g.as_default(): loader = loader.DataLoader(csv_path=op.join(dataset_root, 'Annotations/train.csv'), dataset_root=dataset_root) model_loader = ml.ModelLoader(load_mode='ckpt', model_path='./models/fashion.ckpt-25000') datashape, labelshape = loader.get_shape() tensor_in = tf.placeholder(shape=datashape, dtype=tf.float32) label = tf.placeholder(shape=labelshape, dtype=tf.float32) tensor_out = network.make_cpm(tensor_in) diff2_stage1 = tf.square(tf.subtract(tensor_out[0], label)) diff2_stage2 = tf.square(tf.subtract(tensor_out[1], label)) # with tf.name_scope('loss1'): loss_stage1 = 0.5 * tf.reduce_mean( tf.reduce_sum(tf.reduce_sum(tf.reduce_sum(diff2_stage1, axis=1), axis=1),
dataset_root = '/home/yfji/Workspace/Python/FashionAI/test_new/test/' iteration = 20000 with tf.Graph().as_default(): tensor_in = tf.placeholder(shape=[1, input_size, input_size, 3], dtype=tf.float32) tensor_out = network.make_cpm(tensor_in) config = tf.ConfigProto() config.gpu_options.allow_growth = True with tf.Session(config=config) as sess: model_loader = ml.ModelLoader(load_mode='ckpt', model_path='models/fashion.ckpt-%d' % iteration) model_loader.load_model(session=sess) with open( '/home/yfji/benchmark/Keypoint/fashionAI_key_points_train_20180227/train/Annotations/train.csv', 'r') as tf: reader = csv.reader(tf) header = None for row in reader: header = list(row) break print(header) csv_name = 'pred_iter_%d_0.85.csv' % iteration rows = [] with open(op.join(dataset_root, 'test.csv'), 'r') as f: