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


Python image_resizer_pb2.ImageResizer方法代码示例

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


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

示例1: build_input

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def build_input():
  image_tensor = image_ph = tf.placeholder(dtype=tf.uint8, shape=[None, None, 3], name='image_ph')
  image_resizer_text_proto = """
    keep_aspect_ratio_resizer {
      min_dimension: 800
      max_dimension: 1365
    }
  """
  image_resizer_config = image_resizer_pb2.ImageResizer()
  text_format.Merge(image_resizer_text_proto, image_resizer_config)
  image_resizer_fn = image_resizer_builder.build(image_resizer_config)
  resized_image_tensor, _ = image_resizer_fn(image_tensor)
  resized_image_tensor = tf.cast(resized_image_tensor, dtype=tf.uint8)
  resized_image_tensor = tf.expand_dims(resized_image_tensor, 0)

  return image_ph, resized_image_tensor 
开发者ID:jerryli27,项目名称:AniSeg,代码行数:18,代码来源:infer_from_image.py

示例2: _shape_of_resized_random_image_given_text_proto

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(
      self, input_shape, text_proto):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    text_format.Merge(text_proto, image_resizer_config)
    image_resizer_fn = image_resizer_builder.build(image_resizer_config)
    images = tf.to_float(tf.random_uniform(
        input_shape, minval=0, maxval=255, dtype=tf.int32))
    resized_images = image_resizer_fn(images)
    with self.test_session() as sess:
      return sess.run(resized_images).shape 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:image_resizer_builder_test.py

示例3: build

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def build(image_resizer_config):
  """Builds callable for image resizing operations.

  Args:
    image_resizer_config: image_resizer.proto object containing parameters for
      an image resizing operation.

  Returns:
    image_resizer_fn: Callable for image resizing.  This callable always takes
      a rank-3 image tensor (corresponding to a single image) and returns a
      rank-3 image tensor, possibly with new spatial dimensions.

  Raises:
    ValueError: if `image_resizer_config` is of incorrect type.
    ValueError: if `image_resizer_config.image_resizer_oneof` is of expected
      type.
    ValueError: if min_dimension > max_dimension when keep_aspect_ratio_resizer
      is used.
  """
  if not isinstance(image_resizer_config, image_resizer_pb2.ImageResizer):
    raise ValueError('image_resizer_config not of type '
                     'image_resizer_pb2.ImageResizer.')

  if image_resizer_config.WhichOneof(
      'image_resizer_oneof') == 'keep_aspect_ratio_resizer':
    keep_aspect_ratio_config = image_resizer_config.keep_aspect_ratio_resizer
    if not (keep_aspect_ratio_config.min_dimension
            <= keep_aspect_ratio_config.max_dimension):
      raise ValueError('min_dimension > max_dimension')
    return functools.partial(
        preprocessor.resize_to_range,
        min_dimension=keep_aspect_ratio_config.min_dimension,
        max_dimension=keep_aspect_ratio_config.max_dimension)
  if image_resizer_config.WhichOneof(
      'image_resizer_oneof') == 'fixed_shape_resizer':
    fixed_shape_resizer_config = image_resizer_config.fixed_shape_resizer
    return functools.partial(preprocessor.resize_image,
                             new_height=fixed_shape_resizer_config.height,
                             new_width=fixed_shape_resizer_config.width)
  raise ValueError('Invalid image resizer option.') 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:42,代码来源:image_resizer_builder.py

示例4: testGetSpatialImageSizeFromFixedShapeResizerConfig

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromFixedShapeResizerConfig(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.fixed_shape_resizer.height = 100
    image_resizer_config.fixed_shape_resizer.width = 200
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [100, 200]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:8,代码来源:config_util_test.py

示例5: testGetSpatialImageSizeFromAspectPreservingResizerConfig

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromAspectPreservingResizerConfig(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
    image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
    image_resizer_config.keep_aspect_ratio_resizer.pad_to_max_dimension = True
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [600, 600]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:9,代码来源:config_util_test.py

示例6: testGetSpatialImageSizeFromAspectPreservingResizerDynamic

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def testGetSpatialImageSizeFromAspectPreservingResizerDynamic(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
    image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [-1, -1]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:8,代码来源:config_util_test.py

示例7: _shape_of_resized_random_image_given_text_proto

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(self, input_shape,
                                                      text_proto):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    text_format.Merge(text_proto, image_resizer_config)
    image_resizer_fn = image_resizer_builder.build(image_resizer_config)
    images = tf.to_float(
        tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32))
    resized_images, _ = image_resizer_fn(images)
    with self.test_session() as sess:
      return sess.run(resized_images).shape 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:12,代码来源:image_resizer_builder_test.py

示例8: _resized_image_given_text_proto

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _resized_image_given_text_proto(self, image, text_proto):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    text_format.Merge(text_proto, image_resizer_config)
    image_resizer_fn = image_resizer_builder.build(image_resizer_config)
    image_placeholder = tf.placeholder(tf.uint8, [1, None, None, 3])
    resized_image, _ = image_resizer_fn(image_placeholder)
    with self.test_session() as sess:
      return sess.run(resized_image, feed_dict={image_placeholder: image}) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:10,代码来源:image_resizer_builder_test.py

示例9: test_get_spatial_image_size_from_fixed_shape_resizer_config

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_fixed_shape_resizer_config(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.fixed_shape_resizer.height = 100
    image_resizer_config.fixed_shape_resizer.width = 200
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [100, 200]) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:8,代码来源:config_util_test.py

示例10: test_get_spatial_image_size_from_aspect_preserving_resizer_config

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_aspect_preserving_resizer_config(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
    image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
    image_resizer_config.keep_aspect_ratio_resizer.pad_to_max_dimension = True
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [600, 600]) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:9,代码来源:config_util_test.py

示例11: test_get_spatial_image_size_from_aspect_preserving_resizer_dynamic

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def test_get_spatial_image_size_from_aspect_preserving_resizer_dynamic(self):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    image_resizer_config.keep_aspect_ratio_resizer.min_dimension = 100
    image_resizer_config.keep_aspect_ratio_resizer.max_dimension = 600
    image_shape = config_util.get_spatial_image_size(image_resizer_config)
    self.assertAllEqual(image_shape, [-1, -1]) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:8,代码来源:config_util_test.py

示例12: _shape_of_resized_random_image_given_text_proto

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _shape_of_resized_random_image_given_text_proto(self, input_shape,
                                                      text_proto):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    text_format.Merge(text_proto, image_resizer_config)
    image_resizer_fn = image_resizer_builder.build(image_resizer_config)
    images = tf.to_float(
        tf.random_uniform(input_shape, minval=0, maxval=255, dtype=tf.int32))
    resized_images = image_resizer_fn(images)
    with self.test_session() as sess:
      return sess.run(resized_images).shape 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:12,代码来源:image_resizer_builder_test.py

示例13: _resized_image_given_text_proto

# 需要导入模块: from object_detection.protos import image_resizer_pb2 [as 别名]
# 或者: from object_detection.protos.image_resizer_pb2 import ImageResizer [as 别名]
def _resized_image_given_text_proto(self, image, text_proto):
    image_resizer_config = image_resizer_pb2.ImageResizer()
    text_format.Merge(text_proto, image_resizer_config)
    image_resizer_fn = image_resizer_builder.build(image_resizer_config)
    image_placeholder = tf.placeholder(tf.uint8, [1, None, None, 3])
    resized_image = image_resizer_fn(image_placeholder)
    with self.test_session() as sess:
      return sess.run(resized_image, feed_dict={image_placeholder: image}) 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:10,代码来源:image_resizer_builder_test.py


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