เทนเซอร์โฟลว์ :: ops :: SampleDistortedBoundingBox
#include <image_ops.h>
สร้างกรอบขอบเขตที่บิดเบี้ยวแบบสุ่มสำหรับรูปภาพ
สรุป
คำอธิบายประกอบแบบ Bounding box มักมีให้เพิ่มเติมจากป้ายกำกับความจริงพื้นฐานในงานการจดจำรูปภาพหรืองานโลคัลไลเซชันออบเจ็กต์ เทคนิคทั่วไปในการฝึกอบรมระบบดังกล่าวคือการสุ่มบิดเบือนรูปภาพในขณะที่ยังคงรักษาเนื้อหาไว้เช่น การเพิ่มข้อมูล Op นี้แสดงผลการแปลที่ผิดเพี้ยนแบบสุ่มของวัตถุเช่นกล่องขอบเขตที่กำหนด image_size
, bounding_boxes
และชุดของข้อ จำกัด
ผลลัพธ์ของ Op นี้คือกล่องขอบเขตเดียวที่อาจใช้เพื่อครอบตัดรูปภาพต้นฉบับ เอาต์พุตจะถูกส่งคืนเป็น 3 เทนเซอร์: begin
size
และ bboxes
คุณสามารถป้อน tf.slice
2 ตัวแรกลงใน tf.slice
ได้โดยตรงเพื่อครอบตัดรูปภาพ หลังอาจถูกส่งไปยัง tf.image.draw_bounding_boxes
เพื่อให้เห็นภาพว่ากล่องขอบเขตมีลักษณะอย่างไร
กล่อง [y_min, x_min, y_max, x_max]
ถูกจัดส่งและส่งคืนเป็น [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
เป็นเท็จและไม่มีการกำหนดกรอบข้อผิดพลาดจะเกิดขึ้น
อาร์กิวเมนต์:
- ขอบเขต: วัตถุ ขอบเขต
- image_size: 1-D ประกอบด้วย
[height, width, channels]
- bounding_boxes: 3-D ที่มีรูปร่าง
[batch, N, 4]
อธิบายกล่องขอบเขต N ที่เกี่ยวข้องกับรูปภาพ
แอตทริบิวต์เสริม (ดู Attrs
):
- seed: ถ้า
seed
หรือseed2
ถูกตั้งค่าเป็น non-zero ตัวสร้างตัวเลขสุ่มจะถูกseed
โดยseed
กำหนด มิฉะนั้นจะเพาะเมล็ดโดยสุ่ม - seed2: เมล็ดพันธุ์ที่สองเพื่อหลีกเลี่ยงการชนกันของเมล็ด
- min_object_covered: พื้นที่ที่ครอบตัดของรูปภาพต้องมีเศษส่วนนี้อย่างน้อยที่สุดของกล่องขอบเขตที่ให้มา ค่าของพารามิเตอร์นี้ไม่ควรเป็นลบ ในกรณีของ 0 พื้นที่ที่ครอบตัดไม่จำเป็นต้องทับซ้อนกันของกล่องขอบเขตใด ๆ ที่ให้มา
- อัตราส่วนกว้างยาว: พื้นที่ที่ครอบตัดของรูปภาพต้องมีอัตราส่วนภาพ = ความกว้าง / ความสูงภายในช่วงนี้
- area_range: พื้นที่ที่ครอบตัดของรูปภาพต้องมีเศษเสี้ยวของภาพที่ให้มาภายในช่วงนี้
- max_attempts: จำนวนครั้งที่พยายามสร้างขอบเขตที่ครอบตัดของรูปภาพของข้อ จำกัด ที่ระบุ หลังจาก
max_attempts
ล้มเหลวให้ส่งคืนรูปภาพทั้งหมด - use_image_if_no_bounding_boxes: ควบคุมพฤติกรรมหากไม่มีกล่องขอบเขตที่ให้มา ถ้าเป็นจริงให้สมมติว่ามีกรอบขอบเขตโดยปริยายซึ่งครอบคลุมข้อมูลทั้งหมด หากเป็นเท็จให้เพิ่มข้อผิดพลาด
ผลตอบแทน:
- เริ่มต้น
Output
: 1-D ประกอบด้วย[offset_height, offset_width, 0]
ระบุเป็นอินพุตไปยังtf.slice
- ขนาด
Output
: 1-D ประกอบด้วย[target_height, target_width, -1]
ระบุเป็นอินพุตไปยังtf.slice
- bboxes
Output
: 3-D ที่มีรูปร่าง[1, 1, 4]
ที่มีกล่องขอบเขตบิดเบี้ยว ระบุเป็นอินพุตให้กับ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 )
เมล็ดพันธุ์ 2
Attrs Seed2( int64 x )
UseImageIfNoBoundingBoxes
Attrs UseImageIfNoBoundingBoxes( bool x )