aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/api_def/base_api/api_def_SampleDistortedBoundingBoxV2.pbtxt
blob: e9912609729fbadf7a3dd706903ecc4d915d72eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
op {
  graph_op_name: "SampleDistortedBoundingBoxV2"
  in_arg {
    name: "image_size"
    description: <<END
1-D, containing `[height, width, channels]`.
END
  }
  in_arg {
    name: "bounding_boxes"
    description: <<END
3-D with shape `[batch, N, 4]` describing the N bounding boxes
associated with the image.
END
  }
  in_arg {
    name: "min_object_covered"
    description: <<END
The cropped area of the image must contain at least this
fraction of any bounding box supplied. The value of this parameter should be
non-negative. In the case of 0, the cropped area does not need to overlap
any of the bounding boxes supplied.
END
  }
  out_arg {
    name: "begin"
    description: <<END
1-D, containing `[offset_height, offset_width, 0]`. Provide as input to
`tf.slice`.
END
  }
  out_arg {
    name: "size"
    description: <<END
1-D, containing `[target_height, target_width, -1]`. Provide as input to
`tf.slice`.
END
  }
  out_arg {
    name: "bboxes"
    description: <<END
3-D with shape `[1, 1, 4]` containing the distorted bounding box.
Provide as input to `tf.image.draw_bounding_boxes`.
END
  }
  attr {
    name: "seed"
    description: <<END
If either `seed` or `seed2` are set to non-zero, the random number
generator is seeded by the given `seed`.  Otherwise, it is seeded by a random
seed.
END
  }
  attr {
    name: "seed2"
    description: <<END
A second seed to avoid seed collision.
END
  }
  attr {
    name: "aspect_ratio_range"
    description: <<END
The cropped area of the image must have an aspect ratio =
width / height within this range.
END
  }
  attr {
    name: "area_range"
    description: <<END
The cropped area of the image must contain a fraction of the
supplied image within in this range.
END
  }
  attr {
    name: "max_attempts"
    description: <<END
Number of attempts at generating a cropped region of the image
of the specified constraints. After `max_attempts` failures, return the entire
image.
END
  }
  attr {
    name: "use_image_if_no_bounding_boxes"
    description: <<END
Controls behavior if no bounding boxes supplied.
If true, assume an implicit bounding box covering the whole input. If false,
raise an error.
END
  }
  summary: "Generate a single randomly distorted bounding box for an image."
  description: <<END
Bounding box annotations are often supplied in addition to ground-truth labels
in image recognition or object localization tasks. A common technique for
training such a system is to randomly distort an image while preserving
its content, i.e. *data augmentation*. This Op outputs a randomly distorted
localization of an object, i.e. bounding box, given an `image_size`,
`bounding_boxes` and a series of constraints.

The output of this Op is a single bounding box that may be used to crop the
original image. The output is returned as 3 tensors: `begin`, `size` and
`bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the
image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize
what the bounding box looks like.

Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The
bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and
height of the underlying image.

For example,

```python
    # 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.image_summary('images_with_box', image_with_box)

    # Employ the bounding box to distort the image.
    distorted_image = tf.slice(image, begin, size)
```

Note that if no bounding box information is available, setting
`use_image_if_no_bounding_boxes = true` will assume there is a single implicit
bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is
false and no bounding boxes are supplied, an error is raised.
END
}