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


Python inception_preprocessing.distort_color方法代码示例

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


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

示例1: distort_image

# 需要导入模块: from preprocessing import inception_preprocessing [as 别名]
# 或者: from preprocessing.inception_preprocessing import distort_color [as 别名]
def distort_image(im, fast_mode=False):
  # All images in the same batch are transformed the same way, but over
  # iterations you see different distortions.
  # im should be float with values between 0 and 1.
  im_ = tf.reshape(im, shape=(-1,1,3))
  im_ = ip.apply_with_random_selector(
      im_, lambda x, ordering: ip.distort_color(x, ordering, fast_mode),
      num_cases=4)
  im_ = tf.reshape(im_, tf.shape(im))
  return im_ 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:tf_utils.py

示例2: distort_randomly_image_color

# 需要导入模块: from preprocessing import inception_preprocessing [as 别名]
# 或者: from preprocessing.inception_preprocessing import distort_color [as 别名]
def distort_randomly_image_color(image_tensor, fast_mode=False):
    """Accepts image tensor of (width, height, 3) and returns color distorted image.
    The function performs random brightness, saturation, hue, contrast change as it is performed
    for inception model training in TF-Slim (you can find the link below in comments). All the
    parameters of random variables were originally preserved. There are two regimes for the function
    to work: fast and slow. Slow one performs only saturation and brightness random change is performed.
    
    Parameters
    ----------
    image_tensor : Tensor of size (width, height, 3) of tf.int32 or tf.float
        Tensor with image with range [0,255]
    fast_mode : boolean
        Boolean value representing whether to use fast or slow mode
        
    Returns
    -------
    img_float_distorted_original_range : Tensor of size (width, height, 3) of type tf.float.
        Image Tensor with distorted color in [0,255] intensity range
    """
    
    # Make the range to be in [0,1]
    img_float_zero_one_range = tf.to_float(image_tensor) / 255
    
    # Randomly distort the color of image. There are 4 ways to do it.
    # Credit: TF-Slim
    # https://github.com/tensorflow/models/blob/master/slim/preprocessing/inception_preprocessing.py#L224
    # Most probably the inception models were trainined using this color augmentation:
    # https://github.com/tensorflow/models/tree/master/slim#pre-trained-models
    distorted_image = apply_with_random_selector(img_float_zero_one_range,
                                                 lambda x, ordering: distort_color(x, ordering, fast_mode=fast_mode),
                                                 num_cases=4)
    
    img_float_distorted_original_range = distorted_image * 255
    
    return img_float_distorted_original_range 
开发者ID:hailotech,项目名称:seg-mentor,代码行数:37,代码来源:augmentation.py


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