1 | // This file is MACHINE GENERATED! Do not edit. |
2 | |
3 | #ifndef TENSORFLOW_CC_OPS_IMAGE_OPS_H_ |
4 | #define TENSORFLOW_CC_OPS_IMAGE_OPS_H_ |
5 | |
6 | // This file is MACHINE GENERATED! Do not edit. |
7 | |
8 | #include "tensorflow/cc/framework/ops.h" |
9 | #include "tensorflow/cc/framework/scope.h" |
10 | #include "tensorflow/core/framework/tensor.h" |
11 | #include "tensorflow/core/framework/tensor_shape.h" |
12 | #include "tensorflow/core/framework/types.h" |
13 | #include "tensorflow/core/lib/gtl/array_slice.h" |
14 | |
15 | namespace tensorflow { |
16 | namespace ops { |
17 | |
18 | /// @defgroup image_ops Image Ops |
19 | /// @{ |
20 | |
21 | /// Adjust the contrast of one or more images. |
22 | /// |
23 | /// `images` is a tensor of at least 3 dimensions. The last 3 dimensions are |
24 | /// interpreted as `[height, width, channels]`. The other dimensions only |
25 | /// represent a collection of images, such as `[batch, height, width, channels].` |
26 | /// |
27 | /// Contrast is adjusted independently for each channel of each image. |
28 | /// |
29 | /// For each channel, the Op first computes the mean of the image pixels in the |
30 | /// channel and then adjusts each component of each pixel to |
31 | /// `(x - mean) * contrast_factor + mean`. |
32 | /// |
33 | /// Args: |
34 | /// * scope: A Scope object |
35 | /// * images: Images to adjust. At least 3-D. |
36 | /// * contrast_factor: A float multiplier for adjusting contrast. |
37 | /// |
38 | /// Returns: |
39 | /// * `Output`: The contrast-adjusted image or images. |
40 | class AdjustContrast { |
41 | public: |
42 | AdjustContrast(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
43 | ::tensorflow::Input contrast_factor); |
44 | operator ::tensorflow::Output() const { return output; } |
45 | operator ::tensorflow::Input() const { return output; } |
46 | ::tensorflow::Node* node() const { return output.node(); } |
47 | |
48 | Operation operation; |
49 | ::tensorflow::Output output; |
50 | }; |
51 | |
52 | /// Adjust the hue of one or more images. |
53 | /// |
54 | /// `images` is a tensor of at least 3 dimensions. The last dimension is |
55 | /// interpreted as channels, and must be three. |
56 | /// |
57 | /// The input image is considered in the RGB colorspace. Conceptually, the RGB |
58 | /// colors are first mapped into HSV. A delta is then applied all the hue values, |
59 | /// and then remapped back to RGB colorspace. |
60 | /// |
61 | /// Args: |
62 | /// * scope: A Scope object |
63 | /// * images: Images to adjust. At least 3-D. |
64 | /// * delta: A float delta to add to the hue. |
65 | /// |
66 | /// Returns: |
67 | /// * `Output`: The hue-adjusted image or images. |
68 | class AdjustHue { |
69 | public: |
70 | AdjustHue(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
71 | ::tensorflow::Input delta); |
72 | operator ::tensorflow::Output() const { return output; } |
73 | operator ::tensorflow::Input() const { return output; } |
74 | ::tensorflow::Node* node() const { return output.node(); } |
75 | |
76 | Operation operation; |
77 | ::tensorflow::Output output; |
78 | }; |
79 | |
80 | /// Adjust the saturation of one or more images. |
81 | /// |
82 | /// `images` is a tensor of at least 3 dimensions. The last dimension is |
83 | /// interpreted as channels, and must be three. |
84 | /// |
85 | /// The input image is considered in the RGB colorspace. Conceptually, the RGB |
86 | /// colors are first mapped into HSV. A scale is then applied all the saturation |
87 | /// values, and then remapped back to RGB colorspace. |
88 | /// |
89 | /// Args: |
90 | /// * scope: A Scope object |
91 | /// * images: Images to adjust. At least 3-D. |
92 | /// * scale: A float scale to add to the saturation. |
93 | /// |
94 | /// Returns: |
95 | /// * `Output`: The hue-adjusted image or images. |
96 | class AdjustSaturation { |
97 | public: |
98 | AdjustSaturation(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
99 | ::tensorflow::Input scale); |
100 | operator ::tensorflow::Output() const { return output; } |
101 | operator ::tensorflow::Input() const { return output; } |
102 | ::tensorflow::Node* node() const { return output.node(); } |
103 | |
104 | Operation operation; |
105 | ::tensorflow::Output output; |
106 | }; |
107 | |
108 | /// Greedily selects a subset of bounding boxes in descending order of score, |
109 | /// |
110 | /// This operation performs non_max_suppression on the inputs per batch, across |
111 | /// all classes. |
112 | /// Prunes away boxes that have high intersection-over-union (IOU) overlap |
113 | /// with previously selected boxes. Bounding boxes are supplied as |
114 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
115 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
116 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
117 | /// is agnostic to where the origin is in the coordinate system. Also note that |
118 | /// this algorithm is invariant to orthogonal transformations and translations |
119 | /// of the coordinate system; thus translating or reflections of the coordinate |
120 | /// system result in the same boxes being selected by the algorithm. |
121 | /// The output of this operation is the final boxes, scores and classes tensor |
122 | /// returned after performing non_max_suppression. |
123 | /// |
124 | /// Args: |
125 | /// * scope: A Scope object |
126 | /// * boxes: A 4-D float tensor of shape `[batch_size, num_boxes, q, 4]`. If `q` is 1 then |
127 | /// same boxes are used for all classes otherwise, if `q` is equal to number of |
128 | /// classes, class-specific boxes are used. |
129 | /// * scores: A 3-D float tensor of shape `[batch_size, num_boxes, num_classes]` |
130 | /// representing a single score corresponding to each box (each row of boxes). |
131 | /// * max_output_size_per_class: A scalar integer tensor representing the maximum number of |
132 | /// boxes to be selected by non max suppression per class |
133 | /// * max_total_size: An int32 scalar representing the maximum number of boxes retained over all |
134 | /// classes. Note that setting this value to a large number may result in OOM error |
135 | /// depending on the system workload. |
136 | /// * iou_threshold: A 0-D float tensor representing the threshold for deciding whether |
137 | /// boxes overlap too much with respect to IOU. |
138 | /// * score_threshold: A 0-D float tensor representing the threshold for deciding when to remove |
139 | /// boxes based on score. |
140 | /// |
141 | /// Optional attributes (see `Attrs`): |
142 | /// * pad_per_class: If false, the output nmsed boxes, scores and classes |
143 | /// are padded/clipped to `max_total_size`. If true, the |
144 | /// output nmsed boxes, scores and classes are padded to be of length |
145 | /// `max_size_per_class`*`num_classes`, unless it exceeds `max_total_size` in |
146 | /// which case it is clipped to `max_total_size`. Defaults to false. |
147 | /// * clip_boxes: If true, assume the box coordinates are between [0, 1] and clip the output boxes |
148 | /// if they fall beyond [0, 1]. If false, do not do clipping and output the box |
149 | /// coordinates as it is. |
150 | /// |
151 | /// Returns: |
152 | /// * `Output` nmsed_boxes: A [batch_size, max_detections, 4] float32 tensor |
153 | /// containing the non-max suppressed boxes. |
154 | /// * `Output` nmsed_scores: A [batch_size, max_detections] float32 tensor |
155 | /// containing the scores for the boxes. |
156 | /// * `Output` nmsed_classes: A [batch_size, max_detections] float32 tensor |
157 | /// containing the classes for the boxes. |
158 | /// * `Output` valid_detections: A [batch_size] int32 tensor indicating the number of |
159 | /// valid detections per batch item. Only the top num_detections[i] entries in |
160 | /// nms_boxes[i], nms_scores[i] and nms_class[i] are valid. The rest of the |
161 | /// entries are zero paddings. |
162 | class CombinedNonMaxSuppression { |
163 | public: |
164 | /// Optional attribute setters for CombinedNonMaxSuppression |
165 | struct Attrs { |
166 | /// If false, the output nmsed boxes, scores and classes |
167 | /// are padded/clipped to `max_total_size`. If true, the |
168 | /// output nmsed boxes, scores and classes are padded to be of length |
169 | /// `max_size_per_class`*`num_classes`, unless it exceeds `max_total_size` in |
170 | /// which case it is clipped to `max_total_size`. Defaults to false. |
171 | /// |
172 | /// Defaults to false |
173 | TF_MUST_USE_RESULT Attrs PadPerClass(bool x) { |
174 | Attrs ret = *this; |
175 | ret.pad_per_class_ = x; |
176 | return ret; |
177 | } |
178 | |
179 | /// If true, assume the box coordinates are between [0, 1] and clip the output boxes |
180 | /// if they fall beyond [0, 1]. If false, do not do clipping and output the box |
181 | /// coordinates as it is. |
182 | /// |
183 | /// Defaults to true |
184 | TF_MUST_USE_RESULT Attrs ClipBoxes(bool x) { |
185 | Attrs ret = *this; |
186 | ret.clip_boxes_ = x; |
187 | return ret; |
188 | } |
189 | |
190 | bool pad_per_class_ = false; |
191 | bool clip_boxes_ = true; |
192 | }; |
193 | CombinedNonMaxSuppression(const ::tensorflow::Scope& scope, ::tensorflow::Input |
194 | boxes, ::tensorflow::Input scores, |
195 | ::tensorflow::Input max_output_size_per_class, |
196 | ::tensorflow::Input max_total_size, |
197 | ::tensorflow::Input iou_threshold, |
198 | ::tensorflow::Input score_threshold); |
199 | CombinedNonMaxSuppression(const ::tensorflow::Scope& scope, ::tensorflow::Input |
200 | boxes, ::tensorflow::Input scores, |
201 | ::tensorflow::Input max_output_size_per_class, |
202 | ::tensorflow::Input max_total_size, |
203 | ::tensorflow::Input iou_threshold, |
204 | ::tensorflow::Input score_threshold, const |
205 | CombinedNonMaxSuppression::Attrs& attrs); |
206 | |
207 | static Attrs PadPerClass(bool x) { |
208 | return Attrs().PadPerClass(x); |
209 | } |
210 | static Attrs ClipBoxes(bool x) { |
211 | return Attrs().ClipBoxes(x); |
212 | } |
213 | |
214 | Operation operation; |
215 | ::tensorflow::Output nmsed_boxes; |
216 | ::tensorflow::Output nmsed_scores; |
217 | ::tensorflow::Output nmsed_classes; |
218 | ::tensorflow::Output valid_detections; |
219 | }; |
220 | |
221 | /// Extracts crops from the input image tensor and resizes them. |
222 | /// |
223 | /// Extracts crops from the input image tensor and resizes them using bilinear |
224 | /// sampling or nearest neighbor sampling (possibly with aspect ratio change) to a |
225 | /// common output size specified by `crop_size`. This is more general than the |
226 | /// `crop_to_bounding_box` op which extracts a fixed size slice from the input image |
227 | /// and does not allow resizing or aspect ratio change. |
228 | /// |
229 | /// Returns a tensor with `crops` from the input `image` at positions defined at the |
230 | /// bounding box locations in `boxes`. The cropped boxes are all resized (with |
231 | /// bilinear or nearest neighbor interpolation) to a fixed |
232 | /// `size = [crop_height, crop_width]`. The result is a 4-D tensor |
233 | /// `[num_boxes, crop_height, crop_width, depth]`. The resizing is corner aligned. |
234 | /// In particular, if `boxes = [[0, 0, 1, 1]]`, the method will give identical |
235 | /// results to using `tf.image.resize_bilinear()` or |
236 | /// `tf.image.resize_nearest_neighbor()`(depends on the `method` argument) with |
237 | /// `align_corners=True`. |
238 | /// |
239 | /// Args: |
240 | /// * scope: A Scope object |
241 | /// * image: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. |
242 | /// Both `image_height` and `image_width` need to be positive. |
243 | /// * boxes: A 2-D tensor of shape `[num_boxes, 4]`. The `i`-th row of the tensor |
244 | /// specifies the coordinates of a box in the `box_ind[i]` image and is specified |
245 | /// in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of |
246 | /// `y` is mapped to the image coordinate at `y * (image_height - 1)`, so as the |
247 | /// `[0, 1]` interval of normalized image height is mapped to |
248 | /// `[0, image_height - 1]` in image height coordinates. We do allow `y1` > `y2`, in |
249 | /// which case the sampled crop is an up-down flipped version of the original |
250 | /// image. The width dimension is treated similarly. Normalized coordinates |
251 | /// outside the `[0, 1]` range are allowed, in which case we use |
252 | /// `extrapolation_value` to extrapolate the input image values. |
253 | /// * box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. |
254 | /// The value of `box_ind[i]` specifies the image that the `i`-th box refers to. |
255 | /// * crop_size: A 1-D tensor of 2 elements, `size = [crop_height, crop_width]`. All |
256 | /// cropped image patches are resized to this size. The aspect ratio of the image |
257 | /// content is not preserved. Both `crop_height` and `crop_width` need to be |
258 | /// positive. |
259 | /// |
260 | /// Optional attributes (see `Attrs`): |
261 | /// * method: A string specifying the sampling method for resizing. It can be either |
262 | /// `"bilinear"` or `"nearest"` and default to `"bilinear"`. Currently two sampling |
263 | /// methods are supported: Bilinear and Nearest Neighbor. |
264 | /// * extrapolation_value: Value used for extrapolation, when applicable. |
265 | /// |
266 | /// Returns: |
267 | /// * `Output`: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`. |
268 | class CropAndResize { |
269 | public: |
270 | /// Optional attribute setters for CropAndResize |
271 | struct Attrs { |
272 | /// A string specifying the sampling method for resizing. It can be either |
273 | /// `"bilinear"` or `"nearest"` and default to `"bilinear"`. Currently two sampling |
274 | /// methods are supported: Bilinear and Nearest Neighbor. |
275 | /// |
276 | /// Defaults to "bilinear" |
277 | TF_MUST_USE_RESULT Attrs Method(StringPiece x) { |
278 | Attrs ret = *this; |
279 | ret.method_ = x; |
280 | return ret; |
281 | } |
282 | |
283 | /// Value used for extrapolation, when applicable. |
284 | /// |
285 | /// Defaults to 0 |
286 | TF_MUST_USE_RESULT Attrs ExtrapolationValue(float x) { |
287 | Attrs ret = *this; |
288 | ret.extrapolation_value_ = x; |
289 | return ret; |
290 | } |
291 | |
292 | StringPiece method_ = "bilinear" ; |
293 | float extrapolation_value_ = 0.0f; |
294 | }; |
295 | CropAndResize(const ::tensorflow::Scope& scope, ::tensorflow::Input image, |
296 | ::tensorflow::Input boxes, ::tensorflow::Input box_ind, |
297 | ::tensorflow::Input crop_size); |
298 | CropAndResize(const ::tensorflow::Scope& scope, ::tensorflow::Input image, |
299 | ::tensorflow::Input boxes, ::tensorflow::Input box_ind, |
300 | ::tensorflow::Input crop_size, const CropAndResize::Attrs& attrs); |
301 | operator ::tensorflow::Output() const { return crops; } |
302 | operator ::tensorflow::Input() const { return crops; } |
303 | ::tensorflow::Node* node() const { return crops.node(); } |
304 | |
305 | static Attrs Method(StringPiece x) { |
306 | return Attrs().Method(x); |
307 | } |
308 | static Attrs ExtrapolationValue(float x) { |
309 | return Attrs().ExtrapolationValue(x); |
310 | } |
311 | |
312 | Operation operation; |
313 | ::tensorflow::Output crops; |
314 | }; |
315 | |
316 | /// Computes the gradient of the crop_and_resize op wrt the input boxes tensor. |
317 | /// |
318 | /// Args: |
319 | /// * scope: A Scope object |
320 | /// * grads: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`. |
321 | /// * image: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. |
322 | /// Both `image_height` and `image_width` need to be positive. |
323 | /// * boxes: A 2-D tensor of shape `[num_boxes, 4]`. The `i`-th row of the tensor |
324 | /// specifies the coordinates of a box in the `box_ind[i]` image and is specified |
325 | /// in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of |
326 | /// `y` is mapped to the image coordinate at `y * (image_height - 1)`, so as the |
327 | /// `[0, 1]` interval of normalized image height is mapped to |
328 | /// `[0, image_height - 1] in image height coordinates. We do allow y1 > y2, in |
329 | /// which case the sampled crop is an up-down flipped version of the original |
330 | /// image. The width dimension is treated similarly. Normalized coordinates |
331 | /// outside the `[0, 1]` range are allowed, in which case we use |
332 | /// `extrapolation_value` to extrapolate the input image values. |
333 | /// * box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. |
334 | /// The value of `box_ind[i]` specifies the image that the `i`-th box refers to. |
335 | /// |
336 | /// Optional attributes (see `Attrs`): |
337 | /// * method: A string specifying the interpolation method. Only 'bilinear' is |
338 | /// supported for now. |
339 | /// |
340 | /// Returns: |
341 | /// * `Output`: A 2-D tensor of shape `[num_boxes, 4]`. |
342 | class CropAndResizeGradBoxes { |
343 | public: |
344 | /// Optional attribute setters for CropAndResizeGradBoxes |
345 | struct Attrs { |
346 | /// A string specifying the interpolation method. Only 'bilinear' is |
347 | /// supported for now. |
348 | /// |
349 | /// Defaults to "bilinear" |
350 | TF_MUST_USE_RESULT Attrs Method(StringPiece x) { |
351 | Attrs ret = *this; |
352 | ret.method_ = x; |
353 | return ret; |
354 | } |
355 | |
356 | StringPiece method_ = "bilinear" ; |
357 | }; |
358 | CropAndResizeGradBoxes(const ::tensorflow::Scope& scope, ::tensorflow::Input |
359 | grads, ::tensorflow::Input image, ::tensorflow::Input |
360 | boxes, ::tensorflow::Input box_ind); |
361 | CropAndResizeGradBoxes(const ::tensorflow::Scope& scope, ::tensorflow::Input |
362 | grads, ::tensorflow::Input image, ::tensorflow::Input |
363 | boxes, ::tensorflow::Input box_ind, const |
364 | CropAndResizeGradBoxes::Attrs& attrs); |
365 | operator ::tensorflow::Output() const { return output; } |
366 | operator ::tensorflow::Input() const { return output; } |
367 | ::tensorflow::Node* node() const { return output.node(); } |
368 | |
369 | static Attrs Method(StringPiece x) { |
370 | return Attrs().Method(x); |
371 | } |
372 | |
373 | Operation operation; |
374 | ::tensorflow::Output output; |
375 | }; |
376 | |
377 | /// Computes the gradient of the crop_and_resize op wrt the input image tensor. |
378 | /// |
379 | /// Args: |
380 | /// * scope: A Scope object |
381 | /// * grads: A 4-D tensor of shape `[num_boxes, crop_height, crop_width, depth]`. |
382 | /// * boxes: A 2-D tensor of shape `[num_boxes, 4]`. The `i`-th row of the tensor |
383 | /// specifies the coordinates of a box in the `box_ind[i]` image and is specified |
384 | /// in normalized coordinates `[y1, x1, y2, x2]`. A normalized coordinate value of |
385 | /// `y` is mapped to the image coordinate at `y * (image_height - 1)`, so as the |
386 | /// `[0, 1]` interval of normalized image height is mapped to |
387 | /// `[0, image_height - 1] in image height coordinates. We do allow y1 > y2, in |
388 | /// which case the sampled crop is an up-down flipped version of the original |
389 | /// image. The width dimension is treated similarly. Normalized coordinates |
390 | /// outside the `[0, 1]` range are allowed, in which case we use |
391 | /// `extrapolation_value` to extrapolate the input image values. |
392 | /// * box_ind: A 1-D tensor of shape `[num_boxes]` with int32 values in `[0, batch)`. |
393 | /// The value of `box_ind[i]` specifies the image that the `i`-th box refers to. |
394 | /// * image_size: A 1-D tensor with value `[batch, image_height, image_width, depth]` |
395 | /// containing the original image size. Both `image_height` and `image_width` need |
396 | /// to be positive. |
397 | /// |
398 | /// Optional attributes (see `Attrs`): |
399 | /// * method: A string specifying the interpolation method. Only 'bilinear' is |
400 | /// supported for now. |
401 | /// |
402 | /// Returns: |
403 | /// * `Output`: A 4-D tensor of shape `[batch, image_height, image_width, depth]`. |
404 | class CropAndResizeGradImage { |
405 | public: |
406 | /// Optional attribute setters for CropAndResizeGradImage |
407 | struct Attrs { |
408 | /// A string specifying the interpolation method. Only 'bilinear' is |
409 | /// supported for now. |
410 | /// |
411 | /// Defaults to "bilinear" |
412 | TF_MUST_USE_RESULT Attrs Method(StringPiece x) { |
413 | Attrs ret = *this; |
414 | ret.method_ = x; |
415 | return ret; |
416 | } |
417 | |
418 | StringPiece method_ = "bilinear" ; |
419 | }; |
420 | CropAndResizeGradImage(const ::tensorflow::Scope& scope, ::tensorflow::Input |
421 | grads, ::tensorflow::Input boxes, ::tensorflow::Input |
422 | box_ind, ::tensorflow::Input image_size, DataType T); |
423 | CropAndResizeGradImage(const ::tensorflow::Scope& scope, ::tensorflow::Input |
424 | grads, ::tensorflow::Input boxes, ::tensorflow::Input |
425 | box_ind, ::tensorflow::Input image_size, DataType T, |
426 | const CropAndResizeGradImage::Attrs& attrs); |
427 | operator ::tensorflow::Output() const { return output; } |
428 | operator ::tensorflow::Input() const { return output; } |
429 | ::tensorflow::Node* node() const { return output.node(); } |
430 | |
431 | static Attrs Method(StringPiece x) { |
432 | return Attrs().Method(x); |
433 | } |
434 | |
435 | Operation operation; |
436 | ::tensorflow::Output output; |
437 | }; |
438 | |
439 | /// Decode and Crop a JPEG-encoded image to a uint8 tensor. |
440 | /// |
441 | /// The attr `channels` indicates the desired number of color channels for the |
442 | /// decoded image. |
443 | /// |
444 | /// Accepted values are: |
445 | /// |
446 | /// * 0: Use the number of channels in the JPEG-encoded image. |
447 | /// * 1: output a grayscale image. |
448 | /// * 3: output an RGB image. |
449 | /// |
450 | /// If needed, the JPEG-encoded image is transformed to match the requested number |
451 | /// of color channels. |
452 | /// |
453 | /// The attr `ratio` allows downscaling the image by an integer factor during |
454 | /// decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than |
455 | /// downscaling the image later. |
456 | /// |
457 | /// |
458 | /// It is equivalent to a combination of decode and crop, but much faster by only |
459 | /// decoding partial jpeg image. |
460 | /// |
461 | /// Args: |
462 | /// * scope: A Scope object |
463 | /// * contents: 0-D. The JPEG-encoded image. |
464 | /// * crop_window: 1-D. The crop window: [crop_y, crop_x, crop_height, crop_width]. |
465 | /// |
466 | /// Optional attributes (see `Attrs`): |
467 | /// * channels: Number of color channels for the decoded image. |
468 | /// * ratio: Downscaling ratio. |
469 | /// * fancy_upscaling: If true use a slower but nicer upscaling of the |
470 | /// chroma planes (yuv420/422 only). |
471 | /// * try_recover_truncated: If true try to recover an image from truncated input. |
472 | /// * acceptable_fraction: The minimum required fraction of lines before a truncated |
473 | /// input is accepted. |
474 | /// * dct_method: string specifying a hint about the algorithm used for |
475 | /// decompression. Defaults to "" which maps to a system-specific |
476 | /// default. Currently valid values are ["INTEGER_FAST", |
477 | /// "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal |
478 | /// jpeg library changes to a version that does not have that specific |
479 | /// option.) |
480 | /// |
481 | /// Returns: |
482 | /// * `Output`: 3-D with shape `[height, width, channels]`.. |
483 | class DecodeAndCropJpeg { |
484 | public: |
485 | /// Optional attribute setters for DecodeAndCropJpeg |
486 | struct Attrs { |
487 | /// Number of color channels for the decoded image. |
488 | /// |
489 | /// Defaults to 0 |
490 | TF_MUST_USE_RESULT Attrs Channels(int64 x) { |
491 | Attrs ret = *this; |
492 | ret.channels_ = x; |
493 | return ret; |
494 | } |
495 | |
496 | /// Downscaling ratio. |
497 | /// |
498 | /// Defaults to 1 |
499 | TF_MUST_USE_RESULT Attrs Ratio(int64 x) { |
500 | Attrs ret = *this; |
501 | ret.ratio_ = x; |
502 | return ret; |
503 | } |
504 | |
505 | /// If true use a slower but nicer upscaling of the |
506 | /// chroma planes (yuv420/422 only). |
507 | /// |
508 | /// Defaults to true |
509 | TF_MUST_USE_RESULT Attrs FancyUpscaling(bool x) { |
510 | Attrs ret = *this; |
511 | ret.fancy_upscaling_ = x; |
512 | return ret; |
513 | } |
514 | |
515 | /// If true try to recover an image from truncated input. |
516 | /// |
517 | /// Defaults to false |
518 | TF_MUST_USE_RESULT Attrs TryRecoverTruncated(bool x) { |
519 | Attrs ret = *this; |
520 | ret.try_recover_truncated_ = x; |
521 | return ret; |
522 | } |
523 | |
524 | /// The minimum required fraction of lines before a truncated |
525 | /// input is accepted. |
526 | /// |
527 | /// Defaults to 1 |
528 | TF_MUST_USE_RESULT Attrs AcceptableFraction(float x) { |
529 | Attrs ret = *this; |
530 | ret.acceptable_fraction_ = x; |
531 | return ret; |
532 | } |
533 | |
534 | /// string specifying a hint about the algorithm used for |
535 | /// decompression. Defaults to "" which maps to a system-specific |
536 | /// default. Currently valid values are ["INTEGER_FAST", |
537 | /// "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal |
538 | /// jpeg library changes to a version that does not have that specific |
539 | /// option.) |
540 | /// |
541 | /// Defaults to "" |
542 | TF_MUST_USE_RESULT Attrs DctMethod(StringPiece x) { |
543 | Attrs ret = *this; |
544 | ret.dct_method_ = x; |
545 | return ret; |
546 | } |
547 | |
548 | int64 channels_ = 0; |
549 | int64 ratio_ = 1; |
550 | bool fancy_upscaling_ = true; |
551 | bool try_recover_truncated_ = false; |
552 | float acceptable_fraction_ = 1.0f; |
553 | StringPiece dct_method_ = "" ; |
554 | }; |
555 | DecodeAndCropJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input |
556 | contents, ::tensorflow::Input crop_window); |
557 | DecodeAndCropJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input |
558 | contents, ::tensorflow::Input crop_window, const |
559 | DecodeAndCropJpeg::Attrs& attrs); |
560 | operator ::tensorflow::Output() const { return image; } |
561 | operator ::tensorflow::Input() const { return image; } |
562 | ::tensorflow::Node* node() const { return image.node(); } |
563 | |
564 | static Attrs Channels(int64 x) { |
565 | return Attrs().Channels(x); |
566 | } |
567 | static Attrs Ratio(int64 x) { |
568 | return Attrs().Ratio(x); |
569 | } |
570 | static Attrs FancyUpscaling(bool x) { |
571 | return Attrs().FancyUpscaling(x); |
572 | } |
573 | static Attrs TryRecoverTruncated(bool x) { |
574 | return Attrs().TryRecoverTruncated(x); |
575 | } |
576 | static Attrs AcceptableFraction(float x) { |
577 | return Attrs().AcceptableFraction(x); |
578 | } |
579 | static Attrs DctMethod(StringPiece x) { |
580 | return Attrs().DctMethod(x); |
581 | } |
582 | |
583 | Operation operation; |
584 | ::tensorflow::Output image; |
585 | }; |
586 | |
587 | /// Decode the first frame of a BMP-encoded image to a uint8 tensor. |
588 | /// |
589 | /// The attr `channels` indicates the desired number of color channels for the |
590 | /// decoded image. |
591 | /// |
592 | /// Accepted values are: |
593 | /// |
594 | /// * 0: Use the number of channels in the BMP-encoded image. |
595 | /// * 3: output an RGB image. |
596 | /// * 4: output an RGBA image. |
597 | /// |
598 | /// Args: |
599 | /// * scope: A Scope object |
600 | /// * contents: 0-D. The BMP-encoded image. |
601 | /// |
602 | /// Returns: |
603 | /// * `Output`: 3-D with shape `[height, width, channels]`. RGB order |
604 | class DecodeBmp { |
605 | public: |
606 | /// Optional attribute setters for DecodeBmp |
607 | struct Attrs { |
608 | /// Defaults to 0 |
609 | TF_MUST_USE_RESULT Attrs Channels(int64 x) { |
610 | Attrs ret = *this; |
611 | ret.channels_ = x; |
612 | return ret; |
613 | } |
614 | |
615 | int64 channels_ = 0; |
616 | }; |
617 | DecodeBmp(const ::tensorflow::Scope& scope, ::tensorflow::Input contents); |
618 | DecodeBmp(const ::tensorflow::Scope& scope, ::tensorflow::Input contents, const |
619 | DecodeBmp::Attrs& attrs); |
620 | operator ::tensorflow::Output() const { return image; } |
621 | operator ::tensorflow::Input() const { return image; } |
622 | ::tensorflow::Node* node() const { return image.node(); } |
623 | |
624 | static Attrs Channels(int64 x) { |
625 | return Attrs().Channels(x); |
626 | } |
627 | |
628 | Operation operation; |
629 | ::tensorflow::Output image; |
630 | }; |
631 | |
632 | /// Decode the frame(s) of a GIF-encoded image to a uint8 tensor. |
633 | /// |
634 | /// GIF images with frame or transparency compression are not supported. |
635 | /// On Linux and MacOS systems, convert animated GIFs from compressed to |
636 | /// uncompressed by running: |
637 | /// |
638 | /// convert $src.gif -coalesce $dst.gif |
639 | /// |
640 | /// This op also supports decoding JPEGs and PNGs, though it is cleaner to use |
641 | /// `tf.io.decode_image`. |
642 | /// |
643 | /// Args: |
644 | /// * scope: A Scope object |
645 | /// * contents: 0-D. The GIF-encoded image. |
646 | /// |
647 | /// Returns: |
648 | /// * `Output`: 4-D with shape `[num_frames, height, width, 3]`. RGB channel order. |
649 | class DecodeGif { |
650 | public: |
651 | DecodeGif(const ::tensorflow::Scope& scope, ::tensorflow::Input contents); |
652 | operator ::tensorflow::Output() const { return image; } |
653 | operator ::tensorflow::Input() const { return image; } |
654 | ::tensorflow::Node* node() const { return image.node(); } |
655 | |
656 | Operation operation; |
657 | ::tensorflow::Output image; |
658 | }; |
659 | |
660 | /// Function for decode_bmp, decode_gif, decode_jpeg, and decode_png. |
661 | /// |
662 | /// Detects whether an image is a BMP, GIF, JPEG, or PNG, and performs the |
663 | /// appropriate operation to convert the input bytes string into a Tensor of type |
664 | /// dtype. |
665 | /// |
666 | /// *NOTE*: decode_gif returns a 4-D array [num_frames, height, width, 3], as |
667 | /// opposed to decode_bmp, decode_jpeg and decode_png, which return 3-D arrays |
668 | /// [height, width, num_channels]. Make sure to take this into account when |
669 | /// constructing your graph if you are intermixing GIF files with BMP, JPEG, and/or |
670 | /// PNG files. Alternately, set the expand_animations argument of this function to |
671 | /// False, in which case the op will return 3-dimensional tensors and will truncate |
672 | /// animated GIF files to the first frame. |
673 | /// |
674 | /// *NOTE*: If the first frame of an animated GIF does not occupy the entire |
675 | /// canvas (maximum frame width x maximum frame height), then it fills the |
676 | /// unoccupied areas (in the first frame) with zeros (black). For frames after the |
677 | /// first frame that does not occupy the entire canvas, it uses the previous |
678 | /// frame to fill the unoccupied areas. |
679 | /// |
680 | /// Args: |
681 | /// * scope: A Scope object |
682 | /// * contents: 0-D. The encoded image bytes. |
683 | /// |
684 | /// Optional attributes (see `Attrs`): |
685 | /// * channels: Number of color channels for the decoded image. |
686 | /// * dtype: The desired DType of the returned Tensor. |
687 | /// * expand_animations: Controls the output shape of the returned op. If True, the returned op will |
688 | /// produce a 3-D tensor for PNG, JPEG, and BMP files; and a 4-D tensor for all |
689 | /// GIFs, whether animated or not. If, False, the returned op will produce a 3-D |
690 | /// tensor for all file types and will truncate animated GIFs to the first frame. |
691 | /// |
692 | /// Returns: |
693 | /// * `Output`: 3-D with shape `[height, width, channels]` or 4-D with shape |
694 | /// `[frame, height, width, channels]`.. |
695 | class DecodeImage { |
696 | public: |
697 | /// Optional attribute setters for DecodeImage |
698 | struct Attrs { |
699 | /// Number of color channels for the decoded image. |
700 | /// |
701 | /// Defaults to 0 |
702 | TF_MUST_USE_RESULT Attrs Channels(int64 x) { |
703 | Attrs ret = *this; |
704 | ret.channels_ = x; |
705 | return ret; |
706 | } |
707 | |
708 | /// The desired DType of the returned Tensor. |
709 | /// |
710 | /// Defaults to DT_UINT8 |
711 | TF_MUST_USE_RESULT Attrs Dtype(DataType x) { |
712 | Attrs ret = *this; |
713 | ret.dtype_ = x; |
714 | return ret; |
715 | } |
716 | |
717 | /// Controls the output shape of the returned op. If True, the returned op will |
718 | /// produce a 3-D tensor for PNG, JPEG, and BMP files; and a 4-D tensor for all |
719 | /// GIFs, whether animated or not. If, False, the returned op will produce a 3-D |
720 | /// tensor for all file types and will truncate animated GIFs to the first frame. |
721 | /// |
722 | /// Defaults to true |
723 | TF_MUST_USE_RESULT Attrs ExpandAnimations(bool x) { |
724 | Attrs ret = *this; |
725 | ret.expand_animations_ = x; |
726 | return ret; |
727 | } |
728 | |
729 | int64 channels_ = 0; |
730 | DataType dtype_ = DT_UINT8; |
731 | bool expand_animations_ = true; |
732 | }; |
733 | DecodeImage(const ::tensorflow::Scope& scope, ::tensorflow::Input contents); |
734 | DecodeImage(const ::tensorflow::Scope& scope, ::tensorflow::Input contents, |
735 | const DecodeImage::Attrs& attrs); |
736 | operator ::tensorflow::Output() const { return image; } |
737 | operator ::tensorflow::Input() const { return image; } |
738 | ::tensorflow::Node* node() const { return image.node(); } |
739 | |
740 | static Attrs Channels(int64 x) { |
741 | return Attrs().Channels(x); |
742 | } |
743 | static Attrs Dtype(DataType x) { |
744 | return Attrs().Dtype(x); |
745 | } |
746 | static Attrs ExpandAnimations(bool x) { |
747 | return Attrs().ExpandAnimations(x); |
748 | } |
749 | |
750 | Operation operation; |
751 | ::tensorflow::Output image; |
752 | }; |
753 | |
754 | /// Decode a JPEG-encoded image to a uint8 tensor. |
755 | /// |
756 | /// The attr `channels` indicates the desired number of color channels for the |
757 | /// decoded image. |
758 | /// |
759 | /// Accepted values are: |
760 | /// |
761 | /// * 0: Use the number of channels in the JPEG-encoded image. |
762 | /// * 1: output a grayscale image. |
763 | /// * 3: output an RGB image. |
764 | /// |
765 | /// If needed, the JPEG-encoded image is transformed to match the requested number |
766 | /// of color channels. |
767 | /// |
768 | /// The attr `ratio` allows downscaling the image by an integer factor during |
769 | /// decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than |
770 | /// downscaling the image later. |
771 | /// |
772 | /// |
773 | /// This op also supports decoding PNGs and non-animated GIFs since the interface is |
774 | /// the same, though it is cleaner to use `tf.io.decode_image`. |
775 | /// |
776 | /// Args: |
777 | /// * scope: A Scope object |
778 | /// * contents: 0-D. The JPEG-encoded image. |
779 | /// |
780 | /// Optional attributes (see `Attrs`): |
781 | /// * channels: Number of color channels for the decoded image. |
782 | /// * ratio: Downscaling ratio. |
783 | /// * fancy_upscaling: If true use a slower but nicer upscaling of the |
784 | /// chroma planes (yuv420/422 only). |
785 | /// * try_recover_truncated: If true try to recover an image from truncated input. |
786 | /// * acceptable_fraction: The minimum required fraction of lines before a truncated |
787 | /// input is accepted. |
788 | /// * dct_method: string specifying a hint about the algorithm used for |
789 | /// decompression. Defaults to "" which maps to a system-specific |
790 | /// default. Currently valid values are ["INTEGER_FAST", |
791 | /// "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal |
792 | /// jpeg library changes to a version that does not have that specific |
793 | /// option.) |
794 | /// |
795 | /// Returns: |
796 | /// * `Output`: 3-D with shape `[height, width, channels]`.. |
797 | class DecodeJpeg { |
798 | public: |
799 | /// Optional attribute setters for DecodeJpeg |
800 | struct Attrs { |
801 | /// Number of color channels for the decoded image. |
802 | /// |
803 | /// Defaults to 0 |
804 | TF_MUST_USE_RESULT Attrs Channels(int64 x) { |
805 | Attrs ret = *this; |
806 | ret.channels_ = x; |
807 | return ret; |
808 | } |
809 | |
810 | /// Downscaling ratio. |
811 | /// |
812 | /// Defaults to 1 |
813 | TF_MUST_USE_RESULT Attrs Ratio(int64 x) { |
814 | Attrs ret = *this; |
815 | ret.ratio_ = x; |
816 | return ret; |
817 | } |
818 | |
819 | /// If true use a slower but nicer upscaling of the |
820 | /// chroma planes (yuv420/422 only). |
821 | /// |
822 | /// Defaults to true |
823 | TF_MUST_USE_RESULT Attrs FancyUpscaling(bool x) { |
824 | Attrs ret = *this; |
825 | ret.fancy_upscaling_ = x; |
826 | return ret; |
827 | } |
828 | |
829 | /// If true try to recover an image from truncated input. |
830 | /// |
831 | /// Defaults to false |
832 | TF_MUST_USE_RESULT Attrs TryRecoverTruncated(bool x) { |
833 | Attrs ret = *this; |
834 | ret.try_recover_truncated_ = x; |
835 | return ret; |
836 | } |
837 | |
838 | /// The minimum required fraction of lines before a truncated |
839 | /// input is accepted. |
840 | /// |
841 | /// Defaults to 1 |
842 | TF_MUST_USE_RESULT Attrs AcceptableFraction(float x) { |
843 | Attrs ret = *this; |
844 | ret.acceptable_fraction_ = x; |
845 | return ret; |
846 | } |
847 | |
848 | /// string specifying a hint about the algorithm used for |
849 | /// decompression. Defaults to "" which maps to a system-specific |
850 | /// default. Currently valid values are ["INTEGER_FAST", |
851 | /// "INTEGER_ACCURATE"]. The hint may be ignored (e.g., the internal |
852 | /// jpeg library changes to a version that does not have that specific |
853 | /// option.) |
854 | /// |
855 | /// Defaults to "" |
856 | TF_MUST_USE_RESULT Attrs DctMethod(StringPiece x) { |
857 | Attrs ret = *this; |
858 | ret.dct_method_ = x; |
859 | return ret; |
860 | } |
861 | |
862 | int64 channels_ = 0; |
863 | int64 ratio_ = 1; |
864 | bool fancy_upscaling_ = true; |
865 | bool try_recover_truncated_ = false; |
866 | float acceptable_fraction_ = 1.0f; |
867 | StringPiece dct_method_ = "" ; |
868 | }; |
869 | DecodeJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input contents); |
870 | DecodeJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input contents, |
871 | const DecodeJpeg::Attrs& attrs); |
872 | operator ::tensorflow::Output() const { return image; } |
873 | operator ::tensorflow::Input() const { return image; } |
874 | ::tensorflow::Node* node() const { return image.node(); } |
875 | |
876 | static Attrs Channels(int64 x) { |
877 | return Attrs().Channels(x); |
878 | } |
879 | static Attrs Ratio(int64 x) { |
880 | return Attrs().Ratio(x); |
881 | } |
882 | static Attrs FancyUpscaling(bool x) { |
883 | return Attrs().FancyUpscaling(x); |
884 | } |
885 | static Attrs TryRecoverTruncated(bool x) { |
886 | return Attrs().TryRecoverTruncated(x); |
887 | } |
888 | static Attrs AcceptableFraction(float x) { |
889 | return Attrs().AcceptableFraction(x); |
890 | } |
891 | static Attrs DctMethod(StringPiece x) { |
892 | return Attrs().DctMethod(x); |
893 | } |
894 | |
895 | Operation operation; |
896 | ::tensorflow::Output image; |
897 | }; |
898 | |
899 | /// Decode a PNG-encoded image to a uint8 or uint16 tensor. |
900 | /// |
901 | /// The attr `channels` indicates the desired number of color channels for the |
902 | /// decoded image. |
903 | /// |
904 | /// Accepted values are: |
905 | /// |
906 | /// * 0: Use the number of channels in the PNG-encoded image. |
907 | /// * 1: output a grayscale image. |
908 | /// * 3: output an RGB image. |
909 | /// * 4: output an RGBA image. |
910 | /// |
911 | /// If needed, the PNG-encoded image is transformed to match the requested number |
912 | /// of color channels. |
913 | /// |
914 | /// This op also supports decoding JPEGs and non-animated GIFs since the interface |
915 | /// is the same, though it is cleaner to use `tf.io.decode_image`. |
916 | /// |
917 | /// Args: |
918 | /// * scope: A Scope object |
919 | /// * contents: 0-D. The PNG-encoded image. |
920 | /// |
921 | /// Optional attributes (see `Attrs`): |
922 | /// * channels: Number of color channels for the decoded image. |
923 | /// |
924 | /// Returns: |
925 | /// * `Output`: 3-D with shape `[height, width, channels]`. |
926 | class DecodePng { |
927 | public: |
928 | /// Optional attribute setters for DecodePng |
929 | struct Attrs { |
930 | /// Number of color channels for the decoded image. |
931 | /// |
932 | /// Defaults to 0 |
933 | TF_MUST_USE_RESULT Attrs Channels(int64 x) { |
934 | Attrs ret = *this; |
935 | ret.channels_ = x; |
936 | return ret; |
937 | } |
938 | |
939 | /// Defaults to DT_UINT8 |
940 | TF_MUST_USE_RESULT Attrs Dtype(DataType x) { |
941 | Attrs ret = *this; |
942 | ret.dtype_ = x; |
943 | return ret; |
944 | } |
945 | |
946 | int64 channels_ = 0; |
947 | DataType dtype_ = DT_UINT8; |
948 | }; |
949 | DecodePng(const ::tensorflow::Scope& scope, ::tensorflow::Input contents); |
950 | DecodePng(const ::tensorflow::Scope& scope, ::tensorflow::Input contents, const |
951 | DecodePng::Attrs& attrs); |
952 | operator ::tensorflow::Output() const { return image; } |
953 | operator ::tensorflow::Input() const { return image; } |
954 | ::tensorflow::Node* node() const { return image.node(); } |
955 | |
956 | static Attrs Channels(int64 x) { |
957 | return Attrs().Channels(x); |
958 | } |
959 | static Attrs Dtype(DataType x) { |
960 | return Attrs().Dtype(x); |
961 | } |
962 | |
963 | Operation operation; |
964 | ::tensorflow::Output image; |
965 | }; |
966 | |
967 | /// Draw bounding boxes on a batch of images. |
968 | /// |
969 | /// Outputs a copy of `images` but draws on top of the pixels zero or more bounding |
970 | /// boxes specified by the locations in `boxes`. The coordinates of the each |
971 | /// bounding box in `boxes` are encoded as `[y_min, x_min, y_max, x_max]`. The |
972 | /// bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and |
973 | /// height of the underlying image. |
974 | /// |
975 | /// For example, if an image is 100 x 200 pixels (height x width) and the bounding |
976 | /// box is `[0.1, 0.2, 0.5, 0.9]`, the upper-left and bottom-right coordinates of |
977 | /// the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates). |
978 | /// |
979 | /// Parts of the bounding box may fall outside the image. |
980 | /// |
981 | /// Args: |
982 | /// * scope: A Scope object |
983 | /// * images: 4-D with shape `[batch, height, width, depth]`. A batch of images. |
984 | /// * boxes: 3-D with shape `[batch, num_bounding_boxes, 4]` containing bounding |
985 | /// boxes. |
986 | /// |
987 | /// Returns: |
988 | /// * `Output`: 4-D with the same shape as `images`. The batch of input images with |
989 | /// bounding boxes drawn on the images. |
990 | class DrawBoundingBoxes { |
991 | public: |
992 | DrawBoundingBoxes(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
993 | ::tensorflow::Input boxes); |
994 | operator ::tensorflow::Output() const { return output; } |
995 | operator ::tensorflow::Input() const { return output; } |
996 | ::tensorflow::Node* node() const { return output.node(); } |
997 | |
998 | Operation operation; |
999 | ::tensorflow::Output output; |
1000 | }; |
1001 | |
1002 | /// Draw bounding boxes on a batch of images. |
1003 | /// |
1004 | /// Outputs a copy of `images` but draws on top of the pixels zero or more bounding |
1005 | /// boxes specified by the locations in `boxes`. The coordinates of the each |
1006 | /// bounding box in `boxes` are encoded as `[y_min, x_min, y_max, x_max]`. The |
1007 | /// bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and |
1008 | /// height of the underlying image. |
1009 | /// |
1010 | /// For example, if an image is 100 x 200 pixels (height x width) and the bounding |
1011 | /// box is `[0.1, 0.2, 0.5, 0.9]`, the upper-left and bottom-right coordinates of |
1012 | /// the bounding box will be `(40, 10)` to `(100, 50)` (in (x,y) coordinates). |
1013 | /// |
1014 | /// Parts of the bounding box may fall outside the image. |
1015 | /// |
1016 | /// Args: |
1017 | /// * scope: A Scope object |
1018 | /// * images: 4-D with shape `[batch, height, width, depth]`. A batch of images. |
1019 | /// * boxes: 3-D with shape `[batch, num_bounding_boxes, 4]` containing bounding |
1020 | /// boxes. |
1021 | /// * colors: 2-D. A list of RGBA colors to cycle through for the boxes. |
1022 | /// |
1023 | /// Returns: |
1024 | /// * `Output`: 4-D with the same shape as `images`. The batch of input images with |
1025 | /// bounding boxes drawn on the images. |
1026 | class DrawBoundingBoxesV2 { |
1027 | public: |
1028 | DrawBoundingBoxesV2(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1029 | images, ::tensorflow::Input boxes, ::tensorflow::Input |
1030 | colors); |
1031 | operator ::tensorflow::Output() const { return output; } |
1032 | operator ::tensorflow::Input() const { return output; } |
1033 | ::tensorflow::Node* node() const { return output.node(); } |
1034 | |
1035 | Operation operation; |
1036 | ::tensorflow::Output output; |
1037 | }; |
1038 | |
1039 | /// JPEG-encode an image. |
1040 | /// |
1041 | /// `image` is a 3-D uint8 Tensor of shape `[height, width, channels]`. |
1042 | /// |
1043 | /// The attr `format` can be used to override the color format of the encoded |
1044 | /// output. Values can be: |
1045 | /// |
1046 | /// * `''`: Use a default format based on the number of channels in the image. |
1047 | /// * `grayscale`: Output a grayscale JPEG image. The `channels` dimension |
1048 | /// of `image` must be 1. |
1049 | /// * `rgb`: Output an RGB JPEG image. The `channels` dimension |
1050 | /// of `image` must be 3. |
1051 | /// |
1052 | /// If `format` is not specified or is the empty string, a default format is picked |
1053 | /// in function of the number of channels in `image`: |
1054 | /// |
1055 | /// * 1: Output a grayscale image. |
1056 | /// * 3: Output an RGB image. |
1057 | /// |
1058 | /// Args: |
1059 | /// * scope: A Scope object |
1060 | /// * image: 3-D with shape `[height, width, channels]`. |
1061 | /// |
1062 | /// Optional attributes (see `Attrs`): |
1063 | /// * format: Per pixel image format. |
1064 | /// * quality: Quality of the compression from 0 to 100 (higher is better and slower). |
1065 | /// * progressive: If True, create a JPEG that loads progressively (coarse to fine). |
1066 | /// * optimize_size: If True, spend CPU/RAM to reduce size with no quality change. |
1067 | /// * chroma_downsampling: See http://en.wikipedia.org/wiki/Chroma_subsampling. |
1068 | /// * density_unit: Unit used to specify `x_density` and `y_density`: |
1069 | /// pixels per inch (`'in'`) or centimeter (`'cm'`). |
1070 | /// * x_density: Horizontal pixels per density unit. |
1071 | /// * y_density: Vertical pixels per density unit. |
1072 | /// * xmp_metadata: If not empty, embed this XMP metadata in the image header. |
1073 | /// |
1074 | /// Returns: |
1075 | /// * `Output`: 0-D. JPEG-encoded image. |
1076 | class EncodeJpeg { |
1077 | public: |
1078 | /// Optional attribute setters for EncodeJpeg |
1079 | struct Attrs { |
1080 | /// Per pixel image format. |
1081 | /// |
1082 | /// Defaults to "" |
1083 | TF_MUST_USE_RESULT Attrs Format(StringPiece x) { |
1084 | Attrs ret = *this; |
1085 | ret.format_ = x; |
1086 | return ret; |
1087 | } |
1088 | |
1089 | /// Quality of the compression from 0 to 100 (higher is better and slower). |
1090 | /// |
1091 | /// Defaults to 95 |
1092 | TF_MUST_USE_RESULT Attrs Quality(int64 x) { |
1093 | Attrs ret = *this; |
1094 | ret.quality_ = x; |
1095 | return ret; |
1096 | } |
1097 | |
1098 | /// If True, create a JPEG that loads progressively (coarse to fine). |
1099 | /// |
1100 | /// Defaults to false |
1101 | TF_MUST_USE_RESULT Attrs Progressive(bool x) { |
1102 | Attrs ret = *this; |
1103 | ret.progressive_ = x; |
1104 | return ret; |
1105 | } |
1106 | |
1107 | /// If True, spend CPU/RAM to reduce size with no quality change. |
1108 | /// |
1109 | /// Defaults to false |
1110 | TF_MUST_USE_RESULT Attrs OptimizeSize(bool x) { |
1111 | Attrs ret = *this; |
1112 | ret.optimize_size_ = x; |
1113 | return ret; |
1114 | } |
1115 | |
1116 | /// See http://en.wikipedia.org/wiki/Chroma_subsampling. |
1117 | /// |
1118 | /// Defaults to true |
1119 | TF_MUST_USE_RESULT Attrs ChromaDownsampling(bool x) { |
1120 | Attrs ret = *this; |
1121 | ret.chroma_downsampling_ = x; |
1122 | return ret; |
1123 | } |
1124 | |
1125 | /// Unit used to specify `x_density` and `y_density`: |
1126 | /// pixels per inch (`'in'`) or centimeter (`'cm'`). |
1127 | /// |
1128 | /// Defaults to "in" |
1129 | TF_MUST_USE_RESULT Attrs DensityUnit(StringPiece x) { |
1130 | Attrs ret = *this; |
1131 | ret.density_unit_ = x; |
1132 | return ret; |
1133 | } |
1134 | |
1135 | /// Horizontal pixels per density unit. |
1136 | /// |
1137 | /// Defaults to 300 |
1138 | TF_MUST_USE_RESULT Attrs XDensity(int64 x) { |
1139 | Attrs ret = *this; |
1140 | ret.x_density_ = x; |
1141 | return ret; |
1142 | } |
1143 | |
1144 | /// Vertical pixels per density unit. |
1145 | /// |
1146 | /// Defaults to 300 |
1147 | TF_MUST_USE_RESULT Attrs YDensity(int64 x) { |
1148 | Attrs ret = *this; |
1149 | ret.y_density_ = x; |
1150 | return ret; |
1151 | } |
1152 | |
1153 | /// If not empty, embed this XMP metadata in the image header. |
1154 | /// |
1155 | /// Defaults to "" |
1156 | TF_MUST_USE_RESULT Attrs XmpMetadata(StringPiece x) { |
1157 | Attrs ret = *this; |
1158 | ret.xmp_metadata_ = x; |
1159 | return ret; |
1160 | } |
1161 | |
1162 | StringPiece format_ = "" ; |
1163 | int64 quality_ = 95; |
1164 | bool progressive_ = false; |
1165 | bool optimize_size_ = false; |
1166 | bool chroma_downsampling_ = true; |
1167 | StringPiece density_unit_ = "in" ; |
1168 | int64 x_density_ = 300; |
1169 | int64 y_density_ = 300; |
1170 | StringPiece xmp_metadata_ = "" ; |
1171 | }; |
1172 | EncodeJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input image); |
1173 | EncodeJpeg(const ::tensorflow::Scope& scope, ::tensorflow::Input image, const |
1174 | EncodeJpeg::Attrs& attrs); |
1175 | operator ::tensorflow::Output() const { return contents; } |
1176 | operator ::tensorflow::Input() const { return contents; } |
1177 | ::tensorflow::Node* node() const { return contents.node(); } |
1178 | |
1179 | static Attrs Format(StringPiece x) { |
1180 | return Attrs().Format(x); |
1181 | } |
1182 | static Attrs Quality(int64 x) { |
1183 | return Attrs().Quality(x); |
1184 | } |
1185 | static Attrs Progressive(bool x) { |
1186 | return Attrs().Progressive(x); |
1187 | } |
1188 | static Attrs OptimizeSize(bool x) { |
1189 | return Attrs().OptimizeSize(x); |
1190 | } |
1191 | static Attrs ChromaDownsampling(bool x) { |
1192 | return Attrs().ChromaDownsampling(x); |
1193 | } |
1194 | static Attrs DensityUnit(StringPiece x) { |
1195 | return Attrs().DensityUnit(x); |
1196 | } |
1197 | static Attrs XDensity(int64 x) { |
1198 | return Attrs().XDensity(x); |
1199 | } |
1200 | static Attrs YDensity(int64 x) { |
1201 | return Attrs().YDensity(x); |
1202 | } |
1203 | static Attrs XmpMetadata(StringPiece x) { |
1204 | return Attrs().XmpMetadata(x); |
1205 | } |
1206 | |
1207 | Operation operation; |
1208 | ::tensorflow::Output contents; |
1209 | }; |
1210 | |
1211 | /// JPEG encode input image with provided compression quality. |
1212 | /// |
1213 | /// `image` is a 3-D uint8 Tensor of shape `[height, width, channels]`. |
1214 | /// `quality` is an int32 jpeg compression quality value between 0 and 100. |
1215 | /// |
1216 | /// |
1217 | /// Args: |
1218 | /// * scope: A Scope object |
1219 | /// * images: Images to adjust. At least 3-D. |
1220 | /// * quality: An int quality to encode to. |
1221 | /// |
1222 | /// Returns: |
1223 | /// * `Output`: 0-D. JPEG-encoded image. |
1224 | class EncodeJpegVariableQuality { |
1225 | public: |
1226 | EncodeJpegVariableQuality(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1227 | images, ::tensorflow::Input quality); |
1228 | operator ::tensorflow::Output() const { return contents; } |
1229 | operator ::tensorflow::Input() const { return contents; } |
1230 | ::tensorflow::Node* node() const { return contents.node(); } |
1231 | |
1232 | Operation operation; |
1233 | ::tensorflow::Output contents; |
1234 | }; |
1235 | |
1236 | /// PNG-encode an image. |
1237 | /// |
1238 | /// `image` is a 3-D uint8 or uint16 Tensor of shape `[height, width, channels]` |
1239 | /// where `channels` is: |
1240 | /// |
1241 | /// * 1: for grayscale. |
1242 | /// * 2: for grayscale + alpha. |
1243 | /// * 3: for RGB. |
1244 | /// * 4: for RGBA. |
1245 | /// |
1246 | /// The ZLIB compression level, `compression`, can be -1 for the PNG-encoder |
1247 | /// default or a value from 0 to 9. 9 is the highest compression level, generating |
1248 | /// the smallest output, but is slower. |
1249 | /// |
1250 | /// Args: |
1251 | /// * scope: A Scope object |
1252 | /// * image: 3-D with shape `[height, width, channels]`. |
1253 | /// |
1254 | /// Optional attributes (see `Attrs`): |
1255 | /// * compression: Compression level. |
1256 | /// |
1257 | /// Returns: |
1258 | /// * `Output`: 0-D. PNG-encoded image. |
1259 | class EncodePng { |
1260 | public: |
1261 | /// Optional attribute setters for EncodePng |
1262 | struct Attrs { |
1263 | /// Compression level. |
1264 | /// |
1265 | /// Defaults to -1 |
1266 | TF_MUST_USE_RESULT Attrs Compression(int64 x) { |
1267 | Attrs ret = *this; |
1268 | ret.compression_ = x; |
1269 | return ret; |
1270 | } |
1271 | |
1272 | int64 compression_ = -1; |
1273 | }; |
1274 | EncodePng(const ::tensorflow::Scope& scope, ::tensorflow::Input image); |
1275 | EncodePng(const ::tensorflow::Scope& scope, ::tensorflow::Input image, const |
1276 | EncodePng::Attrs& attrs); |
1277 | operator ::tensorflow::Output() const { return contents; } |
1278 | operator ::tensorflow::Input() const { return contents; } |
1279 | ::tensorflow::Node* node() const { return contents.node(); } |
1280 | |
1281 | static Attrs Compression(int64 x) { |
1282 | return Attrs().Compression(x); |
1283 | } |
1284 | |
1285 | Operation operation; |
1286 | ::tensorflow::Output contents; |
1287 | }; |
1288 | |
1289 | /// Extracts a glimpse from the input tensor. |
1290 | /// |
1291 | /// Returns a set of windows called glimpses extracted at location |
1292 | /// `offsets` from the input tensor. If the windows only partially |
1293 | /// overlaps the inputs, the non overlapping areas will be filled with |
1294 | /// random noise. |
1295 | /// |
1296 | /// The result is a 4-D tensor of shape `[batch_size, glimpse_height, |
1297 | /// glimpse_width, channels]`. The channels and batch dimensions are the |
1298 | /// same as that of the input tensor. The height and width of the output |
1299 | /// windows are specified in the `size` parameter. |
1300 | /// |
1301 | /// The argument `normalized` and `centered` controls how the windows are built: |
1302 | /// |
1303 | /// * If the coordinates are normalized but not centered, 0.0 and 1.0 |
1304 | /// correspond to the minimum and maximum of each height and width |
1305 | /// dimension. |
1306 | /// * If the coordinates are both normalized and centered, they range from |
1307 | /// -1.0 to 1.0. The coordinates (-1.0, -1.0) correspond to the upper |
1308 | /// left corner, the lower right corner is located at (1.0, 1.0) and the |
1309 | /// center is at (0, 0). |
1310 | /// * If the coordinates are not normalized they are interpreted as |
1311 | /// numbers of pixels. |
1312 | /// |
1313 | /// Args: |
1314 | /// * scope: A Scope object |
1315 | /// * input: A 4-D float tensor of shape `[batch_size, height, width, channels]`. |
1316 | /// * size: A 1-D tensor of 2 elements containing the size of the glimpses |
1317 | /// to extract. The glimpse height must be specified first, following |
1318 | /// by the glimpse width. |
1319 | /// * offsets: A 2-D integer tensor of shape `[batch_size, 2]` containing |
1320 | /// the y, x locations of the center of each window. |
1321 | /// |
1322 | /// Optional attributes (see `Attrs`): |
1323 | /// * centered: indicates if the offset coordinates are centered relative to |
1324 | /// the image, in which case the (0, 0) offset is relative to the center |
1325 | /// of the input images. If false, the (0,0) offset corresponds to the |
1326 | /// upper left corner of the input images. |
1327 | /// * normalized: indicates if the offset coordinates are normalized. |
1328 | /// * uniform_noise: indicates if the noise should be generated using a |
1329 | /// uniform distribution or a Gaussian distribution. |
1330 | /// * noise: indicates if the noise should `uniform`, `gaussian`, or |
1331 | /// `zero`. The default is `uniform` which means the noise type |
1332 | /// will be decided by `uniform_noise`. |
1333 | /// |
1334 | /// Returns: |
1335 | /// * `Output`: A tensor representing the glimpses `[batch_size, |
1336 | /// glimpse_height, glimpse_width, channels]`. |
1337 | class { |
1338 | public: |
1339 | /// Optional attribute setters for ExtractGlimpse |
1340 | struct { |
1341 | /// indicates if the offset coordinates are centered relative to |
1342 | /// the image, in which case the (0, 0) offset is relative to the center |
1343 | /// of the input images. If false, the (0,0) offset corresponds to the |
1344 | /// upper left corner of the input images. |
1345 | /// |
1346 | /// Defaults to true |
1347 | TF_MUST_USE_RESULT Attrs (bool x) { |
1348 | Attrs ret = *this; |
1349 | ret.centered_ = x; |
1350 | return ret; |
1351 | } |
1352 | |
1353 | /// indicates if the offset coordinates are normalized. |
1354 | /// |
1355 | /// Defaults to true |
1356 | TF_MUST_USE_RESULT Attrs (bool x) { |
1357 | Attrs ret = *this; |
1358 | ret.normalized_ = x; |
1359 | return ret; |
1360 | } |
1361 | |
1362 | /// indicates if the noise should be generated using a |
1363 | /// uniform distribution or a Gaussian distribution. |
1364 | /// |
1365 | /// Defaults to true |
1366 | TF_MUST_USE_RESULT Attrs (bool x) { |
1367 | Attrs ret = *this; |
1368 | ret.uniform_noise_ = x; |
1369 | return ret; |
1370 | } |
1371 | |
1372 | /// indicates if the noise should `uniform`, `gaussian`, or |
1373 | /// `zero`. The default is `uniform` which means the noise type |
1374 | /// will be decided by `uniform_noise`. |
1375 | /// |
1376 | /// Defaults to "uniform" |
1377 | TF_MUST_USE_RESULT Attrs (StringPiece x) { |
1378 | Attrs ret = *this; |
1379 | ret.noise_ = x; |
1380 | return ret; |
1381 | } |
1382 | |
1383 | bool = true; |
1384 | bool = true; |
1385 | bool = true; |
1386 | StringPiece = "uniform" ; |
1387 | }; |
1388 | (const ::tensorflow::Scope& scope, ::tensorflow::Input input, |
1389 | ::tensorflow::Input size, ::tensorflow::Input offsets); |
1390 | (const ::tensorflow::Scope& scope, ::tensorflow::Input input, |
1391 | ::tensorflow::Input size, ::tensorflow::Input offsets, const |
1392 | ExtractGlimpse::Attrs& attrs); |
1393 | () const { return glimpse; } |
1394 | () const { return glimpse; } |
1395 | ::tensorflow::Node* () const { return glimpse.node(); } |
1396 | |
1397 | static Attrs (bool x) { |
1398 | return Attrs().Centered(x); |
1399 | } |
1400 | static Attrs (bool x) { |
1401 | return Attrs().Normalized(x); |
1402 | } |
1403 | static Attrs (bool x) { |
1404 | return Attrs().UniformNoise(x); |
1405 | } |
1406 | static Attrs (StringPiece x) { |
1407 | return Attrs().Noise(x); |
1408 | } |
1409 | |
1410 | Operation ; |
1411 | ::tensorflow::Output ; |
1412 | }; |
1413 | |
1414 | /// Extract the shape information of a JPEG-encoded image. |
1415 | /// |
1416 | /// This op only parses the image header, so it is much faster than DecodeJpeg. |
1417 | /// |
1418 | /// Args: |
1419 | /// * scope: A Scope object |
1420 | /// * contents: 0-D. The JPEG-encoded image. |
1421 | /// |
1422 | /// Optional attributes (see `Attrs`): |
1423 | /// * output_type: (Optional) The output type of the operation (int32 or int64). |
1424 | /// Defaults to int32. |
1425 | /// |
1426 | /// Returns: |
1427 | /// * `Output`: 1-D. The image shape with format [height, width, channels]. |
1428 | class { |
1429 | public: |
1430 | /// Optional attribute setters for ExtractJpegShape |
1431 | struct { |
1432 | /// (Optional) The output type of the operation (int32 or int64). |
1433 | /// Defaults to int32. |
1434 | /// |
1435 | /// Defaults to DT_INT32 |
1436 | TF_MUST_USE_RESULT Attrs (DataType x) { |
1437 | Attrs ret = *this; |
1438 | ret.output_type_ = x; |
1439 | return ret; |
1440 | } |
1441 | |
1442 | DataType = DT_INT32; |
1443 | }; |
1444 | (const ::tensorflow::Scope& scope, ::tensorflow::Input |
1445 | contents); |
1446 | (const ::tensorflow::Scope& scope, ::tensorflow::Input |
1447 | contents, const ExtractJpegShape::Attrs& attrs); |
1448 | () const { return image_shape; } |
1449 | () const { return image_shape; } |
1450 | ::tensorflow::Node* () const { return image_shape.node(); } |
1451 | |
1452 | static Attrs (DataType x) { |
1453 | return Attrs().OutputType(x); |
1454 | } |
1455 | |
1456 | Operation ; |
1457 | ::tensorflow::Output ; |
1458 | }; |
1459 | |
1460 | /// Convert one or more images from HSV to RGB. |
1461 | /// |
1462 | /// Outputs a tensor of the same shape as the `images` tensor, containing the RGB |
1463 | /// value of the pixels. The output is only well defined if the value in `images` |
1464 | /// are in `[0,1]`. |
1465 | /// |
1466 | /// See `rgb_to_hsv` for a description of the HSV encoding. |
1467 | /// |
1468 | /// Args: |
1469 | /// * scope: A Scope object |
1470 | /// * images: 1-D or higher rank. HSV data to convert. Last dimension must be size 3. |
1471 | /// |
1472 | /// Returns: |
1473 | /// * `Output`: `images` converted to RGB. |
1474 | class HSVToRGB { |
1475 | public: |
1476 | HSVToRGB(const ::tensorflow::Scope& scope, ::tensorflow::Input images); |
1477 | operator ::tensorflow::Output() const { return output; } |
1478 | operator ::tensorflow::Input() const { return output; } |
1479 | ::tensorflow::Node* node() const { return output.node(); } |
1480 | |
1481 | Operation operation; |
1482 | ::tensorflow::Output output; |
1483 | }; |
1484 | |
1485 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1486 | /// |
1487 | /// pruning away boxes that have high intersection-over-union (IOU) overlap |
1488 | /// with previously selected boxes. Bounding boxes are supplied as |
1489 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
1490 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
1491 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
1492 | /// is agnostic to where the origin is in the coordinate system. Note that this |
1493 | /// algorithm is invariant to orthogonal transformations and translations |
1494 | /// of the coordinate system; thus translating or reflections of the coordinate |
1495 | /// system result in the same boxes being selected by the algorithm. |
1496 | /// The output of this operation is a set of integers indexing into the input |
1497 | /// collection of bounding boxes representing the selected boxes. The bounding |
1498 | /// box coordinates corresponding to the selected indices can then be obtained |
1499 | /// using the `tf.gather operation`. For example: |
1500 | /// selected_indices = tf.image.non_max_suppression( |
1501 | /// boxes, scores, max_output_size, iou_threshold) |
1502 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1503 | /// |
1504 | /// Args: |
1505 | /// * scope: A Scope object |
1506 | /// * boxes: A 2-D float tensor of shape `[num_boxes, 4]`. |
1507 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1508 | /// score corresponding to each box (each row of boxes). |
1509 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1510 | /// boxes to be selected by non max suppression. |
1511 | /// |
1512 | /// Optional attributes (see `Attrs`): |
1513 | /// * iou_threshold: A float representing the threshold for deciding whether boxes |
1514 | /// overlap too much with respect to IOU. |
1515 | /// |
1516 | /// Returns: |
1517 | /// * `Output`: A 1-D integer tensor of shape `[M]` representing the selected |
1518 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1519 | class NonMaxSuppression { |
1520 | public: |
1521 | /// Optional attribute setters for NonMaxSuppression |
1522 | struct Attrs { |
1523 | /// A float representing the threshold for deciding whether boxes |
1524 | /// overlap too much with respect to IOU. |
1525 | /// |
1526 | /// Defaults to 0.5 |
1527 | TF_MUST_USE_RESULT Attrs IouThreshold(float x) { |
1528 | Attrs ret = *this; |
1529 | ret.iou_threshold_ = x; |
1530 | return ret; |
1531 | } |
1532 | |
1533 | float iou_threshold_ = 0.5f; |
1534 | }; |
1535 | NonMaxSuppression(const ::tensorflow::Scope& scope, ::tensorflow::Input boxes, |
1536 | ::tensorflow::Input scores, ::tensorflow::Input |
1537 | max_output_size); |
1538 | NonMaxSuppression(const ::tensorflow::Scope& scope, ::tensorflow::Input boxes, |
1539 | ::tensorflow::Input scores, ::tensorflow::Input |
1540 | max_output_size, const NonMaxSuppression::Attrs& attrs); |
1541 | operator ::tensorflow::Output() const { return selected_indices; } |
1542 | operator ::tensorflow::Input() const { return selected_indices; } |
1543 | ::tensorflow::Node* node() const { return selected_indices.node(); } |
1544 | |
1545 | static Attrs IouThreshold(float x) { |
1546 | return Attrs().IouThreshold(x); |
1547 | } |
1548 | |
1549 | Operation operation; |
1550 | ::tensorflow::Output selected_indices; |
1551 | }; |
1552 | |
1553 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1554 | /// |
1555 | /// pruning away boxes that have high intersection-over-union (IOU) overlap |
1556 | /// with previously selected boxes. Bounding boxes are supplied as |
1557 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
1558 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
1559 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
1560 | /// is agnostic to where the origin is in the coordinate system. Note that this |
1561 | /// algorithm is invariant to orthogonal transformations and translations |
1562 | /// of the coordinate system; thus translating or reflections of the coordinate |
1563 | /// system result in the same boxes being selected by the algorithm. |
1564 | /// |
1565 | /// The output of this operation is a set of integers indexing into the input |
1566 | /// collection of bounding boxes representing the selected boxes. The bounding |
1567 | /// box coordinates corresponding to the selected indices can then be obtained |
1568 | /// using the `tf.gather operation`. For example: |
1569 | /// |
1570 | /// selected_indices = tf.image.non_max_suppression_v2( |
1571 | /// boxes, scores, max_output_size, iou_threshold) |
1572 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1573 | /// |
1574 | /// Args: |
1575 | /// * scope: A Scope object |
1576 | /// * boxes: A 2-D float tensor of shape `[num_boxes, 4]`. |
1577 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1578 | /// score corresponding to each box (each row of boxes). |
1579 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1580 | /// boxes to be selected by non max suppression. |
1581 | /// * iou_threshold: A 0-D float tensor representing the threshold for deciding whether |
1582 | /// boxes overlap too much with respect to IOU. |
1583 | /// |
1584 | /// Returns: |
1585 | /// * `Output`: A 1-D integer tensor of shape `[M]` representing the selected |
1586 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1587 | class NonMaxSuppressionV2 { |
1588 | public: |
1589 | NonMaxSuppressionV2(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1590 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1591 | max_output_size, ::tensorflow::Input iou_threshold); |
1592 | operator ::tensorflow::Output() const { return selected_indices; } |
1593 | operator ::tensorflow::Input() const { return selected_indices; } |
1594 | ::tensorflow::Node* node() const { return selected_indices.node(); } |
1595 | |
1596 | Operation operation; |
1597 | ::tensorflow::Output selected_indices; |
1598 | }; |
1599 | |
1600 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1601 | /// |
1602 | /// pruning away boxes that have high intersection-over-union (IOU) overlap |
1603 | /// with previously selected boxes. Bounding boxes with score less than |
1604 | /// `score_threshold` are removed. Bounding boxes are supplied as |
1605 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
1606 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
1607 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
1608 | /// is agnostic to where the origin is in the coordinate system and more |
1609 | /// generally is invariant to orthogonal transformations and translations |
1610 | /// of the coordinate system; thus translating or reflections of the coordinate |
1611 | /// system result in the same boxes being selected by the algorithm. |
1612 | /// The output of this operation is a set of integers indexing into the input |
1613 | /// collection of bounding boxes representing the selected boxes. The bounding |
1614 | /// box coordinates corresponding to the selected indices can then be obtained |
1615 | /// using the `tf.gather operation`. For example: |
1616 | /// selected_indices = tf.image.non_max_suppression_v2( |
1617 | /// boxes, scores, max_output_size, iou_threshold, score_threshold) |
1618 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1619 | /// |
1620 | /// Args: |
1621 | /// * scope: A Scope object |
1622 | /// * boxes: A 2-D float tensor of shape `[num_boxes, 4]`. |
1623 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1624 | /// score corresponding to each box (each row of boxes). |
1625 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1626 | /// boxes to be selected by non max suppression. |
1627 | /// * iou_threshold: A 0-D float tensor representing the threshold for deciding whether |
1628 | /// boxes overlap too much with respect to IOU. |
1629 | /// * score_threshold: A 0-D float tensor representing the threshold for deciding when to remove |
1630 | /// boxes based on score. |
1631 | /// |
1632 | /// Returns: |
1633 | /// * `Output`: A 1-D integer tensor of shape `[M]` representing the selected |
1634 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1635 | class NonMaxSuppressionV3 { |
1636 | public: |
1637 | NonMaxSuppressionV3(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1638 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1639 | max_output_size, ::tensorflow::Input iou_threshold, |
1640 | ::tensorflow::Input score_threshold); |
1641 | operator ::tensorflow::Output() const { return selected_indices; } |
1642 | operator ::tensorflow::Input() const { return selected_indices; } |
1643 | ::tensorflow::Node* node() const { return selected_indices.node(); } |
1644 | |
1645 | Operation operation; |
1646 | ::tensorflow::Output selected_indices; |
1647 | }; |
1648 | |
1649 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1650 | /// |
1651 | /// pruning away boxes that have high intersection-over-union (IOU) overlap |
1652 | /// with previously selected boxes. Bounding boxes with score less than |
1653 | /// `score_threshold` are removed. Bounding boxes are supplied as |
1654 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
1655 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
1656 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
1657 | /// is agnostic to where the origin is in the coordinate system and more |
1658 | /// generally is invariant to orthogonal transformations and translations |
1659 | /// of the coordinate system; thus translating or reflections of the coordinate |
1660 | /// system result in the same boxes being selected by the algorithm. |
1661 | /// The output of this operation is a set of integers indexing into the input |
1662 | /// collection of bounding boxes representing the selected boxes. The bounding |
1663 | /// box coordinates corresponding to the selected indices can then be obtained |
1664 | /// using the `tf.gather operation`. For example: |
1665 | /// selected_indices = tf.image.non_max_suppression_v2( |
1666 | /// boxes, scores, max_output_size, iou_threshold, score_threshold) |
1667 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1668 | /// |
1669 | /// Args: |
1670 | /// * scope: A Scope object |
1671 | /// * boxes: A 2-D float tensor of shape `[num_boxes, 4]`. |
1672 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1673 | /// score corresponding to each box (each row of boxes). |
1674 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1675 | /// boxes to be selected by non max suppression. |
1676 | /// * iou_threshold: A 0-D float tensor representing the threshold for deciding whether |
1677 | /// boxes overlap too much with respect to IOU. |
1678 | /// * score_threshold: A 0-D float tensor representing the threshold for deciding when to remove |
1679 | /// boxes based on score. |
1680 | /// |
1681 | /// Optional attributes (see `Attrs`): |
1682 | /// * pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length |
1683 | /// `max_output_size`. Defaults to false. |
1684 | /// |
1685 | /// Returns: |
1686 | /// * `Output` selected_indices: A 1-D integer tensor of shape `[M]` representing the selected |
1687 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1688 | /// * `Output` valid_outputs: A 0-D integer tensor representing the number of valid elements in |
1689 | /// `selected_indices`, with the valid elements appearing first. |
1690 | class NonMaxSuppressionV4 { |
1691 | public: |
1692 | /// Optional attribute setters for NonMaxSuppressionV4 |
1693 | struct Attrs { |
1694 | /// If true, the output `selected_indices` is padded to be of length |
1695 | /// `max_output_size`. Defaults to false. |
1696 | /// |
1697 | /// Defaults to false |
1698 | TF_MUST_USE_RESULT Attrs PadToMaxOutputSize(bool x) { |
1699 | Attrs ret = *this; |
1700 | ret.pad_to_max_output_size_ = x; |
1701 | return ret; |
1702 | } |
1703 | |
1704 | bool pad_to_max_output_size_ = false; |
1705 | }; |
1706 | NonMaxSuppressionV4(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1707 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1708 | max_output_size, ::tensorflow::Input iou_threshold, |
1709 | ::tensorflow::Input score_threshold); |
1710 | NonMaxSuppressionV4(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1711 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1712 | max_output_size, ::tensorflow::Input iou_threshold, |
1713 | ::tensorflow::Input score_threshold, const |
1714 | NonMaxSuppressionV4::Attrs& attrs); |
1715 | |
1716 | static Attrs PadToMaxOutputSize(bool x) { |
1717 | return Attrs().PadToMaxOutputSize(x); |
1718 | } |
1719 | |
1720 | Operation operation; |
1721 | ::tensorflow::Output selected_indices; |
1722 | ::tensorflow::Output valid_outputs; |
1723 | }; |
1724 | |
1725 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1726 | /// |
1727 | /// pruning away boxes that have high intersection-over-union (IOU) overlap |
1728 | /// with previously selected boxes. Bounding boxes with score less than |
1729 | /// `score_threshold` are removed. Bounding boxes are supplied as |
1730 | /// [y1, x1, y2, x2], where (y1, x1) and (y2, x2) are the coordinates of any |
1731 | /// diagonal pair of box corners and the coordinates can be provided as normalized |
1732 | /// (i.e., lying in the interval [0, 1]) or absolute. Note that this algorithm |
1733 | /// is agnostic to where the origin is in the coordinate system and more |
1734 | /// generally is invariant to orthogonal transformations and translations |
1735 | /// of the coordinate system; thus translating or reflections of the coordinate |
1736 | /// system result in the same boxes being selected by the algorithm. |
1737 | /// The output of this operation is a set of integers indexing into the input |
1738 | /// collection of bounding boxes representing the selected boxes. The bounding |
1739 | /// box coordinates corresponding to the selected indices can then be obtained |
1740 | /// using the `tf.gather operation`. For example: |
1741 | /// selected_indices = tf.image.non_max_suppression_v2( |
1742 | /// boxes, scores, max_output_size, iou_threshold, score_threshold) |
1743 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1744 | /// This op also supports a Soft-NMS (with Gaussian weighting) mode (c.f. |
1745 | /// Bodla et al, https://arxiv.org/abs/1704.04503) where boxes reduce the score |
1746 | /// of other overlapping boxes instead of directly causing them to be pruned. |
1747 | /// To enable this Soft-NMS mode, set the `soft_nms_sigma` parameter to be |
1748 | /// larger than 0. |
1749 | /// |
1750 | /// Args: |
1751 | /// * scope: A Scope object |
1752 | /// * boxes: A 2-D float tensor of shape `[num_boxes, 4]`. |
1753 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1754 | /// score corresponding to each box (each row of boxes). |
1755 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1756 | /// boxes to be selected by non max suppression. |
1757 | /// * iou_threshold: A 0-D float tensor representing the threshold for deciding whether |
1758 | /// boxes overlap too much with respect to IOU. |
1759 | /// * score_threshold: A 0-D float tensor representing the threshold for deciding when to remove |
1760 | /// boxes based on score. |
1761 | /// * soft_nms_sigma: A 0-D float tensor representing the sigma parameter for Soft NMS; see Bodla et |
1762 | /// al (c.f. https://arxiv.org/abs/1704.04503). When `soft_nms_sigma=0.0` (which |
1763 | /// is default), we fall back to standard (hard) NMS. |
1764 | /// |
1765 | /// Optional attributes (see `Attrs`): |
1766 | /// * pad_to_max_output_size: If true, the output `selected_indices` is padded to be of length |
1767 | /// `max_output_size`. Defaults to false. |
1768 | /// |
1769 | /// Returns: |
1770 | /// * `Output` selected_indices: A 1-D integer tensor of shape `[M]` representing the selected |
1771 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1772 | /// * `Output` selected_scores: A 1-D float tensor of shape `[M]` representing the corresponding |
1773 | /// scores for each selected box, where `M <= max_output_size`. Scores only differ |
1774 | /// from corresponding input scores when using Soft NMS (i.e. when |
1775 | /// `soft_nms_sigma>0`) |
1776 | /// * `Output` valid_outputs: A 0-D integer tensor representing the number of valid elements in |
1777 | /// `selected_indices`, with the valid elements appearing first. |
1778 | class NonMaxSuppressionV5 { |
1779 | public: |
1780 | /// Optional attribute setters for NonMaxSuppressionV5 |
1781 | struct Attrs { |
1782 | /// If true, the output `selected_indices` is padded to be of length |
1783 | /// `max_output_size`. Defaults to false. |
1784 | /// |
1785 | /// Defaults to false |
1786 | TF_MUST_USE_RESULT Attrs PadToMaxOutputSize(bool x) { |
1787 | Attrs ret = *this; |
1788 | ret.pad_to_max_output_size_ = x; |
1789 | return ret; |
1790 | } |
1791 | |
1792 | bool pad_to_max_output_size_ = false; |
1793 | }; |
1794 | NonMaxSuppressionV5(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1795 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1796 | max_output_size, ::tensorflow::Input iou_threshold, |
1797 | ::tensorflow::Input score_threshold, ::tensorflow::Input |
1798 | soft_nms_sigma); |
1799 | NonMaxSuppressionV5(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1800 | boxes, ::tensorflow::Input scores, ::tensorflow::Input |
1801 | max_output_size, ::tensorflow::Input iou_threshold, |
1802 | ::tensorflow::Input score_threshold, ::tensorflow::Input |
1803 | soft_nms_sigma, const NonMaxSuppressionV5::Attrs& attrs); |
1804 | |
1805 | static Attrs PadToMaxOutputSize(bool x) { |
1806 | return Attrs().PadToMaxOutputSize(x); |
1807 | } |
1808 | |
1809 | Operation operation; |
1810 | ::tensorflow::Output selected_indices; |
1811 | ::tensorflow::Output selected_scores; |
1812 | ::tensorflow::Output valid_outputs; |
1813 | }; |
1814 | |
1815 | /// Greedily selects a subset of bounding boxes in descending order of score, |
1816 | /// |
1817 | /// pruning away boxes that have high overlaps |
1818 | /// with previously selected boxes. Bounding boxes with score less than |
1819 | /// `score_threshold` are removed. N-by-n overlap values are supplied as square matrix, |
1820 | /// which allows for defining a custom overlap criterium (eg. intersection over union, |
1821 | /// intersection over area, etc.). |
1822 | /// |
1823 | /// The output of this operation is a set of integers indexing into the input |
1824 | /// collection of bounding boxes representing the selected boxes. The bounding |
1825 | /// box coordinates corresponding to the selected indices can then be obtained |
1826 | /// using the `tf.gather operation`. For example: |
1827 | /// |
1828 | /// selected_indices = tf.image.non_max_suppression_with_overlaps( |
1829 | /// overlaps, scores, max_output_size, overlap_threshold, score_threshold) |
1830 | /// selected_boxes = tf.gather(boxes, selected_indices) |
1831 | /// |
1832 | /// Args: |
1833 | /// * scope: A Scope object |
1834 | /// * overlaps: A 2-D float tensor of shape `[num_boxes, num_boxes]` representing |
1835 | /// the n-by-n box overlap values. |
1836 | /// * scores: A 1-D float tensor of shape `[num_boxes]` representing a single |
1837 | /// score corresponding to each box (each row of boxes). |
1838 | /// * max_output_size: A scalar integer tensor representing the maximum number of |
1839 | /// boxes to be selected by non max suppression. |
1840 | /// * overlap_threshold: A 0-D float tensor representing the threshold for deciding whether |
1841 | /// boxes overlap too. |
1842 | /// * score_threshold: A 0-D float tensor representing the threshold for deciding when to remove |
1843 | /// boxes based on score. |
1844 | /// |
1845 | /// Returns: |
1846 | /// * `Output`: A 1-D integer tensor of shape `[M]` representing the selected |
1847 | /// indices from the boxes tensor, where `M <= max_output_size`. |
1848 | class NonMaxSuppressionWithOverlaps { |
1849 | public: |
1850 | NonMaxSuppressionWithOverlaps(const ::tensorflow::Scope& scope, |
1851 | ::tensorflow::Input overlaps, ::tensorflow::Input |
1852 | scores, ::tensorflow::Input max_output_size, |
1853 | ::tensorflow::Input overlap_threshold, |
1854 | ::tensorflow::Input score_threshold); |
1855 | operator ::tensorflow::Output() const { return selected_indices; } |
1856 | operator ::tensorflow::Input() const { return selected_indices; } |
1857 | ::tensorflow::Node* node() const { return selected_indices.node(); } |
1858 | |
1859 | Operation operation; |
1860 | ::tensorflow::Output selected_indices; |
1861 | }; |
1862 | |
1863 | /// Resize quantized `images` to `size` using quantized bilinear interpolation. |
1864 | /// |
1865 | /// Input images and output images must be quantized types. |
1866 | /// |
1867 | /// Args: |
1868 | /// * scope: A Scope object |
1869 | /// * images: 4-D with shape `[batch, height, width, channels]`. |
1870 | /// * size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The |
1871 | /// new size for the images. |
1872 | /// |
1873 | /// Optional attributes (see `Attrs`): |
1874 | /// * align_corners: If true, the centers of the 4 corner pixels of the input and output tensors are |
1875 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
1876 | /// |
1877 | /// Returns: |
1878 | /// * `Output` resized_images: 4-D with shape |
1879 | /// `[batch, new_height, new_width, channels]`. |
1880 | /// * `Output` out_min |
1881 | /// * `Output` out_max |
1882 | class QuantizedResizeBilinear { |
1883 | public: |
1884 | /// Optional attribute setters for QuantizedResizeBilinear |
1885 | struct Attrs { |
1886 | /// If true, the centers of the 4 corner pixels of the input and output tensors are |
1887 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
1888 | /// |
1889 | /// Defaults to false |
1890 | TF_MUST_USE_RESULT Attrs AlignCorners(bool x) { |
1891 | Attrs ret = *this; |
1892 | ret.align_corners_ = x; |
1893 | return ret; |
1894 | } |
1895 | |
1896 | /// Defaults to false |
1897 | TF_MUST_USE_RESULT Attrs HalfPixelCenters(bool x) { |
1898 | Attrs ret = *this; |
1899 | ret.half_pixel_centers_ = x; |
1900 | return ret; |
1901 | } |
1902 | |
1903 | bool align_corners_ = false; |
1904 | bool half_pixel_centers_ = false; |
1905 | }; |
1906 | QuantizedResizeBilinear(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1907 | images, ::tensorflow::Input size, ::tensorflow::Input |
1908 | min, ::tensorflow::Input max); |
1909 | QuantizedResizeBilinear(const ::tensorflow::Scope& scope, ::tensorflow::Input |
1910 | images, ::tensorflow::Input size, ::tensorflow::Input |
1911 | min, ::tensorflow::Input max, const |
1912 | QuantizedResizeBilinear::Attrs& attrs); |
1913 | |
1914 | static Attrs AlignCorners(bool x) { |
1915 | return Attrs().AlignCorners(x); |
1916 | } |
1917 | static Attrs HalfPixelCenters(bool x) { |
1918 | return Attrs().HalfPixelCenters(x); |
1919 | } |
1920 | |
1921 | Operation operation; |
1922 | ::tensorflow::Output resized_images; |
1923 | ::tensorflow::Output out_min; |
1924 | ::tensorflow::Output out_max; |
1925 | }; |
1926 | |
1927 | /// Converts one or more images from RGB to HSV. |
1928 | /// |
1929 | /// Outputs a tensor of the same shape as the `images` tensor, containing the HSV |
1930 | /// value of the pixels. The output is only well defined if the value in `images` |
1931 | /// are in `[0,1]`. |
1932 | /// |
1933 | /// `output[..., 0]` contains hue, `output[..., 1]` contains saturation, and |
1934 | /// `output[..., 2]` contains value. All HSV values are in `[0,1]`. A hue of 0 |
1935 | /// corresponds to pure red, hue 1/3 is pure green, and 2/3 is pure blue. |
1936 | /// |
1937 | /// Usage Example: |
1938 | /// |
1939 | /// >>> blue_image = tf.stack([ |
1940 | /// ... tf.zeros([5,5]), |
1941 | /// ... tf.zeros([5,5]), |
1942 | /// ... tf.ones([5,5])], |
1943 | /// ... axis=-1) |
1944 | /// >>> blue_hsv_image = tf.image.rgb_to_hsv(blue_image) |
1945 | /// >>> blue_hsv_image[0,0].numpy() |
1946 | /// array([0.6666667, 1. , 1. ], dtype=float32) |
1947 | /// |
1948 | /// |
1949 | /// Args: |
1950 | /// * scope: A Scope object |
1951 | /// * images: 1-D or higher rank. RGB data to convert. Last dimension must be size 3. |
1952 | /// |
1953 | /// Returns: |
1954 | /// * `Output`: `images` converted to HSV. |
1955 | class RGBToHSV { |
1956 | public: |
1957 | RGBToHSV(const ::tensorflow::Scope& scope, ::tensorflow::Input images); |
1958 | operator ::tensorflow::Output() const { return output; } |
1959 | operator ::tensorflow::Input() const { return output; } |
1960 | ::tensorflow::Node* node() const { return output.node(); } |
1961 | |
1962 | Operation operation; |
1963 | ::tensorflow::Output output; |
1964 | }; |
1965 | |
1966 | /// Resize `images` to `size` using area interpolation. |
1967 | /// |
1968 | /// Input images can be of different types but output images are always float. |
1969 | /// |
1970 | /// The range of pixel values for the output image might be slightly different |
1971 | /// from the range for the input image because of limited numerical precision. |
1972 | /// To guarantee an output range, for example `[0.0, 1.0]`, apply |
1973 | /// `tf.clip_by_value` to the output. |
1974 | /// |
1975 | /// Each output pixel is computed by first transforming the pixel's footprint into |
1976 | /// the input tensor and then averaging the pixels that intersect the footprint. An |
1977 | /// input pixel's contribution to the average is weighted by the fraction of its |
1978 | /// area that intersects the footprint. This is the same as OpenCV's INTER_AREA. |
1979 | /// |
1980 | /// Args: |
1981 | /// * scope: A Scope object |
1982 | /// * images: 4-D with shape `[batch, height, width, channels]`. |
1983 | /// * size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The |
1984 | /// new size for the images. |
1985 | /// |
1986 | /// Optional attributes (see `Attrs`): |
1987 | /// * align_corners: If true, the centers of the 4 corner pixels of the input and output tensors are |
1988 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
1989 | /// |
1990 | /// Returns: |
1991 | /// * `Output`: 4-D with shape |
1992 | /// `[batch, new_height, new_width, channels]`. |
1993 | class ResizeArea { |
1994 | public: |
1995 | /// Optional attribute setters for ResizeArea |
1996 | struct Attrs { |
1997 | /// If true, the centers of the 4 corner pixels of the input and output tensors are |
1998 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
1999 | /// |
2000 | /// Defaults to false |
2001 | TF_MUST_USE_RESULT Attrs AlignCorners(bool x) { |
2002 | Attrs ret = *this; |
2003 | ret.align_corners_ = x; |
2004 | return ret; |
2005 | } |
2006 | |
2007 | bool align_corners_ = false; |
2008 | }; |
2009 | ResizeArea(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2010 | ::tensorflow::Input size); |
2011 | ResizeArea(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2012 | ::tensorflow::Input size, const ResizeArea::Attrs& attrs); |
2013 | operator ::tensorflow::Output() const { return resized_images; } |
2014 | operator ::tensorflow::Input() const { return resized_images; } |
2015 | ::tensorflow::Node* node() const { return resized_images.node(); } |
2016 | |
2017 | static Attrs AlignCorners(bool x) { |
2018 | return Attrs().AlignCorners(x); |
2019 | } |
2020 | |
2021 | Operation operation; |
2022 | ::tensorflow::Output resized_images; |
2023 | }; |
2024 | |
2025 | /// Resize `images` to `size` using bicubic interpolation. |
2026 | /// |
2027 | /// Input images can be of different types but output images are always float. |
2028 | /// |
2029 | /// Args: |
2030 | /// * scope: A Scope object |
2031 | /// * images: 4-D with shape `[batch, height, width, channels]`. |
2032 | /// * size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The |
2033 | /// new size for the images. |
2034 | /// |
2035 | /// Optional attributes (see `Attrs`): |
2036 | /// * align_corners: If true, the centers of the 4 corner pixels of the input and output tensors are |
2037 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2038 | /// |
2039 | /// Returns: |
2040 | /// * `Output`: 4-D with shape |
2041 | /// `[batch, new_height, new_width, channels]`. |
2042 | class ResizeBicubic { |
2043 | public: |
2044 | /// Optional attribute setters for ResizeBicubic |
2045 | struct Attrs { |
2046 | /// If true, the centers of the 4 corner pixels of the input and output tensors are |
2047 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2048 | /// |
2049 | /// Defaults to false |
2050 | TF_MUST_USE_RESULT Attrs AlignCorners(bool x) { |
2051 | Attrs ret = *this; |
2052 | ret.align_corners_ = x; |
2053 | return ret; |
2054 | } |
2055 | |
2056 | /// Defaults to false |
2057 | TF_MUST_USE_RESULT Attrs HalfPixelCenters(bool x) { |
2058 | Attrs ret = *this; |
2059 | ret.half_pixel_centers_ = x; |
2060 | return ret; |
2061 | } |
2062 | |
2063 | bool align_corners_ = false; |
2064 | bool half_pixel_centers_ = false; |
2065 | }; |
2066 | ResizeBicubic(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2067 | ::tensorflow::Input size); |
2068 | ResizeBicubic(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2069 | ::tensorflow::Input size, const ResizeBicubic::Attrs& attrs); |
2070 | operator ::tensorflow::Output() const { return resized_images; } |
2071 | operator ::tensorflow::Input() const { return resized_images; } |
2072 | ::tensorflow::Node* node() const { return resized_images.node(); } |
2073 | |
2074 | static Attrs AlignCorners(bool x) { |
2075 | return Attrs().AlignCorners(x); |
2076 | } |
2077 | static Attrs HalfPixelCenters(bool x) { |
2078 | return Attrs().HalfPixelCenters(x); |
2079 | } |
2080 | |
2081 | Operation operation; |
2082 | ::tensorflow::Output resized_images; |
2083 | }; |
2084 | |
2085 | /// Resize `images` to `size` using bilinear interpolation. |
2086 | /// |
2087 | /// Input images can be of different types but output images are always float. |
2088 | /// |
2089 | /// Args: |
2090 | /// * scope: A Scope object |
2091 | /// * images: 4-D with shape `[batch, height, width, channels]`. |
2092 | /// * size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The |
2093 | /// new size for the images. |
2094 | /// |
2095 | /// Optional attributes (see `Attrs`): |
2096 | /// * align_corners: If true, the centers of the 4 corner pixels of the input and output tensors are |
2097 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2098 | /// |
2099 | /// Returns: |
2100 | /// * `Output`: 4-D with shape |
2101 | /// `[batch, new_height, new_width, channels]`. |
2102 | class ResizeBilinear { |
2103 | public: |
2104 | /// Optional attribute setters for ResizeBilinear |
2105 | struct Attrs { |
2106 | /// If true, the centers of the 4 corner pixels of the input and output tensors are |
2107 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2108 | /// |
2109 | /// Defaults to false |
2110 | TF_MUST_USE_RESULT Attrs AlignCorners(bool x) { |
2111 | Attrs ret = *this; |
2112 | ret.align_corners_ = x; |
2113 | return ret; |
2114 | } |
2115 | |
2116 | /// Defaults to false |
2117 | TF_MUST_USE_RESULT Attrs HalfPixelCenters(bool x) { |
2118 | Attrs ret = *this; |
2119 | ret.half_pixel_centers_ = x; |
2120 | return ret; |
2121 | } |
2122 | |
2123 | bool align_corners_ = false; |
2124 | bool half_pixel_centers_ = false; |
2125 | }; |
2126 | ResizeBilinear(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2127 | ::tensorflow::Input size); |
2128 | ResizeBilinear(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2129 | ::tensorflow::Input size, const ResizeBilinear::Attrs& attrs); |
2130 | operator ::tensorflow::Output() const { return resized_images; } |
2131 | operator ::tensorflow::Input() const { return resized_images; } |
2132 | ::tensorflow::Node* node() const { return resized_images.node(); } |
2133 | |
2134 | static Attrs AlignCorners(bool x) { |
2135 | return Attrs().AlignCorners(x); |
2136 | } |
2137 | static Attrs HalfPixelCenters(bool x) { |
2138 | return Attrs().HalfPixelCenters(x); |
2139 | } |
2140 | |
2141 | Operation operation; |
2142 | ::tensorflow::Output resized_images; |
2143 | }; |
2144 | |
2145 | /// Resize `images` to `size` using nearest neighbor interpolation. |
2146 | /// |
2147 | /// Args: |
2148 | /// * scope: A Scope object |
2149 | /// * images: 4-D with shape `[batch, height, width, channels]`. |
2150 | /// * size: = A 1-D int32 Tensor of 2 elements: `new_height, new_width`. The |
2151 | /// new size for the images. |
2152 | /// |
2153 | /// Optional attributes (see `Attrs`): |
2154 | /// * align_corners: If true, the centers of the 4 corner pixels of the input and output tensors are |
2155 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2156 | /// |
2157 | /// Returns: |
2158 | /// * `Output`: 4-D with shape |
2159 | /// `[batch, new_height, new_width, channels]`. |
2160 | class ResizeNearestNeighbor { |
2161 | public: |
2162 | /// Optional attribute setters for ResizeNearestNeighbor |
2163 | struct Attrs { |
2164 | /// If true, the centers of the 4 corner pixels of the input and output tensors are |
2165 | /// aligned, preserving the values at the corner pixels. Defaults to false. |
2166 | /// |
2167 | /// Defaults to false |
2168 | TF_MUST_USE_RESULT Attrs AlignCorners(bool x) { |
2169 | Attrs ret = *this; |
2170 | ret.align_corners_ = x; |
2171 | return ret; |
2172 | } |
2173 | |
2174 | /// Defaults to false |
2175 | TF_MUST_USE_RESULT Attrs HalfPixelCenters(bool x) { |
2176 | Attrs ret = *this; |
2177 | ret.half_pixel_centers_ = x; |
2178 | return ret; |
2179 | } |
2180 | |
2181 | bool align_corners_ = false; |
2182 | bool half_pixel_centers_ = false; |
2183 | }; |
2184 | ResizeNearestNeighbor(const ::tensorflow::Scope& scope, ::tensorflow::Input |
2185 | images, ::tensorflow::Input size); |
2186 | ResizeNearestNeighbor(const ::tensorflow::Scope& scope, ::tensorflow::Input |
2187 | images, ::tensorflow::Input size, const |
2188 | ResizeNearestNeighbor::Attrs& attrs); |
2189 | operator ::tensorflow::Output() const { return resized_images; } |
2190 | operator ::tensorflow::Input() const { return resized_images; } |
2191 | ::tensorflow::Node* node() const { return resized_images.node(); } |
2192 | |
2193 | static Attrs AlignCorners(bool x) { |
2194 | return Attrs().AlignCorners(x); |
2195 | } |
2196 | static Attrs HalfPixelCenters(bool x) { |
2197 | return Attrs().HalfPixelCenters(x); |
2198 | } |
2199 | |
2200 | Operation operation; |
2201 | ::tensorflow::Output resized_images; |
2202 | }; |
2203 | |
2204 | /// Generate a single randomly distorted bounding box for an image. |
2205 | /// |
2206 | /// Bounding box annotations are often supplied in addition to ground-truth labels |
2207 | /// in image recognition or object localization tasks. A common technique for |
2208 | /// training such a system is to randomly distort an image while preserving |
2209 | /// its content, i.e. *data augmentation*. This Op outputs a randomly distorted |
2210 | /// localization of an object, i.e. bounding box, given an `image_size`, |
2211 | /// `bounding_boxes` and a series of constraints. |
2212 | /// |
2213 | /// The output of this Op is a single bounding box that may be used to crop the |
2214 | /// original image. The output is returned as 3 tensors: `begin`, `size` and |
2215 | /// `bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the |
2216 | /// image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize |
2217 | /// what the bounding box looks like. |
2218 | /// |
2219 | /// Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The |
2220 | /// bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and |
2221 | /// height of the underlying image. |
2222 | /// |
2223 | /// For example, |
2224 | /// |
2225 | /// ```python |
2226 | /// # Generate a single distorted bounding box. |
2227 | /// begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box( |
2228 | /// tf.shape(image), |
2229 | /// bounding_boxes=bounding_boxes) |
2230 | /// |
2231 | /// # Draw the bounding box in an image summary. |
2232 | /// image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0), |
2233 | /// bbox_for_draw) |
2234 | /// tf.summary.image('images_with_box', image_with_box) |
2235 | /// |
2236 | /// # Employ the bounding box to distort the image. |
2237 | /// distorted_image = tf.slice(image, begin, size) |
2238 | /// ``` |
2239 | /// |
2240 | /// Note that if no bounding box information is available, setting |
2241 | /// `use_image_if_no_bounding_boxes = true` will assume there is a single implicit |
2242 | /// bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is |
2243 | /// false and no bounding boxes are supplied, an error is raised. |
2244 | /// |
2245 | /// Args: |
2246 | /// * scope: A Scope object |
2247 | /// * image_size: 1-D, containing `[height, width, channels]`. |
2248 | /// * bounding_boxes: 3-D with shape `[batch, N, 4]` describing the N bounding boxes |
2249 | /// associated with the image. |
2250 | /// |
2251 | /// Optional attributes (see `Attrs`): |
2252 | /// * seed: If either `seed` or `seed2` are set to non-zero, the random number |
2253 | /// generator is seeded by the given `seed`. Otherwise, it is seeded by a random |
2254 | /// seed. |
2255 | /// * seed2: A second seed to avoid seed collision. |
2256 | /// * min_object_covered: The cropped area of the image must contain at least this |
2257 | /// fraction of any bounding box supplied. The value of this parameter should be |
2258 | /// non-negative. In the case of 0, the cropped area does not need to overlap |
2259 | /// any of the bounding boxes supplied. |
2260 | /// * aspect_ratio_range: The cropped area of the image must have an aspect ratio = |
2261 | /// width / height within this range. |
2262 | /// * area_range: The cropped area of the image must contain a fraction of the |
2263 | /// supplied image within this range. |
2264 | /// * max_attempts: Number of attempts at generating a cropped region of the image |
2265 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2266 | /// image. |
2267 | /// * use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied. |
2268 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2269 | /// raise an error. |
2270 | /// |
2271 | /// Returns: |
2272 | /// * `Output` begin: 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to |
2273 | /// `tf.slice`. |
2274 | /// * `Output` size: 1-D, containing `[target_height, target_width, -1]`. Provide as input to |
2275 | /// `tf.slice`. |
2276 | /// * `Output` bboxes: 3-D with shape `[1, 1, 4]` containing the distorted bounding box. |
2277 | /// Provide as input to `tf.image.draw_bounding_boxes`. |
2278 | class SampleDistortedBoundingBox { |
2279 | public: |
2280 | /// Optional attribute setters for SampleDistortedBoundingBox |
2281 | struct Attrs { |
2282 | /// If either `seed` or `seed2` are set to non-zero, the random number |
2283 | /// generator is seeded by the given `seed`. Otherwise, it is seeded by a random |
2284 | /// seed. |
2285 | /// |
2286 | /// Defaults to 0 |
2287 | TF_MUST_USE_RESULT Attrs Seed(int64 x) { |
2288 | Attrs ret = *this; |
2289 | ret.seed_ = x; |
2290 | return ret; |
2291 | } |
2292 | |
2293 | /// A second seed to avoid seed collision. |
2294 | /// |
2295 | /// Defaults to 0 |
2296 | TF_MUST_USE_RESULT Attrs Seed2(int64 x) { |
2297 | Attrs ret = *this; |
2298 | ret.seed2_ = x; |
2299 | return ret; |
2300 | } |
2301 | |
2302 | /// The cropped area of the image must contain at least this |
2303 | /// fraction of any bounding box supplied. The value of this parameter should be |
2304 | /// non-negative. In the case of 0, the cropped area does not need to overlap |
2305 | /// any of the bounding boxes supplied. |
2306 | /// |
2307 | /// Defaults to 0.1 |
2308 | TF_MUST_USE_RESULT Attrs MinObjectCovered(float x) { |
2309 | Attrs ret = *this; |
2310 | ret.min_object_covered_ = x; |
2311 | return ret; |
2312 | } |
2313 | |
2314 | /// The cropped area of the image must have an aspect ratio = |
2315 | /// width / height within this range. |
2316 | /// |
2317 | /// Defaults to [0.75, 1.33] |
2318 | TF_MUST_USE_RESULT Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2319 | Attrs ret = *this; |
2320 | ret.aspect_ratio_range_ = x; |
2321 | return ret; |
2322 | } |
2323 | |
2324 | /// The cropped area of the image must contain a fraction of the |
2325 | /// supplied image within this range. |
2326 | /// |
2327 | /// Defaults to [0.05, 1] |
2328 | TF_MUST_USE_RESULT Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2329 | Attrs ret = *this; |
2330 | ret.area_range_ = x; |
2331 | return ret; |
2332 | } |
2333 | |
2334 | /// Number of attempts at generating a cropped region of the image |
2335 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2336 | /// image. |
2337 | /// |
2338 | /// Defaults to 100 |
2339 | TF_MUST_USE_RESULT Attrs MaxAttempts(int64 x) { |
2340 | Attrs ret = *this; |
2341 | ret.max_attempts_ = x; |
2342 | return ret; |
2343 | } |
2344 | |
2345 | /// Controls behavior if no bounding boxes supplied. |
2346 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2347 | /// raise an error. |
2348 | /// |
2349 | /// Defaults to false |
2350 | TF_MUST_USE_RESULT Attrs UseImageIfNoBoundingBoxes(bool x) { |
2351 | Attrs ret = *this; |
2352 | ret.use_image_if_no_bounding_boxes_ = x; |
2353 | return ret; |
2354 | } |
2355 | |
2356 | int64 seed_ = 0; |
2357 | int64 seed2_ = 0; |
2358 | float min_object_covered_ = 0.1f; |
2359 | gtl::ArraySlice<float> aspect_ratio_range_ = Default_aspect_ratio_range(); |
2360 | gtl::ArraySlice<float> area_range_ = Default_area_range(); |
2361 | int64 max_attempts_ = 100; |
2362 | bool use_image_if_no_bounding_boxes_ = false; |
2363 | private: |
2364 | static gtl::ArraySlice<float> Default_aspect_ratio_range() { |
2365 | static const float kStorage[] = {0.75f, 1.33f}; |
2366 | return gtl::ArraySlice<float>(kStorage); |
2367 | } |
2368 | static gtl::ArraySlice<float> Default_area_range() { |
2369 | static const float kStorage[] = {0.05f, 1.0f}; |
2370 | return gtl::ArraySlice<float>(kStorage); |
2371 | } |
2372 | }; |
2373 | SampleDistortedBoundingBox(const ::tensorflow::Scope& scope, |
2374 | ::tensorflow::Input image_size, ::tensorflow::Input |
2375 | bounding_boxes); |
2376 | SampleDistortedBoundingBox(const ::tensorflow::Scope& scope, |
2377 | ::tensorflow::Input image_size, ::tensorflow::Input |
2378 | bounding_boxes, const |
2379 | SampleDistortedBoundingBox::Attrs& attrs); |
2380 | |
2381 | static Attrs Seed(int64 x) { |
2382 | return Attrs().Seed(x); |
2383 | } |
2384 | static Attrs Seed2(int64 x) { |
2385 | return Attrs().Seed2(x); |
2386 | } |
2387 | static Attrs MinObjectCovered(float x) { |
2388 | return Attrs().MinObjectCovered(x); |
2389 | } |
2390 | static Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2391 | return Attrs().AspectRatioRange(x); |
2392 | } |
2393 | static Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2394 | return Attrs().AreaRange(x); |
2395 | } |
2396 | static Attrs MaxAttempts(int64 x) { |
2397 | return Attrs().MaxAttempts(x); |
2398 | } |
2399 | static Attrs UseImageIfNoBoundingBoxes(bool x) { |
2400 | return Attrs().UseImageIfNoBoundingBoxes(x); |
2401 | } |
2402 | |
2403 | Operation operation; |
2404 | ::tensorflow::Output begin; |
2405 | ::tensorflow::Output size; |
2406 | ::tensorflow::Output bboxes; |
2407 | }; |
2408 | |
2409 | /// Generate a single randomly distorted bounding box for an image. |
2410 | /// |
2411 | /// Bounding box annotations are often supplied in addition to ground-truth labels |
2412 | /// in image recognition or object localization tasks. A common technique for |
2413 | /// training such a system is to randomly distort an image while preserving |
2414 | /// its content, i.e. *data augmentation*. This Op outputs a randomly distorted |
2415 | /// localization of an object, i.e. bounding box, given an `image_size`, |
2416 | /// `bounding_boxes` and a series of constraints. |
2417 | /// |
2418 | /// The output of this Op is a single bounding box that may be used to crop the |
2419 | /// original image. The output is returned as 3 tensors: `begin`, `size` and |
2420 | /// `bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the |
2421 | /// image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize |
2422 | /// what the bounding box looks like. |
2423 | /// |
2424 | /// Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The |
2425 | /// bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and |
2426 | /// height of the underlying image. |
2427 | /// |
2428 | /// For example, |
2429 | /// |
2430 | /// ```python |
2431 | /// # Generate a single distorted bounding box. |
2432 | /// begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box( |
2433 | /// tf.shape(image), |
2434 | /// bounding_boxes=bounding_boxes) |
2435 | /// |
2436 | /// # Draw the bounding box in an image summary. |
2437 | /// image_with_box = tf.image.draw_bounding_boxes(tf.expand_dims(image, 0), |
2438 | /// bbox_for_draw) |
2439 | /// tf.summary.image('images_with_box', image_with_box) |
2440 | /// |
2441 | /// # Employ the bounding box to distort the image. |
2442 | /// distorted_image = tf.slice(image, begin, size) |
2443 | /// ``` |
2444 | /// |
2445 | /// Note that if no bounding box information is available, setting |
2446 | /// `use_image_if_no_bounding_boxes = true` will assume there is a single implicit |
2447 | /// bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is |
2448 | /// false and no bounding boxes are supplied, an error is raised. |
2449 | /// |
2450 | /// Args: |
2451 | /// * scope: A Scope object |
2452 | /// * image_size: 1-D, containing `[height, width, channels]`. |
2453 | /// * bounding_boxes: 3-D with shape `[batch, N, 4]` describing the N bounding boxes |
2454 | /// associated with the image. |
2455 | /// * min_object_covered: The cropped area of the image must contain at least this |
2456 | /// fraction of any bounding box supplied. The value of this parameter should be |
2457 | /// non-negative. In the case of 0, the cropped area does not need to overlap |
2458 | /// any of the bounding boxes supplied. |
2459 | /// |
2460 | /// Optional attributes (see `Attrs`): |
2461 | /// * seed: If either `seed` or `seed2` are set to non-zero, the random number |
2462 | /// generator is seeded by the given `seed`. Otherwise, it is seeded by a random |
2463 | /// seed. |
2464 | /// * seed2: A second seed to avoid seed collision. |
2465 | /// * aspect_ratio_range: The cropped area of the image must have an aspect ratio = |
2466 | /// width / height within this range. |
2467 | /// * area_range: The cropped area of the image must contain a fraction of the |
2468 | /// supplied image within this range. |
2469 | /// * max_attempts: Number of attempts at generating a cropped region of the image |
2470 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2471 | /// image. |
2472 | /// * use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied. |
2473 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2474 | /// raise an error. |
2475 | /// |
2476 | /// Returns: |
2477 | /// * `Output` begin: 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to |
2478 | /// `tf.slice`. |
2479 | /// * `Output` size: 1-D, containing `[target_height, target_width, -1]`. Provide as input to |
2480 | /// `tf.slice`. |
2481 | /// * `Output` bboxes: 3-D with shape `[1, 1, 4]` containing the distorted bounding box. |
2482 | /// Provide as input to `tf.image.draw_bounding_boxes`. |
2483 | class SampleDistortedBoundingBoxV2 { |
2484 | public: |
2485 | /// Optional attribute setters for SampleDistortedBoundingBoxV2 |
2486 | struct Attrs { |
2487 | /// If either `seed` or `seed2` are set to non-zero, the random number |
2488 | /// generator is seeded by the given `seed`. Otherwise, it is seeded by a random |
2489 | /// seed. |
2490 | /// |
2491 | /// Defaults to 0 |
2492 | TF_MUST_USE_RESULT Attrs Seed(int64 x) { |
2493 | Attrs ret = *this; |
2494 | ret.seed_ = x; |
2495 | return ret; |
2496 | } |
2497 | |
2498 | /// A second seed to avoid seed collision. |
2499 | /// |
2500 | /// Defaults to 0 |
2501 | TF_MUST_USE_RESULT Attrs Seed2(int64 x) { |
2502 | Attrs ret = *this; |
2503 | ret.seed2_ = x; |
2504 | return ret; |
2505 | } |
2506 | |
2507 | /// The cropped area of the image must have an aspect ratio = |
2508 | /// width / height within this range. |
2509 | /// |
2510 | /// Defaults to [0.75, 1.33] |
2511 | TF_MUST_USE_RESULT Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2512 | Attrs ret = *this; |
2513 | ret.aspect_ratio_range_ = x; |
2514 | return ret; |
2515 | } |
2516 | |
2517 | /// The cropped area of the image must contain a fraction of the |
2518 | /// supplied image within this range. |
2519 | /// |
2520 | /// Defaults to [0.05, 1] |
2521 | TF_MUST_USE_RESULT Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2522 | Attrs ret = *this; |
2523 | ret.area_range_ = x; |
2524 | return ret; |
2525 | } |
2526 | |
2527 | /// Number of attempts at generating a cropped region of the image |
2528 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2529 | /// image. |
2530 | /// |
2531 | /// Defaults to 100 |
2532 | TF_MUST_USE_RESULT Attrs MaxAttempts(int64 x) { |
2533 | Attrs ret = *this; |
2534 | ret.max_attempts_ = x; |
2535 | return ret; |
2536 | } |
2537 | |
2538 | /// Controls behavior if no bounding boxes supplied. |
2539 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2540 | /// raise an error. |
2541 | /// |
2542 | /// Defaults to false |
2543 | TF_MUST_USE_RESULT Attrs UseImageIfNoBoundingBoxes(bool x) { |
2544 | Attrs ret = *this; |
2545 | ret.use_image_if_no_bounding_boxes_ = x; |
2546 | return ret; |
2547 | } |
2548 | |
2549 | int64 seed_ = 0; |
2550 | int64 seed2_ = 0; |
2551 | gtl::ArraySlice<float> aspect_ratio_range_ = Default_aspect_ratio_range(); |
2552 | gtl::ArraySlice<float> area_range_ = Default_area_range(); |
2553 | int64 max_attempts_ = 100; |
2554 | bool use_image_if_no_bounding_boxes_ = false; |
2555 | private: |
2556 | static gtl::ArraySlice<float> Default_aspect_ratio_range() { |
2557 | static const float kStorage[] = {0.75f, 1.33f}; |
2558 | return gtl::ArraySlice<float>(kStorage); |
2559 | } |
2560 | static gtl::ArraySlice<float> Default_area_range() { |
2561 | static const float kStorage[] = {0.05f, 1.0f}; |
2562 | return gtl::ArraySlice<float>(kStorage); |
2563 | } |
2564 | }; |
2565 | SampleDistortedBoundingBoxV2(const ::tensorflow::Scope& scope, |
2566 | ::tensorflow::Input image_size, |
2567 | ::tensorflow::Input bounding_boxes, |
2568 | ::tensorflow::Input min_object_covered); |
2569 | SampleDistortedBoundingBoxV2(const ::tensorflow::Scope& scope, |
2570 | ::tensorflow::Input image_size, |
2571 | ::tensorflow::Input bounding_boxes, |
2572 | ::tensorflow::Input min_object_covered, const |
2573 | SampleDistortedBoundingBoxV2::Attrs& attrs); |
2574 | |
2575 | static Attrs Seed(int64 x) { |
2576 | return Attrs().Seed(x); |
2577 | } |
2578 | static Attrs Seed2(int64 x) { |
2579 | return Attrs().Seed2(x); |
2580 | } |
2581 | static Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2582 | return Attrs().AspectRatioRange(x); |
2583 | } |
2584 | static Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2585 | return Attrs().AreaRange(x); |
2586 | } |
2587 | static Attrs MaxAttempts(int64 x) { |
2588 | return Attrs().MaxAttempts(x); |
2589 | } |
2590 | static Attrs UseImageIfNoBoundingBoxes(bool x) { |
2591 | return Attrs().UseImageIfNoBoundingBoxes(x); |
2592 | } |
2593 | |
2594 | Operation operation; |
2595 | ::tensorflow::Output begin; |
2596 | ::tensorflow::Output size; |
2597 | ::tensorflow::Output bboxes; |
2598 | }; |
2599 | |
2600 | /// TODO: add doc. |
2601 | /// |
2602 | /// Args: |
2603 | /// * scope: A Scope object |
2604 | /// |
2605 | /// Returns: |
2606 | /// * `Output`: The resized_images tensor. |
2607 | class ScaleAndTranslate { |
2608 | public: |
2609 | /// Optional attribute setters for ScaleAndTranslate |
2610 | struct Attrs { |
2611 | /// Defaults to "lanczos3" |
2612 | TF_MUST_USE_RESULT Attrs KernelType(StringPiece x) { |
2613 | Attrs ret = *this; |
2614 | ret.kernel_type_ = x; |
2615 | return ret; |
2616 | } |
2617 | |
2618 | /// Defaults to true |
2619 | TF_MUST_USE_RESULT Attrs Antialias(bool x) { |
2620 | Attrs ret = *this; |
2621 | ret.antialias_ = x; |
2622 | return ret; |
2623 | } |
2624 | |
2625 | StringPiece kernel_type_ = "lanczos3" ; |
2626 | bool antialias_ = true; |
2627 | }; |
2628 | ScaleAndTranslate(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2629 | ::tensorflow::Input size, ::tensorflow::Input scale, |
2630 | ::tensorflow::Input translation); |
2631 | ScaleAndTranslate(const ::tensorflow::Scope& scope, ::tensorflow::Input images, |
2632 | ::tensorflow::Input size, ::tensorflow::Input scale, |
2633 | ::tensorflow::Input translation, const |
2634 | ScaleAndTranslate::Attrs& attrs); |
2635 | operator ::tensorflow::Output() const { return resized_images; } |
2636 | operator ::tensorflow::Input() const { return resized_images; } |
2637 | ::tensorflow::Node* node() const { return resized_images.node(); } |
2638 | |
2639 | static Attrs KernelType(StringPiece x) { |
2640 | return Attrs().KernelType(x); |
2641 | } |
2642 | static Attrs Antialias(bool x) { |
2643 | return Attrs().Antialias(x); |
2644 | } |
2645 | |
2646 | Operation operation; |
2647 | ::tensorflow::Output resized_images; |
2648 | }; |
2649 | |
2650 | /// Generate a randomly distorted bounding box for an image deterministically. |
2651 | /// |
2652 | /// Bounding box annotations are often supplied in addition to ground-truth labels |
2653 | /// in image recognition or object localization tasks. A common technique for |
2654 | /// training such a system is to randomly distort an image while preserving its |
2655 | /// content, i.e. *data augmentation*. This Op, given the same `seed`, |
2656 | /// deterministically outputs a randomly distorted localization of an object, i.e. |
2657 | /// bounding box, given an `image_size`, `bounding_boxes` and a series of |
2658 | /// constraints. |
2659 | /// |
2660 | /// The output of this Op is a single bounding box that may be used to crop the |
2661 | /// original image. The output is returned as 3 tensors: `begin`, `size` and |
2662 | /// `bboxes`. The first 2 tensors can be fed directly into `tf.slice` to crop the |
2663 | /// image. The latter may be supplied to `tf.image.draw_bounding_boxes` to visualize |
2664 | /// what the bounding box looks like. |
2665 | /// |
2666 | /// Bounding boxes are supplied and returned as `[y_min, x_min, y_max, x_max]`. The |
2667 | /// bounding box coordinates are floats in `[0.0, 1.0]` relative to the width and |
2668 | /// the height of the underlying image. |
2669 | /// |
2670 | /// The output of this Op is guaranteed to be the same given the same `seed` and is |
2671 | /// independent of how many times the function is called, and independent of global |
2672 | /// seed settings (e.g. `tf.random.set_seed`). |
2673 | /// |
2674 | /// Example usage: |
2675 | /// |
2676 | /// >>> image = np.array([[[1], [2], [3]], [[4], [5], [6]], [[7], [8], [9]]]) |
2677 | /// >>> bbox = tf.constant( |
2678 | /// ... [0.0, 0.0, 1.0, 1.0], dtype=tf.float32, shape=[1, 1, 4]) |
2679 | /// >>> seed = (1, 2) |
2680 | /// >>> # Generate a single distorted bounding box. |
2681 | /// >>> bbox_begin, bbox_size, bbox_draw = ( |
2682 | /// ... tf.image.stateless_sample_distorted_bounding_box( |
2683 | /// ... tf.shape(image), bounding_boxes=bbox, seed=seed)) |
2684 | /// >>> # Employ the bounding box to distort the image. |
2685 | /// >>> tf.slice(image, bbox_begin, bbox_size) |
2686 | /// <tf.Tensor: shape=(2, 2, 1), dtype=int64, numpy= |
2687 | /// array([[[1], |
2688 | /// [2]], |
2689 | /// [[4], |
2690 | /// [5]]])> |
2691 | /// >>> # Draw the bounding box in an image summary. |
2692 | /// >>> colors = np.array([[1.0, 0.0, 0.0], [0.0, 0.0, 1.0]]) |
2693 | /// >>> tf.image.draw_bounding_boxes( |
2694 | /// ... tf.expand_dims(tf.cast(image, tf.float32),0), bbox_draw, colors) |
2695 | /// <tf.Tensor: shape=(1, 3, 3, 1), dtype=float32, numpy= |
2696 | /// array([[[[1.], |
2697 | /// [1.], |
2698 | /// [3.]], |
2699 | /// [[1.], |
2700 | /// [1.], |
2701 | /// [6.]], |
2702 | /// [[7.], |
2703 | /// [8.], |
2704 | /// [9.]]]], dtype=float32)> |
2705 | /// |
2706 | /// Note that if no bounding box information is available, setting |
2707 | /// `use_image_if_no_bounding_boxes = true` will assume there is a single implicit |
2708 | /// bounding box covering the whole image. If `use_image_if_no_bounding_boxes` is |
2709 | /// false and no bounding boxes are supplied, an error is raised. |
2710 | /// |
2711 | /// Args: |
2712 | /// * scope: A Scope object |
2713 | /// * image_size: 1-D, containing `[height, width, channels]`. |
2714 | /// * bounding_boxes: 3-D with shape `[batch, N, 4]` describing the N bounding boxes |
2715 | /// associated with the image. |
2716 | /// * min_object_covered: The cropped area of the image must contain at least this |
2717 | /// fraction of any bounding box supplied. The value of this parameter should be |
2718 | /// non-negative. In the case of 0, the cropped area does not need to overlap |
2719 | /// any of the bounding boxes supplied. |
2720 | /// * seed: 1-D with shape `[2]`. The seed to the random number generator. Must have dtype |
2721 | /// `int32` or `int64`. (When using XLA, only `int32` is allowed.) |
2722 | /// |
2723 | /// Optional attributes (see `Attrs`): |
2724 | /// * aspect_ratio_range: The cropped area of the image must have an aspect ratio = |
2725 | /// width / height within this range. |
2726 | /// * area_range: The cropped area of the image must contain a fraction of the |
2727 | /// supplied image within this range. |
2728 | /// * max_attempts: Number of attempts at generating a cropped region of the image |
2729 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2730 | /// image. |
2731 | /// * use_image_if_no_bounding_boxes: Controls behavior if no bounding boxes supplied. |
2732 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2733 | /// raise an error. |
2734 | /// |
2735 | /// Returns: |
2736 | /// * `Output` begin: 1-D, containing `[offset_height, offset_width, 0]`. Provide as input to |
2737 | /// `tf.slice`. |
2738 | /// * `Output` size: 1-D, containing `[target_height, target_width, -1]`. Provide as input to |
2739 | /// `tf.slice`. |
2740 | /// * `Output` bboxes: 3-D with shape `[1, 1, 4]` containing the distorted bounding box. |
2741 | /// Provide as input to `tf.image.draw_bounding_boxes`. |
2742 | class StatelessSampleDistortedBoundingBox { |
2743 | public: |
2744 | /// Optional attribute setters for StatelessSampleDistortedBoundingBox |
2745 | struct Attrs { |
2746 | /// The cropped area of the image must have an aspect ratio = |
2747 | /// width / height within this range. |
2748 | /// |
2749 | /// Defaults to [0.75, 1.33] |
2750 | TF_MUST_USE_RESULT Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2751 | Attrs ret = *this; |
2752 | ret.aspect_ratio_range_ = x; |
2753 | return ret; |
2754 | } |
2755 | |
2756 | /// The cropped area of the image must contain a fraction of the |
2757 | /// supplied image within this range. |
2758 | /// |
2759 | /// Defaults to [0.05, 1] |
2760 | TF_MUST_USE_RESULT Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2761 | Attrs ret = *this; |
2762 | ret.area_range_ = x; |
2763 | return ret; |
2764 | } |
2765 | |
2766 | /// Number of attempts at generating a cropped region of the image |
2767 | /// of the specified constraints. After `max_attempts` failures, return the entire |
2768 | /// image. |
2769 | /// |
2770 | /// Defaults to 100 |
2771 | TF_MUST_USE_RESULT Attrs MaxAttempts(int64 x) { |
2772 | Attrs ret = *this; |
2773 | ret.max_attempts_ = x; |
2774 | return ret; |
2775 | } |
2776 | |
2777 | /// Controls behavior if no bounding boxes supplied. |
2778 | /// If true, assume an implicit bounding box covering the whole input. If false, |
2779 | /// raise an error. |
2780 | /// |
2781 | /// Defaults to false |
2782 | TF_MUST_USE_RESULT Attrs UseImageIfNoBoundingBoxes(bool x) { |
2783 | Attrs ret = *this; |
2784 | ret.use_image_if_no_bounding_boxes_ = x; |
2785 | return ret; |
2786 | } |
2787 | |
2788 | gtl::ArraySlice<float> aspect_ratio_range_ = Default_aspect_ratio_range(); |
2789 | gtl::ArraySlice<float> area_range_ = Default_area_range(); |
2790 | int64 max_attempts_ = 100; |
2791 | bool use_image_if_no_bounding_boxes_ = false; |
2792 | private: |
2793 | static gtl::ArraySlice<float> Default_aspect_ratio_range() { |
2794 | static const float kStorage[] = {0.75f, 1.33f}; |
2795 | return gtl::ArraySlice<float>(kStorage); |
2796 | } |
2797 | static gtl::ArraySlice<float> Default_area_range() { |
2798 | static const float kStorage[] = {0.05f, 1.0f}; |
2799 | return gtl::ArraySlice<float>(kStorage); |
2800 | } |
2801 | }; |
2802 | StatelessSampleDistortedBoundingBox(const ::tensorflow::Scope& scope, |
2803 | ::tensorflow::Input image_size, |
2804 | ::tensorflow::Input bounding_boxes, |
2805 | ::tensorflow::Input min_object_covered, |
2806 | ::tensorflow::Input seed); |
2807 | StatelessSampleDistortedBoundingBox(const ::tensorflow::Scope& scope, |
2808 | ::tensorflow::Input image_size, |
2809 | ::tensorflow::Input bounding_boxes, |
2810 | ::tensorflow::Input min_object_covered, |
2811 | ::tensorflow::Input seed, const |
2812 | StatelessSampleDistortedBoundingBox::Attrs& |
2813 | attrs); |
2814 | |
2815 | static Attrs AspectRatioRange(const gtl::ArraySlice<float>& x) { |
2816 | return Attrs().AspectRatioRange(x); |
2817 | } |
2818 | static Attrs AreaRange(const gtl::ArraySlice<float>& x) { |
2819 | return Attrs().AreaRange(x); |
2820 | } |
2821 | static Attrs MaxAttempts(int64 x) { |
2822 | return Attrs().MaxAttempts(x); |
2823 | } |
2824 | static Attrs UseImageIfNoBoundingBoxes(bool x) { |
2825 | return Attrs().UseImageIfNoBoundingBoxes(x); |
2826 | } |
2827 | |
2828 | Operation operation; |
2829 | ::tensorflow::Output begin; |
2830 | ::tensorflow::Output size; |
2831 | ::tensorflow::Output bboxes; |
2832 | }; |
2833 | |
2834 | /// @} |
2835 | |
2836 | } // namespace ops |
2837 | } // namespace tensorflow |
2838 | |
2839 | #endif // TENSORFLOW_CC_OPS_IMAGE_OPS_H_ |
2840 | |