tensorflow :: ops :: SampleDistortedBoundingBox
#include <image_ops.h>
画像に対してランダムに歪んだ単一の境界ボックスを生成します。
概要
境界ボックスの注釈は、画像認識またはオブジェクトのローカリゼーションタスクでグラウンドトゥルースラベルに加えて提供されることがよくあります。このようなシステムをトレーニングするための一般的な手法は、コンテンツを保持しながら画像をランダムに歪めることです。つまり、データの拡張です。このOpは、 image_size
、 bounding_boxes
、および一連の制約が与えられた場合に、オブジェクト、つまりバウンディングボックスのランダムに歪んだローカリゼーションを出力します。
このOpの出力は、元の画像をトリミングするために使用できる単一の境界ボックスです。出力は、 begin
、 size
、 bboxes
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]
を含み[height, width, channels]
。 - bounding_boxes:画像に関連付けられたN個の境界ボックスを表す形状
[batch, N, 4]
3D。
オプションの属性(参照Attrs
):
- 種子:いずれかの場合
seed
又はseed2
非ゼロに設定され、乱数発生器が所与によって播種されるseed
。それ以外の場合は、ランダムシードによってシードされます。 - seed2:シードの衝突を回避するための2番目のシード。
- min_object_covered:画像のトリミングされた領域には、指定された境界ボックスの少なくともこの部分が含まれている必要があります。このパラメーターの値は負でない必要があります。 0の場合、トリミングされた領域は、提供された境界ボックスのいずれとも重なる必要はありません。
- アスペクト比_範囲:画像のトリミングされた領域は、この範囲内のアスペクト比=幅/高さである必要があります。
- 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
bbox:歪んだ境界ボックスを含む形状[1, 1, 4]
1、1、4[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のオプションの属性セッター。 |
パブリック属性
bboxes
::tensorflow::Output bboxes
ベギン
::tensorflow::Output begin
操作
Operation operation
サイズ
::tensorflow::Output size
公の行事
SampleDistortedBoundingBox
SampleDistortedBoundingBox( const ::tensorflow::Scope & scope, ::tensorflow::Input image_size, ::tensorflow::Input bounding_boxes )
SampleDistortedBoundingBox
SampleDistortedBoundingBox( const ::tensorflow::Scope & scope, ::tensorflow::Input image_size, ::tensorflow::Input bounding_boxes, const SampleDistortedBoundingBox::Attrs & attrs )
パブリック静的関数
AreaRange
Attrs AreaRange( const gtl::ArraySlice< float > & x )
AspectRatioRange
Attrs AspectRatioRange( const gtl::ArraySlice< float > & x )
MaxAttempts
Attrs MaxAttempts( int64 x )
MinObjectCovered
Attrs MinObjectCovered( float x )
シード
Attrs Seed( int64 x )
Seed2
Attrs Seed2( int64 x )
UseImageIfNoBoundingBoxes
Attrs UseImageIfNoBoundingBoxes( bool x )