Python tensorflow.string() Examples
The following are 30
code examples of tensorflow.string().
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
tensorflow
, or try the search function
.
Example #1
Source File: dataset.py From DNA-GAN with MIT License | 7 votes |
def parse_fn(self, serialized_example): features={ 'image/id_name': tf.FixedLenFeature([], tf.string), 'image/height' : tf.FixedLenFeature([], tf.int64), 'image/width' : tf.FixedLenFeature([], tf.int64), 'image/encoded': tf.FixedLenFeature([], tf.string), } for name in self.feature_list: features[name] = tf.FixedLenFeature([], tf.int64) example = tf.parse_single_example(serialized_example, features=features) image = tf.decode_raw(example['image/encoded'], tf.uint8) raw_height = tf.cast(example['image/height'], tf.int32) raw_width = tf.cast(example['image/width'], tf.int32) image = tf.reshape(image, [raw_height, raw_width, 3]) image = tf.image.resize_images(image, size=[self.height, self.width]) # from IPython import embed; embed(); exit() feature_val_list = [tf.cast(example[name], tf.float32) for name in self.feature_list] return image, feature_val_list
Example #2
Source File: exporter.py From vehicle_counting_tensorflow with MIT License | 6 votes |
def _tf_example_input_placeholder(): """Returns input that accepts a batch of strings with tf examples. Returns: a tuple of input placeholder and the output decoded images. """ batch_tf_example_placeholder = tf.placeholder( tf.string, shape=[None], name='tf_example') def decode(tf_example_string_tensor): tensor_dict = tf_example_decoder.TfExampleDecoder().decode( tf_example_string_tensor) image_tensor = tensor_dict[fields.InputDataFields.image] return image_tensor return (batch_tf_example_placeholder, shape_utils.static_or_dynamic_map_fn( decode, elems=batch_tf_example_placeholder, dtype=tf.uint8, parallel_iterations=32, back_prop=False))
Example #3
Source File: dump_tfrecord.py From cwavegan with MIT License | 6 votes |
def _mapper(example_proto): features = { 'samples': tf.FixedLenSequenceFeature([1], tf.float32, allow_missing=True), 'label': tf.FixedLenSequenceFeature([], tf.string, allow_missing=True) } example = tf.parse_single_example(example_proto, features) wav = example['samples'][:, 0] wav = wav[:16384] wav_len = tf.shape(wav)[0] wav = tf.pad(wav, [[0, 16384 - wav_len]]) label = tf.reduce_join(example['label'], 0) return wav, label
Example #4
Source File: video_utils.py From fine-lm with MIT License | 6 votes |
def example_reading_spec(self): extra_data_fields, extra_data_items_to_decoders = self.extra_reading_spec data_fields = { "image/encoded": tf.FixedLenFeature((), tf.string), "image/format": tf.FixedLenFeature((), tf.string), } data_fields.update(extra_data_fields) data_items_to_decoders = { "frame": tf.contrib.slim.tfexample_decoder.Image( image_key="image/encoded", format_key="image/format", shape=[self.frame_height, self.frame_width, self.num_channels], channels=self.num_channels), } data_items_to_decoders.update(extra_data_items_to_decoders) return data_fields, data_items_to_decoders
Example #5
Source File: build_imagenet_data.py From DOTA_models with Apache License 2.0 | 6 votes |
def __init__(self): # Create a single Session to run all image coding calls. self._sess = tf.Session() # Initializes function that converts PNG to JPEG data. self._png_data = tf.placeholder(dtype=tf.string) image = tf.image.decode_png(self._png_data, channels=3) self._png_to_jpeg = tf.image.encode_jpeg(image, format='rgb', quality=100) # Initializes function that converts CMYK JPEG data to RGB JPEG data. self._cmyk_data = tf.placeholder(dtype=tf.string) image = tf.image.decode_jpeg(self._cmyk_data, channels=0) self._cmyk_to_rgb = tf.image.encode_jpeg(image, format='rgb', quality=100) # Initializes function that decodes RGB JPEG data. self._decode_jpeg_data = tf.placeholder(dtype=tf.string) self._decode_jpeg = tf.image.decode_jpeg(self._decode_jpeg_data, channels=3)
Example #6
Source File: vgsl_input.py From DOTA_models with Apache License 2.0 | 6 votes |
def _ImageProcessing(image_buffer, shape): """Convert a PNG string into an input tensor. We allow for fixed and variable sizes. Does fixed conversion to floats in the range [-1.28, 1.27]. Args: image_buffer: Tensor containing a PNG encoded image. shape: ImageShape with the desired shape of the input. Returns: image: Decoded, normalized image in the range [-1.28, 1.27]. """ image = tf.image.decode_png(image_buffer, channels=shape.depth) image.set_shape([shape.height, shape.width, shape.depth]) image = tf.cast(image, tf.float32) image = tf.subtract(image, 128.0) image = tf.multiply(image, 1 / 100.0) return image
Example #7
Source File: image_processing.py From DOTA_models with Apache License 2.0 | 6 votes |
def decode_jpeg(image_buffer, scope=None): """Decode a JPEG string into one 3-D float image Tensor. Args: image_buffer: scalar string Tensor. scope: Optional scope for name_scope. Returns: 3-D float Tensor with values ranging from [0, 1). """ with tf.name_scope(values=[image_buffer], name=scope, default_name='decode_jpeg'): # Decode the string as an RGB JPEG. # Note that the resulting image contains an unknown height and width # that is set dynamically by decode_jpeg. In other words, the height # and width of image is unknown at compile-time. image = tf.image.decode_jpeg(image_buffer, channels=3) # After this point, all image pixels reside in [0,1) # until the very end, when they're rescaled to (-1, 1). The various # adjust_* ops all require this range for dtype float. image = tf.image.convert_image_dtype(image, dtype=tf.float32) return image
Example #8
Source File: vfn_train.py From view-finding-network with GNU General Public License v3.0 | 6 votes |
def read_and_decode_aug(filename_queue): reader = tf.TFRecordReader() _, serialized_example = reader.read(filename_queue) features = tf.parse_single_example( serialized_example, # Defaults are not specified since both keys are required. features={ 'image_raw': tf.FixedLenFeature([], tf.string), }) image = tf.decode_raw(features['image_raw'], tf.uint8) image = tf.image.random_flip_left_right(tf.reshape(image, [227, 227, 6])) # Convert from [0, 255] -> [-0.5, 0.5] floats. image = tf.cast(image, tf.float32) * (1. / 255) - 0.5 image = tf.image.random_brightness(image, 0.01) image = tf.image.random_contrast(image, 0.95, 1.05) return tf.split(image, 2, 2) # 3rd dimension two parts
Example #9
Source File: build_imagenet_data.py From DOTA_models with Apache License 2.0 | 6 votes |
def _process_dataset(name, directory, num_shards, synset_to_human, image_to_bboxes): """Process a complete data set and save it as a TFRecord. Args: name: string, unique identifier specifying the data set. directory: string, root path to the data set. num_shards: integer number of shards for this data set. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' image_to_bboxes: dictionary mapping image file names to a list of bounding boxes. This list contains 0+ bounding boxes. """ filenames, synsets, labels = _find_image_files(directory, FLAGS.labels_file) humans = _find_human_readable_labels(synsets, synset_to_human) bboxes = _find_image_bounding_boxes(filenames, image_to_bboxes) _process_image_files(name, filenames, synsets, labels, humans, bboxes, num_shards)
Example #10
Source File: build_imagenet_data.py From DOTA_models with Apache License 2.0 | 6 votes |
def _find_image_bounding_boxes(filenames, image_to_bboxes): """Find the bounding boxes for a given image file. Args: filenames: list of strings; each string is a path to an image file. image_to_bboxes: dictionary mapping image file names to a list of bounding boxes. This list contains 0+ bounding boxes. Returns: List of bounding boxes for each image. Note that each entry in this list might contain from 0+ entries corresponding to the number of bounding box annotations for the image. """ num_image_bbox = 0 bboxes = [] for f in filenames: basename = os.path.basename(f) if basename in image_to_bboxes: bboxes.append(image_to_bboxes[basename]) num_image_bbox += 1 else: bboxes.append([]) print('Found %d images with bboxes out of %d images' % ( num_image_bbox, len(filenames))) return bboxes
Example #11
Source File: build_imagenet_data.py From DOTA_models with Apache License 2.0 | 6 votes |
def _find_human_readable_labels(synsets, synset_to_human): """Build a list of human-readable labels. Args: synsets: list of strings; each string is a unique WordNet ID. synset_to_human: dict of synset to human labels, e.g., 'n02119022' --> 'red fox, Vulpes vulpes' Returns: List of human-readable strings corresponding to each synset. """ humans = [] for s in synsets: assert s in synset_to_human, ('Failed to find: %s' % s) humans.append(synset_to_human[s]) return humans
Example #12
Source File: vfn_train.py From view-finding-network with GNU General Public License v3.0 | 6 votes |
def read_and_decode(filename_queue): reader = tf.TFRecordReader() _, serialized_example = reader.read(filename_queue) features = tf.parse_single_example( serialized_example, # Defaults are not specified since both keys are required. features={ 'image_raw': tf.FixedLenFeature([], tf.string), }) image = tf.decode_raw(features['image_raw'], tf.uint8) image = tf.reshape(image, [227, 227, 6]) # Convert from [0, 255] -> [-0.5, 0.5] floats. image = tf.cast(image, tf.float32) * (1. / 255) - 0.5 return tf.split(image, 2, 2) # 3rd dimension two parts
Example #13
Source File: problem.py From fine-lm with MIT License | 6 votes |
def serving_input_fn(self, hparams): """Input fn for serving export, starting from serialized example.""" mode = tf.estimator.ModeKeys.PREDICT serialized_example = tf.placeholder( dtype=tf.string, shape=[None], name="serialized_example") dataset = tf.data.Dataset.from_tensor_slices(serialized_example) dataset = dataset.map(self.decode_example) dataset = dataset.map(lambda ex: self.preprocess_example(ex, mode, hparams)) dataset = dataset.map(self.maybe_reverse_and_copy) dataset = dataset.map(data_reader.cast_ints_to_int32) dataset = dataset.padded_batch( tf.shape(serialized_example, out_type=tf.int64)[0], dataset.output_shapes) dataset = dataset.map(standardize_shapes) features = tf.contrib.data.get_single_element(dataset) if self.has_inputs: features.pop("targets", None) return tf.estimator.export.ServingInputReceiver( features=features, receiver_tensors=serialized_example)
Example #14
Source File: audio_records.py From Tensorflow-Audio-Classification with Apache License 2.0 | 5 votes |
def parse_example(example, shape=None): """Parse TF Example""" keys_to_feature = { AUDIO_FEATURE_NAME: tf.FixedLenFeature([], tf.string), AUDIO_LABEL_NAME: tf.FixedLenFeature([], tf.int64)} raw_parsed_example = tf.parse_single_example(example, features=keys_to_feature) feature = tf.decode_raw(raw_parsed_example[AUDIO_FEATURE_NAME], tf.float64) label = tf.cast(raw_parsed_example[AUDIO_LABEL_NAME], tf.int32) feature = tf.cast(feature, tf.float32) if shape is not None: feature = tf.reshape(feature, shape) return feature, label
Example #15
Source File: exporter.py From object_detector_app with MIT License | 5 votes |
def _tf_example_input_placeholder(): tf_example_placeholder = tf.placeholder( tf.string, shape=[], name='tf_example') tensor_dict = tf_example_decoder.TfExampleDecoder().Decode( tf_example_placeholder) image = tensor_dict[fields.InputDataFields.image] return tf.expand_dims(image, axis=0)
Example #16
Source File: input_reader_builder.py From object_detector_app with MIT License | 5 votes |
def build(input_reader_config): """Builds a tensor dictionary based on the InputReader config. Args: input_reader_config: A input_reader_pb2.InputReader object. Returns: A tensor dict based on the input_reader_config. Raises: ValueError: On invalid input reader proto. """ if not isinstance(input_reader_config, input_reader_pb2.InputReader): raise ValueError('input_reader_config not of type ' 'input_reader_pb2.InputReader.') if input_reader_config.WhichOneof('input_reader') == 'tf_record_input_reader': config = input_reader_config.tf_record_input_reader _, string_tensor = parallel_reader.parallel_read( config.input_path, reader_class=tf.TFRecordReader, num_epochs=(input_reader_config.num_epochs if input_reader_config.num_epochs else None), num_readers=input_reader_config.num_readers, shuffle=input_reader_config.shuffle, dtypes=[tf.string, tf.string], capacity=input_reader_config.queue_capacity, min_after_dequeue=input_reader_config.min_after_dequeue) return tf_example_decoder.TfExampleDecoder().Decode(string_tensor) raise ValueError('Unsupported input_reader_config.')
Example #17
Source File: exp11_user_dataset_low_API_1.py From LearningTensorflow with MIT License | 5 votes |
def read_tfrecord(tf_filename, size): queue = tf.train.string_input_producer([tf_filename]) reader = tf.TFRecordReader() __, serialized_example = reader.read(queue) feature = { 'image_raw': tf.FixedLenFeature([], tf.string), 'height': tf.FixedLenFeature([], tf.int64), 'width': tf.FixedLenFeature([], tf.int64) } features = tf.parse_single_example(serialized_example, features=feature) image = tf.decode_raw(features['image_raw'], tf.uint8) image = tf.reshape(image, size) return image
Example #18
Source File: convert.py From STORK with MIT License | 5 votes |
def __init__(self): # Initializes function that decodes RGB JPEG data. self._decode_jpeg_data = tf.placeholder(dtype=tf.string) self._decode_jpeg = tf.image.decode_jpeg(self._decode_jpeg_data, channels=3)
Example #19
Source File: train.py From tensorflow-data with MIT License | 5 votes |
def parser(record): keys_to_features = { "image_raw": tf.FixedLenFeature([], tf.string), "label": tf.FixedLenFeature([], tf.int64) } parsed = tf.parse_single_example(record, keys_to_features) image = tf.decode_raw(parsed["image_raw"], tf.uint8) image = tf.cast(image, tf.float32) #image = tf.reshape(image, shape=[224, 224, 3]) label = tf.cast(parsed["label"], tf.int32) return {'image': image}, label
Example #20
Source File: detection_inference.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def build_input(tfrecord_paths): """Builds the graph's input. Args: tfrecord_paths: List of paths to the input TFRecords Returns: serialized_example_tensor: The next serialized example. String scalar Tensor image_tensor: The decoded image of the example. Uint8 tensor, shape=[1, None, None,3] """ filename_queue = tf.train.string_input_producer( tfrecord_paths, shuffle=False, num_epochs=1) tf_record_reader = tf.TFRecordReader() _, serialized_example_tensor = tf_record_reader.read(filename_queue) features = tf.parse_single_example( serialized_example_tensor, features={ standard_fields.TfExampleFields.image_encoded: tf.FixedLenFeature([], tf.string), }) encoded_image = features[standard_fields.TfExampleFields.image_encoded] image_tensor = tf.image.decode_image(encoded_image, channels=3) image_tensor.set_shape([None, None, 3]) image_tensor = tf.expand_dims(image_tensor, 0) return serialized_example_tensor, image_tensor
Example #21
Source File: inputs_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_predict_input(self): """Tests the predict input function.""" configs = _get_configs_for_model('ssd_inception_v2_pets') predict_input_fn = inputs.create_predict_input_fn( model_config=configs['model'], predict_input_config=configs['eval_input_configs'][0]) serving_input_receiver = predict_input_fn() image = serving_input_receiver.features[fields.InputDataFields.image] receiver_tensors = serving_input_receiver.receiver_tensors[ inputs.SERVING_FED_EXAMPLE_KEY] self.assertEqual([1, 300, 300, 3], image.shape.as_list()) self.assertEqual(tf.float32, image.dtype) self.assertEqual(tf.string, receiver_tensors.dtype)
Example #22
Source File: image_utils.py From fine-lm with MIT License | 5 votes |
def example_reading_spec(self): data_fields = { "image/encoded": tf.FixedLenFeature((), tf.string), "image/format": tf.FixedLenFeature((), tf.string), } data_items_to_decoders = { "inputs": tf.contrib.slim.tfexample_decoder.Image( image_key="image/encoded", format_key="image/format", channels=self.num_channels), } return data_fields, data_items_to_decoders
Example #23
Source File: video_utils.py From fine-lm with MIT License | 5 votes |
def example_reading_spec(self): data_fields = { "image/encoded": tf.FixedLenFeature((), tf.string), "image/format": tf.FixedLenFeature((), tf.string), } data_items_to_decoders = { "inputs": tf.contrib.slim.tfexample_decoder.Image( image_key="image/encoded", format_key="image/format", channels=self.num_channels), } return data_fields, data_items_to_decoders
Example #24
Source File: image_utils_test.py From fine-lm with MIT License | 5 votes |
def testImageGenerator(self): # 2 random images np.random.seed(1111) # To avoid any flakiness. image1 = np.random.randint(0, 255, size=(10, 12, 3)) image2 = np.random.randint(0, 255, size=(10, 12, 3)) # Call image generator on the 2 images with labels [1, 2]. encoded_imgs, labels = [], [] for dictionary in image_utils.image_generator([image1, image2], [1, 2]): self.assertEqual( sorted(list(dictionary)), [ "image/class/label", "image/encoded", "image/format", "image/height", "image/width" ]) self.assertEqual(dictionary["image/format"], ["png"]) self.assertEqual(dictionary["image/height"], [12]) self.assertEqual(dictionary["image/width"], [10]) encoded_imgs.append(dictionary["image/encoded"]) labels.append(dictionary["image/class/label"]) # Check that the result labels match the inputs. self.assertEqual(len(labels), 2) self.assertEqual(labels[0], [1]) self.assertEqual(labels[1], [2]) # Decode images and check that they match the inputs. self.assertEqual(len(encoded_imgs), 2) image_t = tf.placeholder(dtype=tf.string) decoded_png_t = tf.image.decode_png(image_t) with self.test_session() as sess: encoded_img1 = encoded_imgs[0] self.assertEqual(len(encoded_img1), 1) decoded1 = sess.run(decoded_png_t, feed_dict={image_t: encoded_img1[0]}) self.assertAllClose(decoded1, image1) encoded_img2 = encoded_imgs[1] self.assertEqual(len(encoded_img2), 1) decoded2 = sess.run(decoded_png_t, feed_dict={image_t: encoded_img2[0]}) self.assertAllClose(decoded2, image2)
Example #25
Source File: loop.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
def _define_step(self, done, score, summary): """Combine operations of a phase. Keeps track of the mean score and when to report it. Args: done: Tensor indicating whether current score can be used. score: Tensor holding the current, possibly intermediate, score. summary: Tensor holding summary string to write if not an empty string. Returns: Tuple of summary tensor, mean score, and new global step. The mean score is zero for non reporting steps. """ if done.shape.ndims == 0: done = done[None] if score.shape.ndims == 0: score = score[None] score_mean = streaming_mean.StreamingMean((), tf.float32) with tf.control_dependencies([done, score, summary]): done_score = tf.gather(score, tf.where(done)[:, 0]) submit_score = tf.cond( tf.reduce_any(done), lambda: score_mean.submit(done_score), tf.no_op) with tf.control_dependencies([submit_score]): mean_score = tf.cond(self._report, score_mean.clear, float) steps_made = tf.shape(score)[0] next_step = self._step.assign_add(steps_made) with tf.control_dependencies([mean_score, next_step]): return tf.identity(summary), mean_score, next_step, steps_made
Example #26
Source File: loop.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
def add_phase( self, name, done, score, summary, steps, report_every=None, log_every=None, checkpoint_every=None, feed=None): """Add a phase to the loop protocol. If the model breaks long computation into multiple steps, the done tensor indicates whether the current score should be added to the mean counter. For example, in reinforcement learning we only have a valid score at the end of the episode. Score and done tensors can either be scalars or vectors, to support single and batched computations. Args: name: Name for the phase, used for the summary writer. done: Tensor indicating whether current score can be used. score: Tensor holding the current, possibly intermediate, score. summary: Tensor holding summary string to write if not an empty string. steps: Duration of the phase in steps. report_every: Yield mean score every this number of steps. log_every: Request summaries via `log` tensor every this number of steps. checkpoint_every: Write checkpoint every this number of steps. feed: Additional feed dictionary for the session run call. Raises: ValueError: Unknown rank for done or score tensors. """ done = tf.convert_to_tensor(done, tf.bool) score = tf.convert_to_tensor(score, tf.float32) summary = tf.convert_to_tensor(summary, tf.string) feed = feed or {} if done.shape.ndims is None or score.shape.ndims is None: raise ValueError("Rank of 'done' and 'score' tensors must be known.") writer = self._logdir and tf.summary.FileWriter( os.path.join(self._logdir, name), tf.get_default_graph(), flush_secs=60) op = self._define_step(done, score, summary) batch = 1 if score.shape.ndims == 0 else score.shape[0].value self._phases.append(_Phase( name, writer, op, batch, int(steps), feed, report_every, log_every, checkpoint_every))
Example #27
Source File: loop.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
def _define_step(self, done, score, summary): """Combine operations of a phase. Keeps track of the mean score and when to report it. Args: done: Tensor indicating whether current score can be used. score: Tensor holding the current, possibly intermediate, score. summary: Tensor holding summary string to write if not an empty string. Returns: Tuple of summary tensor, mean score, and new global step. The mean score is zero for non reporting steps. """ if done.shape.ndims == 0: done = done[None] if score.shape.ndims == 0: score = score[None] score_mean = streaming_mean.StreamingMean((), tf.float32) with tf.control_dependencies([done, score, summary]): done_score = tf.gather(score, tf.where(done)[:, 0]) submit_score = tf.cond( tf.reduce_any(done), lambda: score_mean.submit(done_score), tf.no_op) with tf.control_dependencies([submit_score]): mean_score = tf.cond(self._report, score_mean.clear, float) steps_made = tf.shape(score)[0] next_step = self._step.assign_add(steps_made) with tf.control_dependencies([mean_score, next_step]): return tf.identity(summary), mean_score, next_step, steps_made
Example #28
Source File: loop.py From soccer-matlab with BSD 2-Clause "Simplified" License | 5 votes |
def add_phase( self, name, done, score, summary, steps, report_every=None, log_every=None, checkpoint_every=None, feed=None): """Add a phase to the loop protocol. If the model breaks long computation into multiple steps, the done tensor indicates whether the current score should be added to the mean counter. For example, in reinforcement learning we only have a valid score at the end of the episode. Score and done tensors can either be scalars or vectors, to support single and batched computations. Args: name: Name for the phase, used for the summary writer. done: Tensor indicating whether current score can be used. score: Tensor holding the current, possibly intermediate, score. summary: Tensor holding summary string to write if not an empty string. steps: Duration of the phase in steps. report_every: Yield mean score every this number of steps. log_every: Request summaries via `log` tensor every this number of steps. checkpoint_every: Write checkpoint every this number of steps. feed: Additional feed dictionary for the session run call. Raises: ValueError: Unknown rank for done or score tensors. """ done = tf.convert_to_tensor(done, tf.bool) score = tf.convert_to_tensor(score, tf.float32) summary = tf.convert_to_tensor(summary, tf.string) feed = feed or {} if done.shape.ndims is None or score.shape.ndims is None: raise ValueError("Rank of 'done' and 'score' tensors must be known.") writer = self._logdir and tf.summary.FileWriter( os.path.join(self._logdir, name), tf.get_default_graph(), flush_secs=60) op = self._define_step(done, score, summary) batch = 1 if score.shape.ndims == 0 else score.shape[0].value self._phases.append(_Phase( name, writer, op, batch, int(steps), feed, report_every, log_every, checkpoint_every))
Example #29
Source File: inputs.py From DOTA_models with Apache License 2.0 | 5 votes |
def parse_sequence_example(serialized, image_feature, caption_feature): """Parses a tensorflow.SequenceExample into an image and caption. Args: serialized: A scalar string Tensor; a single serialized SequenceExample. image_feature: Name of SequenceExample context feature containing image data. caption_feature: Name of SequenceExample feature list containing integer captions. Returns: encoded_image: A scalar string Tensor containing a JPEG encoded image. caption: A 1-D uint64 Tensor with dynamically specified length. """ context, sequence = tf.parse_single_sequence_example( serialized, context_features={ image_feature: tf.FixedLenFeature([], dtype=tf.string) }, sequence_features={ caption_feature: tf.FixedLenSequenceFeature([], dtype=tf.int64), }) encoded_image = context[image_feature] caption = sequence[caption_feature] return encoded_image, caption
Example #30
Source File: build_mscoco_data.py From DOTA_models with Apache License 2.0 | 5 votes |
def __init__(self): # Create a single TensorFlow Session for all image decoding calls. self._sess = tf.Session() # TensorFlow ops for JPEG decoding. self._encoded_jpeg = tf.placeholder(dtype=tf.string) self._decode_jpeg = tf.image.decode_jpeg(self._encoded_jpeg, channels=3)