def _rezoom(hyp, pred_boxes, early_feat, early_feat_channels, w_offsets, h_offsets): #Rezoom into a feature map at multiple interpolation points #in a grid. #If the predicted object center is at X, len(w_offsets) == 3, #and len(h_offsets) == 5, #the rezoom grid will look as follows: #[o o o] #[o o o] #[o X o] #[o o o] #[o o o] #Where each letter indexes into the feature map with bilinear interpolation #grid size grid_size = hyp['grid_width'] * hyp['grid_height'] outer_size = grid_size * hyp['batch_size'] indices = [] for w_offset in w_offsets: for h_offset in h_offsets: indices.append(train_utils.bilinear_select(hyp, pred_boxes, early_feat, early_feat_channels, w_offset, h_offset)) #Rezoom into a feature map at multiple interpolation points interp_indices = tf.concat(axis=0, values=indices) rezoom_features = train_utils.interp(early_feat, interp_indices, early_feat_channels)
def rezoom(H, pred_boxes, early_feat, early_feat_channels, w_offsets, h_offsets): ''' Rezoom into a feature map at multiple interpolation points in a grid. If the predicted object center is at X, len(w_offsets) == 3, and len(h_offsets) == 5, the rezoom grid will look as follows: [o o o] [o o o] [o X o] [o o o] [o o o] Where each letter indexes into the feature map with bilinear interpolation ''' grid_size = H['grid_width'] * H['grid_height'] outer_size = grid_size * H['batch_size'] indices = [] for w_offset in w_offsets: for h_offset in h_offsets: indices.append( train_utils.bilinear_select(H, pred_boxes, early_feat, early_feat_channels, w_offset, h_offset)) interp_indices = tf.concat(axis=0, values=indices) rezoom_features = train_utils.interp(early_feat, interp_indices, early_feat_channels) rezoom_features_r = tf.reshape(rezoom_features, [ len(w_offsets) * len(h_offsets), outer_size, H['rnn_len'], early_feat_channels ]) rezoom_features_t = tf.transpose(rezoom_features_r, [1, 2, 0, 3]) return tf.reshape(rezoom_features_t, [ outer_size, H['rnn_len'], len(w_offsets) * len(h_offsets) * early_feat_channels ])
def rezoom(H, pred_boxes, early_feat, early_feat_channels, w_offsets, h_offsets): ''' Rezoom into a feature map at multiple interpolation points in a grid. If the predicted object center is at X, len(w_offsets) == 3, and len(h_offsets) == 5, the rezoom grid will look as follows: [o o o] [o o o] [o X o] [o o o] [o o o] Where each letter indexes into the feature map with bilinear interpolation ''' grid_size = H['grid_width'] * H['grid_height'] outer_size = grid_size * H['batch_size'] indices = [] for w_offset in w_offsets: for h_offset in h_offsets: indices.append(train_utils.bilinear_select(H, pred_boxes, early_feat, early_feat_channels, w_offset, h_offset)) interp_indices = tf.concat(0, indices) rezoom_features = train_utils.interp(early_feat, interp_indices, early_feat_channels) rezoom_features_r = tf.reshape(rezoom_features, [len(w_offsets) * len(h_offsets), outer_size, H['rnn_len'], early_feat_channels]) rezoom_features_t = tf.transpose(rezoom_features_r, [1, 2, 0, 3]) return tf.reshape(rezoom_features_t, [outer_size, H['rnn_len'], len(w_offsets) * len(h_offsets) * early_feat_channels])
def rezoom(H, pred_boxes, early_feat, early_feat_channels, w_offsets, h_offsets): grid_size = H['grid_width'] * H['grid_height'] outer_size = grid_size * H['batch_size'] indices = [] for w_offset in w_offsets: for h_offset in h_offsets: indices.append( train_utils.bilinear_select(H, pred_boxes, early_feat, early_feat_channels, w_offset, h_offset)) interp_indices = tf.concat(axis=0, values=indices) rezoom_features = train_utils.interp(early_feat, interp_indices, early_feat_channels) rezoom_features_r = tf.reshape(rezoom_features, [ len(w_offsets) * len(h_offsets), outer_size, H['rnn_len'], early_feat_channels ]) rezoom_features_t = tf.transpose(rezoom_features_r, [1, 2, 0, 3]) return tf.reshape(rezoom_features_t, [ outer_size, H['rnn_len'], len(w_offsets) * len(h_offsets) * early_feat_channels ])