gan_metrics.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:tefla 作者: openAGI 项目源码 文件源码
def run_inception(images,
                  graph_def=None,
                  default_graph_def_fn=_default_graph_def_fn,
                  image_size=INCEPTION_DEFAULT_IMAGE_SIZE,
                  input_tensor=INCEPTION_INPUT,
                  output_tensor=INCEPTION_OUTPUT):
    """Run images through a pretrained Inception classifier.
    Args:
      images: Input tensors. Must be [batch, height, width, channels]. Input shape
        and values must be in [-1, 1], which can be achieved using
        `preprocess_image`.
      graph_def: A GraphDef proto of a pretrained Inception graph. If `None`,
        call `default_graph_def_fn` to get GraphDef.
      default_graph_def_fn: A function that returns a GraphDef. Used if
        `graph_def` is `None. By default, returns a pretrained InceptionV3 graph.
      image_size: Required image width and height. See unit tests for the default
        values.
      input_tensor: Name of input Tensor.
      output_tensor: Name of output Tensor. This function will compute activations
        at the specified layer. Examples include INCEPTION_V3_OUTPUT and
        INCEPTION_V3_FINAL_POOL which would result in this function computing
        the final logits or the penultimate pooling layer.
    Returns:
      Logits.
    Raises:
      ValueError: If images are not the correct size.
      ValueError: If neither `graph_def` nor `default_graph_def_fn` are provided.
    """
    images = _validate_images(images, image_size)

    if graph_def is None:
        if default_graph_def_fn is None:
            raise ValueError('If `graph_def` is `None`, must provide '
                             '`default_graph_def_fn`.')
        graph_def = default_graph_def_fn()

    activations = run_image_classifier(images, graph_def, input_tensor,
                                       output_tensor)
    if tf.rank(activations) != 2:
        activations = flatten(activations)
    return activations
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号