当前位置: 首页>>代码示例>>Python>>正文


Python util.is_np_array方法代码示例

本文整理汇总了Python中utils.util.is_np_array方法的典型用法代码示例。如果您正苦于以下问题:Python util.is_np_array方法的具体用法?Python util.is_np_array怎么用?Python util.is_np_array使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在utils.util的用法示例。


在下文中一共展示了util.is_np_array方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: inference

# 需要导入模块: from utils import util [as 别名]
# 或者: from utils.util import is_np_array [as 别名]
def inference(
      self, inference_input, checkpoint_path, batch_size=None, **kwargs):
    """Defines 3 of modes of inference.

    Inputs:
    * Mode 1: Input is an input_fn.
    * Mode 2: Input is a TFRecord (or list of TFRecords).
    * Mode 3: Input is a numpy array holding an image (or array of images).

    Outputs:
    * Mode 1: this returns an iterator over embeddings and additional
      metadata. See
      https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator#predict
      for details.
    * Mode 2: Returns an iterator over tuples of
      (embeddings, raw_image_strings, sequence_name), where embeddings is a
      2-D float32 numpy array holding [sequence_size, embedding_size] image
      embeddings, raw_image_strings is a 1-D string numpy array holding
      [sequence_size] jpeg-encoded image strings, and sequence_name is a
      string holding the name of the embedded sequence.
    * Mode 3: Returns a tuple of (embeddings, raw_image_strings), where
      embeddings is a 2-D float32 numpy array holding
      [batch_size, embedding_size] image embeddings, raw_image_strings is a
      1-D string numpy array holding [batch_size] jpeg-encoded image strings.

    Args:
      inference_input: This can be a tf.Estimator input_fn, a TFRecord path,
        a list of TFRecord paths, a numpy image, or an array of numpy images.
      checkpoint_path: String, path to the checkpoint to restore for inference.
      batch_size: Int, the size of the batch to use for inference.
      **kwargs: Additional keyword arguments, depending on the mode.
        See _input_fn_inference, _tfrecord_inference, and _np_inference.
    Returns:
      inference_output: Inference output depending on mode, see above for
        details.
    Raises:
      ValueError: If inference_input isn't a tf.Estimator input_fn,
        a TFRecord path, a list of TFRecord paths, or a numpy array,
    """
    # Mode 1: input is a callable tf.Estimator input_fn.
    if callable(inference_input):
      return self._input_fn_inference(
          input_fn=inference_input, checkpoint_path=checkpoint_path, **kwargs)
    # Mode 2: Input is a TFRecord path (or list of TFRecord paths).
    elif util.is_tfrecord_input(inference_input):
      return self._tfrecord_inference(
          records=inference_input, checkpoint_path=checkpoint_path,
          batch_size=batch_size, **kwargs)
    # Mode 3: Input is a numpy array of raw images.
    elif util.is_np_array(inference_input):
      return self._np_inference(
          np_images=inference_input, checkpoint_path=checkpoint_path, **kwargs)
    else:
      raise ValueError(
          'inference input must be a tf.Estimator input_fn, a TFRecord path,'
          'a list of TFRecord paths, or a numpy array. Got: %s' % str(type(
              inference_input))) 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:59,代码来源:base_estimator.py


注:本文中的utils.util.is_np_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。