tensorflow:: אופס:: SampleDistortedBoundingBox

#include <image_ops.h>

צור תיבת תוחמת אחת מעוותת באופן אקראי עבור תמונה.

סיכום

הערות תיבות תוחמות מסופקות לעתים קרובות בנוסף לתוויות של אמת בבסיס במשימות זיהוי תמונות או לוקליזציה של אובייקטים. טכניקה נפוצה לאימון מערכת כזו היא עיוות אקראי של תמונה תוך שמירה על התוכן שלה, כלומר הגדלת נתונים . אופ זה מוציא לוקליזציה מעוותת אקראית של אובייקט, כלומר תיבה תוחמת, בהינתן image_size , bounding_boxes וסדרה של אילוצים.

הפלט של אופ זה הוא תיבה תוחמת אחת שניתן להשתמש בה כדי לחתוך את התמונה המקורית. הפלט מוחזר כ-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 הוא false ולא מסופקות תיבות תוחמות, מתעוררת שגיאה.

טיעונים:

  • scope: אובייקט Scope
  • image_size: 1-D, המכיל [height, width, channels] .
  • bounding_boxes: 3-D עם צורה [batch, N, 4] המתארת ​​את N התיבות התוחמות המשויכות לתמונה.

מאפיינים אופציונליים (ראה Attrs ):

  • seed: אם seed או seed2 מוגדרים לא-אפס, מחולל המספרים האקראיים מוזרע על ידי ה- seed הנתון. אחרת, הוא נזרע על ידי זרע אקראי.
  • seed2: זרע שני כדי למנוע התנגשות זרע.
  • min_object_covered: האזור החתוך של התמונה חייב להכיל לפחות חלק זה מכל תיבה תוחמת שסופקה. הערך של פרמטר זה צריך להיות לא שלילי. במקרה של 0, השטח החתוך אינו צריך לחפוף אף אחת מהתיבות התוחמות שסופקו.
  • aspect_ratio_range: לאזור החתוך של התמונה חייב להיות יחס גובה-רוחב = רוחב/גובה בטווח זה.
  • 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 .
  • Output bboxes: 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
)

מקסימום ניסיונות

Attrs MaxAttempts(
  int64 x
)

MinObjectCovered

Attrs MinObjectCovered(
  float x
)

זֶרַע

Attrs Seed(
  int64 x
)

זרע 2

Attrs Seed2(
  int64 x
)

UseImageIfNoBoundingBoxes

Attrs UseImageIfNoBoundingBoxes(
  bool x
)