Python util.info() Examples
The following are 26
code examples of util.info().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
util
, or try the search function
.
Example #1
Source File: sosac.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 6 votes |
def list(self, url, filter=None): util.info("Examining url " + url) list_result = None if FILTER_URL_PARAM in url: list_result = self.list_movies_by_dubbing(url) elif not filter and DUBBING_URL_PARAM in url: list_result = self.list_dubbing(url) elif J_MOVIES_A_TO_Z_TYPE in url or J_MOVIES_GENRE in url: list_result = self.load_json_list(url) elif J_SERIES in url: list_result = self.list_episodes(url) elif J_TV_SHOWS in url or J_TV_SHOWS_MOST_POPULAR in url: list_result = self.list_series_letter(url) elif J_TV_SHOWS_RECENTLY_ADDED in url: list_result = self.list_recentlyadded_episodes(url) elif J_TV_SHOWS_A_TO_Z_TYPE in url: list_result = self.a_to_z(J_TV_SHOWS) else: order_by = None if J_MOVIES_RECENTLY_ADDED in url: order_by = self.order_recently_by list_result = self.list_videos(url, filter, order_by) return list_result
Example #2
Source File: q_learning_agent.py From reversi_ai with MIT License | 6 votes |
def train(self, state, legal_moves, winner=False): assert self.memory is not None, "can't train without setting memory first" self.train_count += 1 model = self.model if self.prev_state is None: # on first move, no training to do yet self.prev_state = state else: # add new info to replay memory reward = 0 if winner == self.color: reward = WIN_REWARD elif winner == opponent[self.color]: reward = LOSE_REWARD elif winner is not False: raise ValueError self.memory.remember(self.prev_state, self.prev_move, reward, state, legal_moves, winner) # get an experience from memory and train on it if self.train_count % BATCH_SIZE == 0 or winner is not False: states, targets = self.memory.get_replay( model, BATCH_SIZE, ALPHA) model.train_on_batch(states, targets)
Example #3
Source File: q_learning_agent.py From reversi_ai with MIT License | 6 votes |
def get_model(self, filename=None): """Given a filename, load that model file; otherwise, generate a new model.""" model = None if filename: info('attempting to load model {}'.format(filename)) try: model = model_from_json(open(filename).read()) except FileNotFoundError: print('could not load file {}'.format(filename)) quit() print('loaded model file {}'.format(filename)) else: print('no model file loaded, generating new model.') size = self.reversi.size ** 2 model = Sequential() model.add(Dense(HIDDEN_SIZE, activation='relu', input_dim=size)) # model.add(Dense(HIDDEN_SIZE, activation='relu')) model.add(Dense(size)) model.compile(loss='mse', optimizer=optimizer) return model
Example #4
Source File: progress.py From proficiency-metric with Apache License 2.0 | 6 votes |
def tick (self, flow_now = None): now = time.time() if ((self.max_ticks is not None and self.ticks == self.max_ticks) or (self.max_time is not None and now > self.start + self.max_time)): raise Done() self.ticks += 1 if flow_now is not None: self.flow_now = flow_now if ((self.tick_report is not None and self.ticks - self.last_report_ticks >= self.tick_report) or (self.flow_report is not None and self.flow_now is not None and ((self.flow_now - self.last_report_flow).total_seconds() >= self.flow_report)) or (self.time_report is not None and now - self.last_report_time >= self.time_report)): self.logger.info("%s",self.report()) self.last_report_time = now self.last_report_ticks = self.ticks self.last_report_flow = self.flow_now
Example #5
Source File: reader.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1][:-1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.jpg') for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #6
Source File: model.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def build_inference_for_training(self): """Invokes depth and ego-motion networks and computes clouds if needed.""" (self.image_stack, self.intrinsic_mat, self.intrinsic_mat_inv) = ( self.reader.read_data()) with tf.name_scope('egomotion_prediction'): self.egomotion, _ = nets.egomotion_net(self.image_stack, is_training=True, legacy_mode=self.legacy_mode) with tf.variable_scope('depth_prediction'): # Organized by ...[i][scale]. Note that the order is flipped in # variables in build_loss() below. self.disp = {} self.depth = {} if self.icp_weight > 0: self.cloud = {} for i in range(self.seq_length): image = self.image_stack[:, :, :, 3 * i:3 * (i + 1)] multiscale_disps_i, _ = nets.disp_net(image, is_training=True) multiscale_depths_i = [1.0 / d for d in multiscale_disps_i] self.disp[i] = multiscale_disps_i self.depth[i] = multiscale_depths_i if self.icp_weight > 0: multiscale_clouds_i = [ project.get_cloud(d, self.intrinsic_mat_inv[:, s, :, :], name='cloud%d_%d' % (s, i)) for (s, d) in enumerate(multiscale_depths_i) ] self.cloud[i] = multiscale_clouds_i # Reuse the same depth graph for all images. tf.get_variable_scope().reuse_variables() logging.info('disp: %s', util.info(self.disp))
Example #7
Source File: reader.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() frames = [k.rstrip() for k in frames] subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.' + self.file_extension) for i in range(len(frames)) ] segment_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '-fseg.' + self.file_extension) for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['segment_file_list'] = segment_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #8
Source File: reader.py From models with Apache License 2.0 | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1][:-1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.jpg') for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #9
Source File: model.py From models with Apache License 2.0 | 5 votes |
def build_inference_for_training(self): """Invokes depth and ego-motion networks and computes clouds if needed.""" (self.image_stack, self.intrinsic_mat, self.intrinsic_mat_inv) = ( self.reader.read_data()) with tf.name_scope('egomotion_prediction'): self.egomotion, _ = nets.egomotion_net(self.image_stack, is_training=True, legacy_mode=self.legacy_mode) with tf.variable_scope('depth_prediction'): # Organized by ...[i][scale]. Note that the order is flipped in # variables in build_loss() below. self.disp = {} self.depth = {} if self.icp_weight > 0: self.cloud = {} for i in range(self.seq_length): image = self.image_stack[:, :, :, 3 * i:3 * (i + 1)] multiscale_disps_i, _ = nets.disp_net(image, is_training=True) multiscale_depths_i = [1.0 / d for d in multiscale_disps_i] self.disp[i] = multiscale_disps_i self.depth[i] = multiscale_depths_i if self.icp_weight > 0: multiscale_clouds_i = [ project.get_cloud(d, self.intrinsic_mat_inv[:, s, :, :], name='cloud%d_%d' % (s, i)) for (s, d) in enumerate(multiscale_depths_i) ] self.cloud[i] = multiscale_clouds_i # Reuse the same depth graph for all images. tf.get_variable_scope().reuse_variables() logging.info('disp: %s', util.info(self.disp))
Example #10
Source File: reader.py From models with Apache License 2.0 | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() frames = [k.rstrip() for k in frames] subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.' + self.file_extension) for i in range(len(frames)) ] segment_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '-fseg.' + self.file_extension) for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['segment_file_list'] = segment_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #11
Source File: reader.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1][:-1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.jpg') for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #12
Source File: model.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def build_inference_for_training(self): """Invokes depth and ego-motion networks and computes clouds if needed.""" (self.image_stack, self.intrinsic_mat, self.intrinsic_mat_inv) = ( self.reader.read_data()) with tf.name_scope('egomotion_prediction'): self.egomotion, _ = nets.egomotion_net(self.image_stack, is_training=True, legacy_mode=self.legacy_mode) with tf.variable_scope('depth_prediction'): # Organized by ...[i][scale]. Note that the order is flipped in # variables in build_loss() below. self.disp = {} self.depth = {} if self.icp_weight > 0: self.cloud = {} for i in range(self.seq_length): image = self.image_stack[:, :, :, 3 * i:3 * (i + 1)] multiscale_disps_i, _ = nets.disp_net(image, is_training=True) multiscale_depths_i = [1.0 / d for d in multiscale_disps_i] self.disp[i] = multiscale_disps_i self.depth[i] = multiscale_depths_i if self.icp_weight > 0: multiscale_clouds_i = [ project.get_cloud(d, self.intrinsic_mat_inv[:, s, :, :], name='cloud%d_%d' % (s, i)) for (s, d) in enumerate(multiscale_depths_i) ] self.cloud[i] = multiscale_clouds_i # Reuse the same depth graph for all images. tf.get_variable_scope().reuse_variables() logging.info('disp: %s', util.info(self.disp))
Example #13
Source File: reader.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def compile_file_list(self, data_dir, split, load_pose=False): """Creates a list of input files.""" logging.info('data_dir: %s', data_dir) with gfile.Open(os.path.join(data_dir, '%s.txt' % split), 'r') as f: frames = f.readlines() frames = [k.rstrip() for k in frames] subfolders = [x.split(' ')[0] for x in frames] frame_ids = [x.split(' ')[1] for x in frames] image_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '.' + self.file_extension) for i in range(len(frames)) ] segment_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '-fseg.' + self.file_extension) for i in range(len(frames)) ] cam_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_cam.txt') for i in range(len(frames)) ] file_lists = {} file_lists['image_file_list'] = image_file_list file_lists['segment_file_list'] = segment_file_list file_lists['cam_file_list'] = cam_file_list if load_pose: pose_file_list = [ os.path.join(data_dir, subfolders[i], frame_ids[i] + '_pose.txt') for i in range(len(frames)) ] file_lists['pose_file_list'] = pose_file_list self.steps_per_epoch = len(image_file_list) // self.batch_size return file_lists
Example #14
Source File: progress.py From proficiency-metric with Apache License 2.0 | 5 votes |
def timing (func, logger = None): start = time.time() ret = func() util.info("Ran %s in %s" % (func, elapsed(start)),logger=logger) return ret
Example #15
Source File: q_learning_agent.py From reversi_ai with MIT License | 5 votes |
def policy(self, state, legal_moves): """The policy of picking an action based on their weights.""" if not legal_moves: return None if not self.minimax_enabled: # don't use minimax if we're in learning mode best_move, _ = best_move_val( self.model.predict(numpify(state)), legal_moves ) return best_move else: next_states = {self.reversi.next_state( state, move): move for move in legal_moves} move_scores = [] for s in next_states.keys(): score = self.minimax(s) move_scores.append((score, s)) info('{}: {}'.format(next_states[s], score)) best_val = -float('inf') best_move = None for each in move_scores: if each[0] > best_val: best_val = each[0] best_move = next_states[each[1]] assert best_move is not None return best_move
Example #16
Source File: q_learning_agent.py From reversi_ai with MIT License | 5 votes |
def set_epsilon(self, val): self.epsilon = val if not self.learning_enabled: info('Warning -- set_epsilon() was called when learning was not enabled.')
Example #17
Source File: sutils.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 5 votes |
def evalSchedules(self): if not self.scanRunning() and not self.isPlaying(): notified = False util.info("SOSAC Loading subscriptions") subs = self.get_subs() new_items = False for url, sub in subs.iteritems(): if xbmc.abortRequested: util.info("SOSAC Exiting") return if sub['type'] == sosac.LIBRARY_TYPE_TVSHOW: if self.scanRunning() or self.isPlaying(): self.cache.delete("subscription.last_run") return refresh = int(sub['refresh']) if refresh > 0: next_check = sub['last_run'] + (refresh * 3600 * 24) if next_check < time.time(): if not notified: self.showNotification( 'Subscription', 'Chcecking') notified = True util.debug("SOSAC Refreshing " + url) new_items |= self.run_custom({ 'action': sosac.LIBRARY_ACTION_ADD, 'type': sosac.LIBRARY_TYPE_TVSHOW, 'update': True, 'url': url, 'name': sub['name'], 'refresh': sub['refresh'] }) self.sleep(3000) else: n = (next_check - time.time()) / 3600 util.debug("SOSAC Skipping " + url + " , next check in %dh" % n) if new_items: xbmc.executebuiltin('UpdateLibrary(video)') notified = False else: util.info("SOSAC Scan skipped")
Example #18
Source File: sutils.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 5 votes |
def service(self): util.info("SOSAC Service Started") try: sleep_time = int(self.getSetting("start_sleep_time")) * 1000 * 60 * 60 except: sleep_time = self.sleep_time pass self.sleep(sleep_time) try: self.last_run = float(self.cache.get("subscription.last_run")) except: self.last_run = time.time() self.cache.set("subscription.last_run", str(self.last_run)) pass if not xbmc.abortRequested and time.time() > self.last_run: self.evalSchedules() while not xbmc.abortRequested: # evaluate subsciptions every 10 minutes if(time.time() > self.last_run + 600): self.evalSchedules() self.last_run = time.time() self.cache.set("subscription.last_run", str(self.last_run)) self.sleep(self.sleep_time) util.info("SOSAC Shutdown")
Example #19
Source File: sosac.py From plugin.video.sosac.ph with GNU General Public License v2.0 | 5 votes |
def request_last_update(self, url): util.debug('request: %s' % url) lastmod = None req = urllib2.Request(url) req.add_header('User-Agent', util.UA) try: response = urllib2.urlopen(req) lastmod = datetime.datetime(*response.info().getdate('Last-Modified')[:6]).strftime( '%d.%m.%Y') response.close() except urllib2.HTTPError, error: util.debug(error.read()) error.close()
Example #20
Source File: model.py From g-tensorflow-models with Apache License 2.0 | 4 votes |
def __init__(self, data_dir=None, is_training=True, learning_rate=0.0002, beta1=0.9, reconstr_weight=0.85, smooth_weight=0.05, ssim_weight=0.15, icp_weight=0.0, batch_size=4, img_height=128, img_width=416, seq_length=3, legacy_mode=False): self.data_dir = data_dir self.is_training = is_training self.learning_rate = learning_rate self.reconstr_weight = reconstr_weight self.smooth_weight = smooth_weight self.ssim_weight = ssim_weight self.icp_weight = icp_weight self.beta1 = beta1 self.batch_size = batch_size self.img_height = img_height self.img_width = img_width self.seq_length = seq_length self.legacy_mode = legacy_mode logging.info('data_dir: %s', data_dir) logging.info('learning_rate: %s', learning_rate) logging.info('beta1: %s', beta1) logging.info('smooth_weight: %s', smooth_weight) logging.info('ssim_weight: %s', ssim_weight) logging.info('icp_weight: %s', icp_weight) logging.info('batch_size: %s', batch_size) logging.info('img_height: %s', img_height) logging.info('img_width: %s', img_width) logging.info('seq_length: %s', seq_length) logging.info('legacy_mode: %s', legacy_mode) if self.is_training: self.reader = reader.DataReader(self.data_dir, self.batch_size, self.img_height, self.img_width, self.seq_length, NUM_SCALES) self.build_train_graph() else: self.build_depth_test_graph() self.build_egomotion_test_graph() # At this point, the model is ready. Print some info on model params. util.count_parameters()
Example #21
Source File: reader.py From g-tensorflow-models with Apache License 2.0 | 4 votes |
def read_data(self): """Provides images and camera intrinsics.""" with tf.name_scope('data_loading'): with tf.name_scope('enqueue_paths'): seed = random.randint(0, 2**31 - 1) self.file_lists = self.compile_file_list(self.data_dir, 'train') image_paths_queue = tf.train.string_input_producer( self.file_lists['image_file_list'], seed=seed, shuffle=True) cam_paths_queue = tf.train.string_input_producer( self.file_lists['cam_file_list'], seed=seed, shuffle=True) img_reader = tf.WholeFileReader() _, image_contents = img_reader.read(image_paths_queue) image_seq = tf.image.decode_jpeg(image_contents) with tf.name_scope('load_intrinsics'): cam_reader = tf.TextLineReader() _, raw_cam_contents = cam_reader.read(cam_paths_queue) rec_def = [] for _ in range(9): rec_def.append([1.0]) raw_cam_vec = tf.decode_csv(raw_cam_contents, record_defaults=rec_def) raw_cam_vec = tf.stack(raw_cam_vec) intrinsics = tf.reshape(raw_cam_vec, [3, 3]) with tf.name_scope('convert_image'): image_seq = self.preprocess_image(image_seq) # Converts to float. with tf.name_scope('image_augmentation'): image_seq = self.augment_image_colorspace(image_seq) image_stack = self.unpack_images(image_seq) with tf.name_scope('image_augmentation_scale_crop'): image_stack, intrinsics = self.augment_images_scale_crop( image_stack, intrinsics, self.img_height, self.img_width) with tf.name_scope('multi_scale_intrinsics'): intrinsic_mat = self.get_multi_scale_intrinsics(intrinsics, self.num_scales) intrinsic_mat.set_shape([self.num_scales, 3, 3]) intrinsic_mat_inv = tf.matrix_inverse(intrinsic_mat) intrinsic_mat_inv.set_shape([self.num_scales, 3, 3]) with tf.name_scope('batching'): image_stack, intrinsic_mat, intrinsic_mat_inv = ( tf.train.shuffle_batch( [image_stack, intrinsic_mat, intrinsic_mat_inv], batch_size=self.batch_size, capacity=QUEUE_SIZE + QUEUE_BUFFER * self.batch_size, min_after_dequeue=QUEUE_SIZE)) logging.info('image_stack: %s', util.info(image_stack)) return image_stack, intrinsic_mat, intrinsic_mat_inv
Example #22
Source File: model.py From models with Apache License 2.0 | 4 votes |
def __init__(self, data_dir=None, is_training=True, learning_rate=0.0002, beta1=0.9, reconstr_weight=0.85, smooth_weight=0.05, ssim_weight=0.15, icp_weight=0.0, batch_size=4, img_height=128, img_width=416, seq_length=3, legacy_mode=False): self.data_dir = data_dir self.is_training = is_training self.learning_rate = learning_rate self.reconstr_weight = reconstr_weight self.smooth_weight = smooth_weight self.ssim_weight = ssim_weight self.icp_weight = icp_weight self.beta1 = beta1 self.batch_size = batch_size self.img_height = img_height self.img_width = img_width self.seq_length = seq_length self.legacy_mode = legacy_mode logging.info('data_dir: %s', data_dir) logging.info('learning_rate: %s', learning_rate) logging.info('beta1: %s', beta1) logging.info('smooth_weight: %s', smooth_weight) logging.info('ssim_weight: %s', ssim_weight) logging.info('icp_weight: %s', icp_weight) logging.info('batch_size: %s', batch_size) logging.info('img_height: %s', img_height) logging.info('img_width: %s', img_width) logging.info('seq_length: %s', seq_length) logging.info('legacy_mode: %s', legacy_mode) if self.is_training: self.reader = reader.DataReader(self.data_dir, self.batch_size, self.img_height, self.img_width, self.seq_length, NUM_SCALES) self.build_train_graph() else: self.build_depth_test_graph() self.build_egomotion_test_graph() # At this point, the model is ready. Print some info on model params. util.count_parameters()
Example #23
Source File: reader.py From models with Apache License 2.0 | 4 votes |
def read_data(self): """Provides images and camera intrinsics.""" with tf.name_scope('data_loading'): with tf.name_scope('enqueue_paths'): seed = random.randint(0, 2**31 - 1) self.file_lists = self.compile_file_list(self.data_dir, 'train') image_paths_queue = tf.train.string_input_producer( self.file_lists['image_file_list'], seed=seed, shuffle=True) cam_paths_queue = tf.train.string_input_producer( self.file_lists['cam_file_list'], seed=seed, shuffle=True) img_reader = tf.WholeFileReader() _, image_contents = img_reader.read(image_paths_queue) image_seq = tf.image.decode_jpeg(image_contents) with tf.name_scope('load_intrinsics'): cam_reader = tf.TextLineReader() _, raw_cam_contents = cam_reader.read(cam_paths_queue) rec_def = [] for _ in range(9): rec_def.append([1.0]) raw_cam_vec = tf.decode_csv(raw_cam_contents, record_defaults=rec_def) raw_cam_vec = tf.stack(raw_cam_vec) intrinsics = tf.reshape(raw_cam_vec, [3, 3]) with tf.name_scope('convert_image'): image_seq = self.preprocess_image(image_seq) # Converts to float. with tf.name_scope('image_augmentation'): image_seq = self.augment_image_colorspace(image_seq) image_stack = self.unpack_images(image_seq) with tf.name_scope('image_augmentation_scale_crop'): image_stack, intrinsics = self.augment_images_scale_crop( image_stack, intrinsics, self.img_height, self.img_width) with tf.name_scope('multi_scale_intrinsics'): intrinsic_mat = self.get_multi_scale_intrinsics(intrinsics, self.num_scales) intrinsic_mat.set_shape([self.num_scales, 3, 3]) intrinsic_mat_inv = tf.matrix_inverse(intrinsic_mat) intrinsic_mat_inv.set_shape([self.num_scales, 3, 3]) with tf.name_scope('batching'): image_stack, intrinsic_mat, intrinsic_mat_inv = ( tf.train.shuffle_batch( [image_stack, intrinsic_mat, intrinsic_mat_inv], batch_size=self.batch_size, capacity=QUEUE_SIZE + QUEUE_BUFFER * self.batch_size, min_after_dequeue=QUEUE_SIZE)) logging.info('image_stack: %s', util.info(image_stack)) return image_stack, intrinsic_mat, intrinsic_mat_inv
Example #24
Source File: model.py From multilabel-image-classification-tensorflow with MIT License | 4 votes |
def __init__(self, data_dir=None, is_training=True, learning_rate=0.0002, beta1=0.9, reconstr_weight=0.85, smooth_weight=0.05, ssim_weight=0.15, icp_weight=0.0, batch_size=4, img_height=128, img_width=416, seq_length=3, legacy_mode=False): self.data_dir = data_dir self.is_training = is_training self.learning_rate = learning_rate self.reconstr_weight = reconstr_weight self.smooth_weight = smooth_weight self.ssim_weight = ssim_weight self.icp_weight = icp_weight self.beta1 = beta1 self.batch_size = batch_size self.img_height = img_height self.img_width = img_width self.seq_length = seq_length self.legacy_mode = legacy_mode logging.info('data_dir: %s', data_dir) logging.info('learning_rate: %s', learning_rate) logging.info('beta1: %s', beta1) logging.info('smooth_weight: %s', smooth_weight) logging.info('ssim_weight: %s', ssim_weight) logging.info('icp_weight: %s', icp_weight) logging.info('batch_size: %s', batch_size) logging.info('img_height: %s', img_height) logging.info('img_width: %s', img_width) logging.info('seq_length: %s', seq_length) logging.info('legacy_mode: %s', legacy_mode) if self.is_training: self.reader = reader.DataReader(self.data_dir, self.batch_size, self.img_height, self.img_width, self.seq_length, NUM_SCALES) self.build_train_graph() else: self.build_depth_test_graph() self.build_egomotion_test_graph() # At this point, the model is ready. Print some info on model params. util.count_parameters()
Example #25
Source File: reader.py From multilabel-image-classification-tensorflow with MIT License | 4 votes |
def read_data(self): """Provides images and camera intrinsics.""" with tf.name_scope('data_loading'): with tf.name_scope('enqueue_paths'): seed = random.randint(0, 2**31 - 1) self.file_lists = self.compile_file_list(self.data_dir, 'train') image_paths_queue = tf.train.string_input_producer( self.file_lists['image_file_list'], seed=seed, shuffle=True) cam_paths_queue = tf.train.string_input_producer( self.file_lists['cam_file_list'], seed=seed, shuffle=True) img_reader = tf.WholeFileReader() _, image_contents = img_reader.read(image_paths_queue) image_seq = tf.image.decode_jpeg(image_contents) with tf.name_scope('load_intrinsics'): cam_reader = tf.TextLineReader() _, raw_cam_contents = cam_reader.read(cam_paths_queue) rec_def = [] for _ in range(9): rec_def.append([1.0]) raw_cam_vec = tf.decode_csv(raw_cam_contents, record_defaults=rec_def) raw_cam_vec = tf.stack(raw_cam_vec) intrinsics = tf.reshape(raw_cam_vec, [3, 3]) with tf.name_scope('convert_image'): image_seq = self.preprocess_image(image_seq) # Converts to float. with tf.name_scope('image_augmentation'): image_seq = self.augment_image_colorspace(image_seq) image_stack = self.unpack_images(image_seq) with tf.name_scope('image_augmentation_scale_crop'): image_stack, intrinsics = self.augment_images_scale_crop( image_stack, intrinsics, self.img_height, self.img_width) with tf.name_scope('multi_scale_intrinsics'): intrinsic_mat = self.get_multi_scale_intrinsics(intrinsics, self.num_scales) intrinsic_mat.set_shape([self.num_scales, 3, 3]) intrinsic_mat_inv = tf.matrix_inverse(intrinsic_mat) intrinsic_mat_inv.set_shape([self.num_scales, 3, 3]) with tf.name_scope('batching'): image_stack, intrinsic_mat, intrinsic_mat_inv = ( tf.train.shuffle_batch( [image_stack, intrinsic_mat, intrinsic_mat_inv], batch_size=self.batch_size, capacity=QUEUE_SIZE + QUEUE_BUFFER * self.batch_size, min_after_dequeue=QUEUE_SIZE)) logging.info('image_stack: %s', util.info(image_stack)) return image_stack, intrinsic_mat, intrinsic_mat_inv
Example #26
Source File: install.py From instavpn with Apache License 2.0 | 4 votes |
def main(): logger.info("Checking your OS version...") if util.check_os(): logger.info("OK") else: logger.critical("You must use Ubuntu 14.04") if util.not_sudo(): logger.critical("Restart script as root") logger.info("Installing packages...") if util.install_packages(): logger.info("OK") else: logger.critical("Failed to install packages") logger.info("Applying sysctl parameters...") if util.setup_sysctl(): logger.info("OK") else: logger.critical("Failed to apply sysctl parameters") logger.info("Creating random passwords...") if util.setup_passwords(): logger.info("OK") else: logger.critical("Failed to create random passwords") logger.info("Other config files...") if util.cp_configs(): logger.info("OK") else: logger.critical("Fail") logger.info("Adding script to rc.local...") if util.setup_vpn(): logger.info("OK") else: logger.critical("Failed adding script to rc.local") logger.info("Installing web UI...") if util.webui(): logger.info("OK") else: logger.critical("Failed installing web UI") util.info()