tensorflow:: ops:: SampleDistortedBoundingBox

#include <image_ops.h>

画像に対して、ランダムに歪んだ単一のバウンディングボックスを生成します。

まとめ

画像認識や物体位置特定タスクでは、正解ラベルに加えてバウンディングボックスの注釈が提供されることがよくあります。このようなシステムをトレーニングするための一般的な手法は、画像の内容を保持したままランダムに画像を歪ませること、つまりデータ拡張を行うことです。この操作ではimage_size 、 bounding_boxes 、および一連の制約が与えられた場合、ランダムに歪ませた物体の位置(バウンディングボックス)を出力します。

この操作の出力は、元の画像を切り抜くために使用できる単一のバウンディングボックスです。出力は、 begin 、 size 、 bboxes 3 つのテンソルとして返されます。最初の 2 つのテンソルは、 tf.sliceに直接渡して画像を切り抜くことができます。最後の bboxes は、 tf.image.draw_bounding_boxesに渡して、バウンディングボックスの形状を視覚化することができます。

バウンディングボックスは、 [y_min, x_min, y_max, x_max]の形式で指定され、返されます。バウンディングボックスの座標は、基となる画像の幅と高さに対する相対値として、 [0.0, 1.0]の範囲の浮動小数点数です。

例えば、

    # Generate a single distorted bounding box.
    begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
        tf.shape(image),
        bounding_boxes=bounding_boxes)

    # Draw the bounding box in an image summary.
    image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0),
                                                  bbox_for_draw)
    tf.summary.image('images_with_box', image_with_box)

    # Employ the bounding box to distort the image.
    distorted_image = tf.slice(image, begin, size)

バウンディングボックスの情報が利用できない場合、 use_image_if_no_bounding_boxes = trueに設定すると、画像全体を覆う単一の暗黙的なバウンディングボックスが存在するとみなされます。use_image_if_no_bounding_boxes use_image_if_no_bounding_boxes false で、バウンディングボックスが指定されていない場合は、エラーが発生します。

議論:

  • スコープ:スコープオブジェクト
  • image_size: 1次元、 [height, width, channels]を含む。
  • bounding_boxes: 画像に関連付けられた N 個のバウンディングボックスを表す形状[batch, N, 4]の 3-D。

オプション属性( Attrs参照):

  • seed: seedまたはseed2いずれかがゼロ以外の値に設定されている場合、乱数生成器は指定されたseedで初期化されます。それ以外の場合は、ランダムなシード値で初期化されます。
  • seed2: シードの衝突を避けるための2つ目のシード。
  • min_object_covered: 画像の切り抜き領域は、指定されたバウンディングボックスの少なくともこの割合を含んでいる必要があります。このパラメータの値は負であってはなりません。0 の場合、切り抜き領域は指定されたバウンディングボックスのいずれとも重なる必要はありません。
  • aspect_ratio_range: 画像の切り抜き領域の縦横比(幅/高さ)はこの範囲内である必要があります。
  • area_range: 画像の切り抜き領域は、指定された画像の一部がこの範囲内に含まれている必要があります。
  • max_attempts: 指定された制約条件を満たす画像の切り抜き領域を生成する試行回数。max_attempts回のmax_attemptsに失敗した場合、画像全体を返します。
  • use_image_if_no_bounding_boxes: バウンディングボックスが指定されていない場合の動作を制御します。true の場合、入力全体を覆う暗黙のバウンディングボックスを想定します。false の場合、エラーを発生させます。

返品:

  • Output開始: 1次元、 [offset_height, offset_width, 0]を含むtf.sliceへの入力として提供してください。
  • Outputサイズ:1次元、 [target_height, target_width, -1]を含むtf.sliceへの入力として提供してください。
  • Outputバウンディングボックス: 歪んだバウンディングボックスを含む形状[1, 1, 4]の 3D バウンディングボックスtf.image.draw_bounding_boxesへの入力として指定します。

構築者と破壊者

SampleDistortedBoundingBox (const :: tensorflow::Scope & scope, :: tensorflow::Input image_size, :: tensorflow::Input bounding_boxes)
SampleDistortedBoundingBox (const :: tensorflow::Scope & scope, :: tensorflow::Input image_size, :: tensorflow::Input bounding_boxes, const SampleDistortedBoundingBox::Attrs & attrs)

公開属性

bboxes
begin
operation
size

パブリック静的関数

AreaRange (const gtl::ArraySlice< float > & x)
AspectRatioRange (const gtl::ArraySlice< float > & x)
MaxAttempts (int64 x)
MinObjectCovered (float x)
Seed (int64 x)
Seed2 (int64 x)
UseImageIfNoBoundingBoxes (bool x)

構造

tensorflow:: ops:: SampleDistortedBoundingBox:: Attrs

SampleDistortedBoundingBoxのオプション属性セッター。

公開属性

bbox

::tensorflow::Output bboxes

始める

::tensorflow::Output begin

手術

Operation operation

サイズ

::tensorflow::Output size

公的機能

サンプル歪みバウンディングボックス

 SampleDistortedBoundingBox(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input image_size,
  ::tensorflow::Input bounding_boxes
)

サンプル歪みバウンディングボックス

 SampleDistortedBoundingBox(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input image_size,
  ::tensorflow::Input bounding_boxes,
  const SampleDistortedBoundingBox::Attrs & attrs
)

パブリック静的関数

エリア範囲

Attrs AreaRange(
  const gtl::ArraySlice< float > & x
)

アスペクト比範囲

Attrs AspectRatioRange(
  const gtl::ArraySlice< float > & x
)

最大試行回数

Attrs MaxAttempts(
  int64 x
)

MinObjectCovered

Attrs MinObjectCovered(
  float x
)

シード

Attrs Seed(
  int64 x
)

シード2

Attrs Seed2(
  int64 x
)

境界ボックスがない場合は画像を使用する

Attrs UseImageIfNoBoundingBoxes(
  bool x
)