def __init__(self, checkpoint_dir=os.path.join(os.path.dirname(__file__), '..', LOG_DIR, 'checkpoints'), gpu_id=GPU_ID, profiler: Profiler = None): os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_id) tf.Graph().as_default() self.imagePlaceholder = tf.placeholder(tf.uint8, shape=(None, CROP_SIZE, CROP_SIZE, 3)) self.prevLstmState = tuple([tf.placeholder(tf.float32, shape=(None, LSTM_SIZE)) for _ in range(4)]) self.batch_size = tf.placeholder(tf.int32, shape=()) self.outputs, self.state1, self.state2 = network.inference( self.imagePlaceholder, num_unrolls=1, batch_size=self.batch_size, train=False, prevLstmState=self.prevLstmState) self.sess = tf_util.Session() self.sess.run(tf.global_variables_initializer()) ckpt = tf.train.get_checkpoint_state(checkpoint_dir) if ckpt is None: raise IOError( ('Checkpoint model could not be found. ' 'Did you download the pretrained weights? ' 'Download them here: http://bit.ly/2L5deYF and read the Model section of the Readme.')) tf_util.restore(self.sess, ckpt.model_checkpoint_path) self.tracked_data = {} self.time = 0 self.total_forward_count = -1 self._profiler: Profiler = profiler_pipe(profiler) self._re3_crop_profiler = "re3 cropping image" self._re3_crop2_profiler = "re3 cropping image 2" self._re3_sess_profiler = "re3 session run" self._re3_sess2_profiler = "re3 session run 2"
def __init__(self, gpu_id=GPU_ID): os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_id) basedir = os.path.dirname(__file__) tf.Graph().as_default() self.imagePlaceholder = tf.placeholder(tf.uint8, shape=(None, CROP_SIZE, CROP_SIZE, 3)) self.prevLstmState = tuple([ tf.placeholder(tf.float32, shape=(None, LSTM_SIZE)) for _ in range(4) ]) self.batch_size = tf.placeholder(tf.int32, shape=()) self.outputs, self.state1, self.state2 = network.inference( self.imagePlaceholder, num_unrolls=1, batch_size=self.batch_size, train=False, prevLstmState=self.prevLstmState) config = tf.ConfigProto() config.gpu_options.allow_growth = True self.sess = tf.Session(config=config) ckpt = tf.train.get_checkpoint_state( os.path.join(basedir, '..', LOG_DIR, 'checkpoints')) if ckpt is None: raise IOError(( 'Checkpoint model could not be found. ' 'Did you download the pretrained weights? ' 'Download them here: https://goo.gl/NWGXGM and read the Model section of the Readme.' )) tf_util.restore(self.sess, ckpt.model_checkpoint_path) self.tracked_data = {} self.time = 0 self.total_forward_count = -1
def create_tracker(self): tracker = Re3Tracker(self.sess, tracked_data=self.tracked_data, lock=self.lock, reuse=self.is_initialized) if not self.is_initialized: basedir = os.path.dirname(__file__) ckpt = tf.train.get_checkpoint_state(os.path.join(basedir, '..', LOG_DIR, 'checkpoints')) tf_util.restore(self.sess, ckpt.model_checkpoint_path) self.is_initialized = True return tracker
def create_tracker(self): tracker = Re3Tracker(self.sess, tracked_data=self.tracked_data, lock=self.lock, reuse=self.is_initialized) if not self.is_initialized: ckpt = tf.train.get_checkpoint_state(self.checkpoint_dir) tf_util.restore(self.sess, ckpt.model_checkpoint_path) self.is_initialized = True return tracker
def __init__(self, gpu_id=GPU_ID): os.environ['CUDA_VISIBLE_DEVICES'] = str(gpu_id) if getattr(sys, 'frozen', False): # application_path = os.path.dirname(sys.executable) basedir = os.path.dirname(sys.executable) elif __file__: # application_path = os.path.dirname(__file__) basedir = os.path.dirname(__file__) tf.Graph().as_default() self.imagePlaceholder = tf.placeholder(tf.uint8, shape=(None, CROP_SIZE, CROP_SIZE, 3)) self.prevLstmState = tuple([ tf.placeholder(tf.float32, shape=(None, LSTM_SIZE)) for _ in range(4) ]) self.batch_size = tf.placeholder(tf.int32, shape=()) self.outputs, self.state1, self.state2, self.conv_layers1 = network.inference( self.imagePlaceholder, num_unrolls=1, batch_size=self.batch_size, train=False, prevLstmState=self.prevLstmState) self.conv_layers = network.returnConvLayers( self.imagePlaceholder, num_unrolls=1, batch_size=self.batch_size, train=False, prevLstmState=self.prevLstmState) self.sess = tf_util.Session() self.sess.run(tf.global_variables_initializer()) ckpt = tf.train.get_checkpoint_state( os.path.join(basedir, '..', LOG_DIR, 'checkpoints')) if ckpt is None: raise IOError(( 'Checkpoint model could not be found. ' 'Did you download the pretrained weights? ' 'Download them here: http://bit.ly/2L5deYF and read the Model section of the Readme.' )) tf_util.restore(self.sess, ckpt.model_checkpoint_path) self.tracked_data = {} self.time = 0 self.total_forward_count = -1
config.gpu_options.allow_growth = True sess = tf.Session(config=config) dataset = Dataset(sess, delta, 1, port, debug) forwardNetworkImagePlaceholder = tf.placeholder(tf.uint8, shape=(2, CROP_SIZE, CROP_SIZE, 3)) prevLstmState = tuple( [tf.placeholder(tf.float32, shape=(1, LSTM_SIZE)) for _ in range(4)]) initialLstmState = tuple([np.zeros((1, LSTM_SIZE)) for _ in range(4)]) networkOutputs, state1, state2 = network.inference( forwardNetworkImagePlaceholder, num_unrolls=1, train=False, prevLstmState=prevLstmState, reuse=False) dataset.initialize_tf_placeholders(forwardNetworkImagePlaceholder, prevLstmState, networkOutputs, state1, state2) init = tf.global_variables_initializer() sess.run(init) ckpt = tf.train.get_checkpoint_state(LOG_DIR + '/checkpoints') if ckpt and ckpt.model_checkpoint_path: tf_util.restore(sess, ckpt.model_checkpoint_path) startIter = int(ckpt.model_checkpoint_path.split('-')[-1]) print('Restored', startIter) iteration = 0 while True: iteration += 1 print('iteration', iteration) dataset.get_data_sequence()