本文整理匯總了Python中preprocessing.unscale_jpeg_encode方法的典型用法代碼示例。如果您正苦於以下問題:Python preprocessing.unscale_jpeg_encode方法的具體用法?Python preprocessing.unscale_jpeg_encode怎麽用?Python preprocessing.unscale_jpeg_encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類preprocessing
的用法示例。
在下文中一共展示了preprocessing.unscale_jpeg_encode方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _setup_np_inference
# 需要導入模塊: import preprocessing [as 別名]
# 或者: from preprocessing import unscale_jpeg_encode [as 別名]
def _setup_np_inference(self, np_images, checkpoint_path):
"""Sets up and restores inference graph, creates and caches a Session."""
tf.logging.info('Restoring model weights.')
# Define inference over an image placeholder.
_, height, width, _ = np.shape(np_images)
image_placeholder = tf.placeholder(
tf.float32, shape=(None, height, width, 3))
# Preprocess batch.
preprocessed = self.preprocess_data(image_placeholder, is_training=False)
# Unscale and jpeg encode preprocessed images for display purposes.
im_strings = preprocessing.unscale_jpeg_encode(preprocessed)
# Do forward pass to get embeddings.
embeddings = self.forward(preprocessed, is_training=False)
# Create a saver to restore model variables.
tf.train.get_or_create_global_step()
saver = tf.train.Saver(tf.all_variables())
self._image_placeholder = image_placeholder
self._batch_encoded = embeddings
self._np_inf_tensor_dict = {
'embeddings': embeddings,
'raw_image_strings': im_strings,
}
# Create a session and restore model variables.
self._sess = tf.Session()
saver.restore(self._sess, checkpoint_path)