當前位置: 首頁>>代碼示例>>Python>>正文


Python feature_pb2.BytesList方法代碼示例

本文整理匯總了Python中tensorflow.core.example.feature_pb2.BytesList方法的典型用法代碼示例。如果您正苦於以下問題:Python feature_pb2.BytesList方法的具體用法?Python feature_pb2.BytesList怎麽用?Python feature_pb2.BytesList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.core.example.feature_pb2的用法示例。


在下文中一共展示了feature_pb2.BytesList方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_tf_record

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def create_tf_record(self):
    path = os.path.join(self.get_temp_dir(), 'tfrecord')
    writer = tf.python_io.TFRecordWriter(path)

    image_tensor = np.random.randint(255, size=(4, 5, 3)).astype(np.uint8)
    with self.test_session():
      encoded_jpeg = tf.image.encode_jpeg(tf.constant(image_tensor)).eval()
    example = example_pb2.Example(features=feature_pb2.Features(feature={
        'image/encoded': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[encoded_jpeg])),
        'image/format': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=['jpeg'.encode('utf-8')])),
        'image/transcript': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[
                'hello'.encode('utf-8')]))
    }))
    writer.write(example.SerializeToString())
    writer.close()

    return path 
開發者ID:bgshih,項目名稱:aster,代碼行數:22,代碼來源:input_reader_builder_test.py

示例2: create_tf_record

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def create_tf_record(self):
    path = os.path.join(self.get_temp_dir(), 'tfrecord')
    writer = tf.python_io.TFRecordWriter(path)

    image_tensor = np.random.randint(255, size=(4, 5, 3)).astype(np.uint8)
    with self.test_session():
      encoded_jpeg = tf.image.encode_jpeg(tf.constant(image_tensor)).eval()
    example = example_pb2.Example(features=feature_pb2.Features(feature={
        'image/encoded': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[encoded_jpeg])),
        'image/format': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=['jpeg'.encode('utf-8')])),
        'image/object/bbox/xmin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/xmax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/bbox/ymin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/ymax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/class/label': feature_pb2.Feature(
            int64_list=feature_pb2.Int64List(value=[2])),
    }))
    writer.write(example.SerializeToString())
    writer.close()

    return path 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:29,代碼來源:input_reader_builder_test.py

示例3: _encoded_bytes_feature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _encoded_bytes_feature(tf_encoded):
  encoded = tf_encoded.eval()

  def string_to_bytes(value):
    return feature_pb2.BytesList(value=[value])

  return feature_pb2.Feature(bytes_list=string_to_bytes(encoded)) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:9,代碼來源:test_utils.py

示例4: _string_feature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _string_feature(value):
  value = value.encode('utf-8')
  return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=[value])) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:5,代碼來源:test_utils.py

示例5: _EncodedBytesFeature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _EncodedBytesFeature(self, tf_encoded):
    with self.test_session():
      encoded = tf_encoded.eval()

    def BytesList(value):
      return feature_pb2.BytesList(value=[value])

    return feature_pb2.Feature(bytes_list=BytesList(encoded)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:10,代碼來源:tfexample_decoder_test.py

示例6: _BytesFeature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _BytesFeature(self, ndarray):
    values = ndarray.flatten().tolist()
    for i in range(len(values)):
      values[i] = values[i].encode('utf-8')
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=values)) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:7,代碼來源:tfexample_decoder_test.py

示例7: _StringFeature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _StringFeature(self, value):
    value = value.encode('utf-8')
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=[value])) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:5,代碼來源:tfexample_decoder_test.py

示例8: _BytesFeature

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _BytesFeature(self, value):
    if isinstance(value, list):
      return tf.train.Feature(bytes_list=tf.train.BytesList(value=value))
    return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value])) 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:6,代碼來源:tf_example_decoder_test.py

示例9: _BytesFeatureFromList

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _BytesFeatureFromList(self, ndarray):
    values = ndarray.flatten().tolist()
    for i in range(len(values)):
      values[i] = values[i].encode('utf-8')
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=values)) 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:7,代碼來源:tf_example_decoder_test.py

示例10: create_tf_record

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def create_tf_record(self):
    path = os.path.join(self.get_temp_dir(), 'tfrecord')
    writer = tf.python_io.TFRecordWriter(path)

    image_tensor = np.random.randint(255, size=(4, 5, 3)).astype(np.uint8)
    flat_mask = (4 * 5) * [1.0]
    with self.test_session():
      encoded_jpeg = tf.image.encode_jpeg(tf.constant(image_tensor)).eval()
    example = example_pb2.Example(features=feature_pb2.Features(feature={
        'image/encoded': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=[encoded_jpeg])),
        'image/format': feature_pb2.Feature(
            bytes_list=feature_pb2.BytesList(value=['jpeg'.encode('utf-8')])),
        'image/height': feature_pb2.Feature(
            int64_list=feature_pb2.Int64List(value=[4])),
        'image/width': feature_pb2.Feature(
            int64_list=feature_pb2.Int64List(value=[5])),
        'image/object/bbox/xmin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/xmax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/bbox/ymin': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[0.0])),
        'image/object/bbox/ymax': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=[1.0])),
        'image/object/class/label': feature_pb2.Feature(
            int64_list=feature_pb2.Int64List(value=[2])),
        'image/object/mask': feature_pb2.Feature(
            float_list=feature_pb2.FloatList(value=flat_mask)),
    }))
    writer.write(example.SerializeToString())
    writer.close()

    return path 
開發者ID:cagbal,項目名稱:ros_people_object_detection_tensorflow,代碼行數:36,代碼來源:input_reader_builder_test.py

示例11: _BytesFeatureFromList

# 需要導入模塊: from tensorflow.core.example import feature_pb2 [as 別名]
# 或者: from tensorflow.core.example.feature_pb2 import BytesList [as 別名]
def _BytesFeatureFromList(self, ndarray):
    values = ndarray.flatten().tolist()
    return feature_pb2.Feature(bytes_list=feature_pb2.BytesList(value=values)) 
開發者ID:ambakick,項目名稱:Person-Detection-and-Tracking,代碼行數:5,代碼來源:tf_example_decoder_test.py


注:本文中的tensorflow.core.example.feature_pb2.BytesList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。