เทนเซอร์โฟลว์:: ปฏิบัติการ:: ตัวอย่าง DistortedBoundingBoxV2

#include <image_ops.h>

สร้างกรอบขอบที่บิดเบี้ยวแบบสุ่มกล่องเดียวสำหรับรูปภาพ

สรุป

คำอธิบายประกอบแบบ Bounding Box มักจะจัดเตรียมไว้นอกเหนือจากป้ายกำกับความเป็นจริงในการจดจำรูปภาพหรืองานการแปลวัตถุ เทคนิคทั่วไปในการฝึกระบบดังกล่าวคือการสุ่มบิดเบือนรูปภาพโดยยังคงรักษาเนื้อหาไว้ เช่น การเพิ่มข้อมูล Op นี้จะส่งเอาต์พุตการแปลวัตถุที่บิดเบี้ยวแบบสุ่ม เช่น bounding box โดยกำหนด image_size , bounding_boxes และชุดข้อจำกัด

ผลลัพธ์ของ Op นี้คือกล่องขอบเขตเดียวที่อาจใช้ในการครอบตัดรูปภาพต้นฉบับ เอาต์พุตจะถูกส่งกลับเป็น 3 เทนเซอร์: begin , size และ bboxes เทนเซอร์ 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 เป็นเท็จ และไม่มีการระบุกรอบขอบ แสดงว่าเกิดข้อผิดพลาด

ข้อโต้แย้ง:

  • ขอบเขต: วัตถุ ขอบเขต
  • image_size: 1-D ประกอบด้วย [height, width, channels]
  • bounding_boxes: 3-D ที่มีรูปร่าง [batch, N, 4] อธิบายกล่องขอบเขต N ที่เกี่ยวข้องกับรูปภาพ
  • min_object_covered: พื้นที่ครอบตัดของรูปภาพต้องมีเศษส่วนอย่างน้อยเท่านี้ของกรอบขอบเขตที่ให้มา ค่าของพารามิเตอร์นี้ไม่ควรเป็นค่าลบ ในกรณีของ 0 พื้นที่ที่ครอบตัดไม่จำเป็นต้องซ้อนทับกับกรอบขอบเขตใดๆ ที่ให้มา

แอ็ตทริบิวต์ทางเลือก (ดู Attrs ):

  • เมล็ด: หากเมล็ดใด seed หนึ่งหรือ seed2 ถูกตั้งค่าไม่เป็นศูนย์ ตัวสร้างตัวเลขสุ่มจะถูกเพาะโดย seed ที่กำหนด มิฉะนั้นจะถูกเพาะโดยเมล็ดแบบสุ่ม
  • seed2: เมล็ดที่สองเพื่อหลีกเลี่ยงการชนกันของเมล็ด
  • อัตราส่วนกว้างยาว: พื้นที่ครอบตัดของรูปภาพต้องมีอัตราส่วนกว้างยาว = ความกว้าง / ความสูงภายในช่วงนี้
  • 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
  • bbox Output : 3-D ที่มีรูปร่าง [1, 1, 4] มีขอบเขตที่บิดเบี้ยว ระบุเป็นอินพุตให้กับ tf.image.draw_bounding_boxes

ตัวสร้างและผู้ทำลาย

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

คุณลักษณะสาธารณะ

bboxes
begin
operation
size

ฟังก์ชันคงที่สาธารณะ

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

โครงสร้าง

เทนเซอร์โฟลว์ :: ops :: SampleDistortedBoundingBoxV2 :: Attrs

ตัวตั้งค่าแอ็ตทริบิวต์ทางเลือกสำหรับ SampleDistortedBoundingBoxV2

คุณลักษณะสาธารณะ

บีบ็อกซ์

::tensorflow::Output bboxes

เริ่ม

::tensorflow::Output begin

การดำเนินการ

Operation operation

ขนาด

::tensorflow::Output size

งานสาธารณะ

ตัวอย่าง DistortedBoundingBoxV2

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

ตัวอย่าง DistortedBoundingBoxV2

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

ฟังก์ชันคงที่สาธารณะ

พื้นที่ช่วง

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

อัตราส่วนภาพช่วง

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

ความพยายามสูงสุด

Attrs MaxAttempts(
  int64 x
)

เมล็ดพันธุ์

Attrs Seed(
  int64 x
)

เมล็ดพันธุ์2

Attrs Seed2(
  int64 x
)

UseImageIfNoBoundingBoxes

Attrs UseImageIfNoBoundingBoxes(
  bool x
)