當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。