Python tensorflow.crop_and_resize() Examples
The following are 6
code examples of tensorflow.crop_and_resize().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow
, or try the search function
.
Example #1
Source File: anchor_projector.py From avod with MIT License | 6 votes |
def reorder_projected_boxes(box_corners): """Helper function to reorder image corners. This reorders the corners from [x1, y1, x2, y2] to [y1, x1, y2, x2] which is required by the tf.crop_and_resize op. Args: box_corners: tensor image corners in the format N x [x1, y1, x2, y2] Returns: box_corners_reordered: tensor image corners in the format N x [y1, x1, y2, x2] """ boxes_reordered = tf.stack([box_corners[:, 1], box_corners[:, 0], box_corners[:, 3], box_corners[:, 2]], axis=1) return boxes_reordered
Example #2
Source File: anchor_projector.py From TLNet with Apache License 2.0 | 6 votes |
def reorder_projected_boxes(box_corners): """Helper function to reorder image corners. This reorders the corners from [x1, y1, x2, y2] to [y1, x1, y2, x2] which is required by the tf.crop_and_resize op. Args: box_corners: tensor image corners in the format N x [x1, y1, x2, y2] Returns: box_corners_reordered: tensor image corners in the format N x [y1, x1, y2, x2] """ boxes_reordered = tf.stack([box_corners[:, 1], box_corners[:, 0], box_corners[:, 3], box_corners[:, 2]], axis=1) return boxes_reordered
Example #3
Source File: anchor_projector.py From avod-ssd with MIT License | 6 votes |
def reorder_projected_boxes(box_corners): """Helper function to reorder image corners. This reorders the corners from [x1, y1, x2, y2] to [y1, x1, y2, x2] which is required by the tf.crop_and_resize op. Args: box_corners: tensor image corners in the format N x [x1, y1, x2, y2] Returns: box_corners_reordered: tensor image corners in the format N x [y1, x1, y2, x2] """ boxes_reordered = tf.stack([box_corners[:, 1], box_corners[:, 0], box_corners[:, 3], box_corners[:, 2]], axis=1) return boxes_reordered
Example #4
Source File: roi_pool.py From Table-Detection-using-Deep-learning with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _roi_crop(self, roi_proposals, conv_feature_map, im_shape): # Get normalized bounding boxes. bboxes = self._get_bboxes(roi_proposals, im_shape) # Generate fake batch ids bboxes_shape = tf.shape(bboxes) batch_ids = tf.zeros((bboxes_shape[0], ), dtype=tf.int32) # Apply crop and resize with extracting a crop double the desired size. crops = tf.image.crop_and_resize( conv_feature_map, bboxes, batch_ids, [self._pooled_width * 2, self._pooled_height * 2], name="crops" ) # Applies max pool with [2,2] kernel to reduce the crops to half the # size, and thus having the desired output. prediction_dict = { 'roi_pool': tf.nn.max_pool( crops, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding=self._pooled_padding ), } if self._debug: prediction_dict['bboxes'] = bboxes prediction_dict['crops'] = crops prediction_dict['batch_ids'] = batch_ids prediction_dict['conv_feature_map'] = conv_feature_map return prediction_dict
Example #5
Source File: roi_pool.py From Tabulo with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _roi_crop(self, roi_proposals, conv_feature_map, im_shape): # Get normalized bounding boxes. bboxes = self._get_bboxes(roi_proposals, im_shape) # Generate fake batch ids bboxes_shape = tf.shape(bboxes) batch_ids = tf.zeros((bboxes_shape[0], ), dtype=tf.int32) # Apply crop and resize with extracting a crop double the desired size. crops = tf.image.crop_and_resize( conv_feature_map, bboxes, batch_ids, [self._pooled_width * 2, self._pooled_height * 2], name="crops" ) # Applies max pool with [2,2] kernel to reduce the crops to half the # size, and thus having the desired output. prediction_dict = { 'roi_pool': tf.nn.max_pool( crops, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding=self._pooled_padding ), } if self._debug: prediction_dict['bboxes'] = bboxes prediction_dict['crops'] = crops prediction_dict['batch_ids'] = batch_ids prediction_dict['conv_feature_map'] = conv_feature_map return prediction_dict
Example #6
Source File: roi_pool.py From luminoth with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _roi_crop(self, roi_proposals, conv_feature_map, im_shape): # Get normalized bounding boxes. bboxes = self._get_bboxes(roi_proposals, im_shape) # Generate fake batch ids bboxes_shape = tf.shape(bboxes) batch_ids = tf.zeros((bboxes_shape[0], ), dtype=tf.int32) # Apply crop and resize with extracting a crop double the desired size. crops = tf.image.crop_and_resize( conv_feature_map, bboxes, batch_ids, [self._pooled_width * 2, self._pooled_height * 2], name="crops" ) # Applies max pool with [2,2] kernel to reduce the crops to half the # size, and thus having the desired output. prediction_dict = { 'roi_pool': tf.nn.max_pool( crops, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding=self._pooled_padding ), } if self._debug: prediction_dict['bboxes'] = bboxes prediction_dict['crops'] = crops prediction_dict['batch_ids'] = batch_ids prediction_dict['conv_feature_map'] = conv_feature_map return prediction_dict