예제 #1
0
 def generate_sprite(self, example_strings):
     # Generate a sprite image for the examples if the examples contain the
     # standard encoded image feature.
     feature_list = (self.examples[0].features.feature
                     if self.example_class == tf.train.Example else
                     self.examples[0].context.feature)
     self.sprite = (inference_utils.create_sprite_image(example_strings) if
                    (len(self.examples)
                     and self.image_feature_name in feature_list) else None)
예제 #2
0
 def _generate_sprite(self):
   # Generate a sprite image for the examples if the examples contain the
   # standard encoded image feature.
   if not self.examples:
     return
   example_to_check = self.json_to_proto(self.examples[0])
   feature_list = (example_to_check.context.feature
                   if self.config.get('are_sequence_examples')
                   else example_to_check.features.feature)
   if 'image/encoded' in feature_list:
     example_strings = [
       self.json_to_proto(ex).SerializeToString()
       for ex in self.examples]
     encoded = base64.b64encode(
       inference_utils.create_sprite_image(example_strings))
     self.sprite = 'data:image/png;base64,{}'.format(encoded)
예제 #3
0
 def create_sprite(self):
     """Returns an encoded image of thumbnails for image examples."""
     # Generate a sprite image for the examples if the examples contain the
     # standard encoded image feature.
     if not self.examples:
         return None
     example_to_check = self.json_to_proto(self.examples[0])
     feature_list = (example_to_check.context.feature
                     if self.config.get("are_sequence_examples") else
                     example_to_check.features.feature)
     if "image/encoded" in feature_list:
         example_strings = [
             self.json_to_proto(ex).SerializeToString()
             for ex in self.examples
         ]
         encoded = ensure_str(
             base64.b64encode(
                 inference_utils.create_sprite_image(example_strings)))
         return "data:image/png;base64,{}".format(encoded)
     else:
         return None
예제 #4
0
 def create_sprite(self):
   """Returns an encoded image of thumbnails for image examples."""
   # Generate a sprite image for the examples if the examples contain the
   # standard encoded image feature.
   if not self.examples:
     return None
   example_to_check = self.json_to_proto(self.examples[0])
   feature_list = (example_to_check.context.feature
                   if self.config.get('are_sequence_examples')
                   else example_to_check.features.feature)
   if 'image/encoded' in feature_list:
     example_strings = [
       self.json_to_proto(ex).SerializeToString()
       for ex in self.examples]
     encoded = base64.b64encode(
       inference_utils.create_sprite_image(example_strings))
     if sys.version_info >= (3, 0):
       encoded = encoded.decode('utf-8')
     return 'data:image/png;base64,{}'.format(encoded)
   else:
     return None