def process_image(self, encoded_image, thread_id=0): return image_processing.process_image( encoded_image, is_training=self.is_training(), height=self.config.image_height, width=self.config.image_width, thread_id=thread_id, image_format=self.config.image_format)
def decode_images(encoded_images): decoded_images = [] for image in encoded_images: decoded_image = image_processing.process_image(image, is_training=True, thread_id=0, height=299, width=299, resize_height=346, resize_width=346, image_format='jpeg') decoded_images.append(decoded_image) return decoded_images
def process_image(self, encoded_image, thread_id=0): """Decodes and processes an image string. Args: encoded_image: A scalar string Tensor; the encoded image. thread_id: Preprocessing thread id used to select the ordering of color distortions. Returns: A float32 Tensor of shape [height, width, 3]; the processed image. """ return image_processing.process_image(encoded_image, is_training=self.is_training(), height=self.config.image_height, width=self.config.image_width, thread_id=thread_id, image_format=self.config.image_format)
def process_image(self, encoded_image, thread_id=0): """Decodes and processes an image string. Args: encoded_image: A scalar string Tensor; the encoded image. thread_id: Preprocessing thread id used to select the ordering of color distortions. Returns: A float32 Tensor of shape [height, width, 3]; the processed image. """ return image_processing.process_image(encoded_image, is_training=self.is_training(), height=self.config.image_height, width=self.config.image_width, thread_id=thread_id, image_format=self.config.image_format)
def build_input(self): #TFRecord로부터 이미지와 캡션 불러오기 input_queue = self.prefetch_tfrecords() images_captions_pairs = [] for thread_id in range(tf.flags.FLAGS.num_preprocess_threads): context, sequence = tf.parse_single_sequence_example( input_queue.dequeue(), context_features={ 'image/data': tf.FixedLenFeature([], dtype=tf.string) }, sequence_features={ 'image/caption_ids': tf.FixedLenSequenceFeature([], dtype=tf.int64), }) encoded_image = context['image/data'] #captions = sequence['image/caption_ids'] captions = sequence.values() # 이미지 디코딩 하기 decoded_image = image_processing.process_image( encoded_image, is_training=True, thread_id=thread_id, height=tf.flags.FLAGS.image_height, width=tf.flags.FLAGS.image_width, resize_height=tf.flags.FLAGS.resize_height, resize_width=tf.flags.FLAGS.resize_width, image_format=tf.flags.FLAGS.image_format) images_captions_pairs.append([decoded_image, captions]) skip_gram_pairs = [] for image, captions in images_captions_pairs: for word in captions: skip_gram_pairs.append((image, word)) #skip_gram_pairs = make_skip_gram_for_image.make_skip_gram_for_image(images_captions_pairs) # 배치 입력 만들기 self.batch_images, self.batch_contexts = make_batch_input.make_batch_input( skip_gram_pairs) self.image_embeddings = make_image_embeddings_cnn.make_image_embeddings_cnn( self.batch_images, self.voc_size)