テンソルフロー::作戦::サンプル歪んだ境界ボックス

#include <image_ops.h>

画像に対してランダムに歪んだ単一の境界ボックスを生成します。

まとめ

多くの場合、境界ボックスの注釈は、画像認識タスクやオブジェクト位置特定タスクでグラウンドトゥルース ラベルに加えて提供されます。このようなシステムをトレーニングするための一般的な手法は、コンテンツを維持しながら画像をランダムに歪ませる、つまりデータ拡張です。この Op は、 image_sizebounding_boxesおよび一連の制約を指定して、ランダムに歪んだオブジェクトの位置、つまりバウンディング ボックスを出力します。

この Op の出力は、元の画像をトリミングするために使用できる単一の境界ボックスです。出力は、 beginsizebboxes 3 つのテンソルとして返されます。最初の 2 つのテンソルをtf.sliceに直接入力して画像をトリミングできます。後者は、境界ボックスがどのように見えるかを視覚化するために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が false で、境界ボックスが指定されていない場合、エラーが発生します。

引数:

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

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

  • シード: seedまたはseed2いずれかがゼロ以外に設定されている場合、乱数ジェネレーターは指定されたseedによってシードされます。それ以外の場合は、ランダム シードによってシードされます。
  • シード2: シードの衝突を避けるための 2 番目のシード。
  • min_object_covered: 画像のトリミングされた領域には、指定された境界ボックスの少なくともこの部分が含まれている必要があります。このパラメータの値は負ではない必要があります。 0 の場合、トリミングされた領域は、指定された境界ボックスのいずれとも重なる必要はありません。
  • spect_ratio_range: 画像のトリミングされた領域のアスペクト比 = 幅 / 高さがこの範囲内である必要があります。
  • area_range: 画像のトリミングされた領域には、この範囲内の指定された画像の一部が含まれている必要があります。
  • max_attempts: 指定された制約の画像の切り取られた領域を生成する試行回数。 max_attempts回の失敗の後、イメージ全体を返します。
  • use_image_if_no_bounding_boxes: 境界ボックスが指定されていない場合の動作を制御します。 true の場合、入力全体をカバーする暗黙的な境界ボックスがあると見なされます。 false の場合、エラーが発生します。

戻り値:

  • Output開始: 1-D、 [offset_height, offset_width, 0]を含む。 tf.sliceへの入力として提供します。
  • Outputサイズ: 1-D、 [target_height, target_width, -1]を含みます。 tf.sliceへの入力として提供します。
  • Output bboxes: 歪んだ境界ボックスを含む形状[1, 1, 4]の 3-D。 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のオプションの属性セッター。

パブリック属性

Bボックス

::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
)

UseImageIfNoBoundingBoxes

Attrs UseImageIfNoBoundingBoxes(
  bool x
)