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


Python image_ops.encode_jpeg方法代碼示例

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


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

示例1: testSynthetic

# 需要導入模塊: from tensorflow.python.ops import image_ops [as 別名]
# 或者: from tensorflow.python.ops.image_ops import encode_jpeg [as 別名]
def testSynthetic(self):
    with self.test_session(use_gpu=True) as sess:
      # Encode it, then decode it, then encode it
      image0 = constant_op.constant(_SimpleColorRamp())
      jpeg0 = image_ops.encode_jpeg(image0)
      image1 = image_ops.decode_jpeg(jpeg0)
      image2 = image_ops.decode_jpeg(image_ops.encode_jpeg(image1))
      jpeg0, image0, image1, image2 = sess.run([jpeg0, image0, image1, image2])

      # The decoded-encoded image should be similar to the input
      self.assertLess(self.averageError(image0, image1), 0.6)

      # We should be very close to a fixpoint
      self.assertLess(self.averageError(image1, image2), 0.02)

      # Smooth ramps compress well (input size is 153600)
      self.assertGreaterEqual(len(jpeg0), 5000)
      self.assertLessEqual(len(jpeg0), 6000) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:20,代碼來源:image_ops_test.py

示例2: _encoder

# 需要導入模塊: from tensorflow.python.ops import image_ops [as 別名]
# 或者: from tensorflow.python.ops.image_ops import encode_jpeg [as 別名]
def _encoder(image, image_format):
  assert image_format in ['jpeg', 'png']
  if image_format == 'jpeg':
    tf_image = constant_op.constant(image, dtype=dtypes.uint8)
    return image_ops.encode_jpeg(tf_image)
  if image_format == 'png':
    tf_image = constant_op.constant(image, dtype=dtypes.uint8)
    return image_ops.encode_png(tf_image) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:10,代碼來源:test_utils.py

示例3: _Encoder

# 需要導入模塊: from tensorflow.python.ops import image_ops [as 別名]
# 或者: from tensorflow.python.ops.image_ops import encode_jpeg [as 別名]
def _Encoder(self, image, image_format):
    assert image_format in ['jpeg', 'JPEG', 'png', 'PNG', 'raw', 'RAW']
    if image_format in ['jpeg', 'JPEG']:
      tf_image = constant_op.constant(image, dtype=dtypes.uint8)
      return image_ops.encode_jpeg(tf_image)
    if image_format in ['png', 'PNG']:
      tf_image = constant_op.constant(image, dtype=dtypes.uint8)
      return image_ops.encode_png(tf_image)
    if image_format in ['raw', 'RAW']:
      return constant_op.constant(image.tostring(), dtype=dtypes.string) 
開發者ID:abhisuri97,項目名稱:auto-alt-text-lambda-api,代碼行數:12,代碼來源:tfexample_decoder_test.py

示例4: _Encoder

# 需要導入模塊: from tensorflow.python.ops import image_ops [as 別名]
# 或者: from tensorflow.python.ops.image_ops import encode_jpeg [as 別名]
def _Encoder(self, image, image_format):
    assert image_format in ['jpeg', 'JPEG', 'png', 'PNG', 'raw', 'RAW']
    if image_format in ['jpeg', 'JPEG']:
      tf_image = tf.constant(image, dtype=tf.uint8)
      return image_ops.encode_jpeg(tf_image)
    if image_format in ['png', 'PNG']:
      tf_image = tf.constant(image, dtype=tf.uint8)
      return image_ops.encode_png(tf_image)
    if image_format in ['raw', 'RAW']:
      # If machine is big endian, change the byte ordering in case of dtype
      # float32 so that it should be interpreted correctly.
      if image.dtype == np.float32 and sys.byteorder == 'big':
        image = image.astype('<f4')
      return tf.constant(image.tostring(), dtype=tf.string) 
開發者ID:google-research,項目名稱:tf-slim,代碼行數:16,代碼來源:tfexample_decoder_test.py

示例5: testExisting

# 需要導入模塊: from tensorflow.python.ops import image_ops [as 別名]
# 或者: from tensorflow.python.ops.image_ops import encode_jpeg [as 別名]
def testExisting(self):
    # Read a real jpeg and verify shape
    path = ('tensorflow/core/lib/jpeg/testdata/'
            'jpeg_merge_test1.jpg')
    with self.test_session(use_gpu=True) as sess:
      jpeg0 = io_ops.read_file(path)
      image0 = image_ops.decode_jpeg(jpeg0)
      image1 = image_ops.decode_jpeg(image_ops.encode_jpeg(image0))
      jpeg0, image0, image1 = sess.run([jpeg0, image0, image1])
      self.assertEqual(len(jpeg0), 3771)
      self.assertEqual(image0.shape, (256, 128, 3))
      self.assertLess(self.averageError(image0, image1), 0.8) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:14,代碼來源:image_ops_test.py


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