def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): """ input:'conv5_3', 'roi-data' roi-data: (1) rois: (num of finally left proposal(根据每个roi和gtbox的overlaps大小来确定留下的fg和bg,多了的随机选择) blob[:,0]=0; blob[:-2,1:5] = x1,y1,x2,y2(pred box in original image); blob[-2:,1:5] = x1,y1,x2,y2(gt_box) [0:fg_rois_per_this_image(大约42)]: the left foregound; [fg_rois_per_this_image(128-42):]:the left background (2) labels: the final classes of the ground truth correspounding to per pred box [num of finally left proposal(128),] for ex: [9,15,15,15,9,9....] (3): num of finally left proposals(128) * 4*21: [dx,dy,dw,dh](gt_boxes相对于rois) of 1 class (4): num of finally left proposals * 4*21: [1, 1, 1, 1] of 1 class (5): num of finally left proposals * 4*21: [true,true,true,true] of 1 class in 21; [false, false, false, false] in left of the classes roi_pool(7, 7, 1.0/16, name='pool_5') """ # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] print input return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] """"# often called with: .roi_pool(7, 7, 1.0/16, name='pool_5') print('................ roi pooling (network.py) .......................') print(input[1][0]) # rois_wo print(input[1][1]) # labels print(input[1][2]) print(input[1][3]) print(input[1][4]) print(input[1][5]) # gt_orientations_new print(input[1][6]) # orientations_pred_new print(input[1][7]) # orientations_targets_new""" if isinstance(input[1], tuple): input[1] = input[1][0] input_1a = input[1][:, 0:5] # rpn_rois as original, no orientations input_1b = input[1][:, 5:6] # orientations as predicted return roi_pool_op.roi_pool(input[0], input_1a, input_1b, pooled_height, pooled_width, spatial_scale, name=name)[0]
def _roi_pool_layer(self, bootom, rois, name): print('ROI Pooling...') with tf.variable_scope(name) as scope: return roi_pool_op.roi_pool(bootom, rois, pooled_height=cfg.POOLING_SIZE, pooled_width=cfg.POOLING_SIZE, spatial_scale=1. / 16., name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, pool_channel, name): # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, pool_channel, name=name)
def load_detection_model(ws): assert len(ws) == 8 data_blob = tf.placeholder(tf.float32) rois_blob = tf.placeholder(tf.float32, shape=[None, 5]) pool5, _ = roi_pooling_op.roi_pool(data_blob, rois_blob, 7, 7, 0.0625) flat_pool5 = tf.reshape(pool5, [-1, 25088]) fc6 = fc(flat_pool5, ws[0], ws[1]) fc7 = fc(fc6, ws[2], ws[3]) cls_prob = fc(fc7, ws[4], ws[5], 'softmax') bbox_pred = fc(fc7, ws[6], ws[7], 'linear') return data_blob, rois_blob, cls_prob, bbox_pred
def roi_pool(self, input, pooled_h, pooled_w, spatial_scale, name): #only use the first input? what's the meaning if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] # print("roi_pool is :",input) return roi_pool_op.roi_pool(input[0], input[1], pooled_h, pooled_w, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] print input return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): """ Rol pooling层有2个输入: 1. 原始的feature maps 2. RPN输出的proposal boxes(大小各不相同) """ # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][1] print input return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name = name)[0]
def roi_pool(self, inputs, pooled_height, pooled_width, spatial_scale, name): with tf.name_scope(name): # only use the first input if isinstance(inputs[0], tuple): inputs[0] = inputs[0][0] if isinstance(inputs[1], tuple): inputs[1] = inputs[1][0] print(inputs) return roi_pool_op.roi_pool(inputs[0], inputs[1], pooled_height, pooled_width, spatial_scale, name=name)[0]
def frcnn_roi_pooling(self, features, rois, pooled_height, pooled_width, \ spatial_scale, name = "pool_5"): ''' input: features : Nbatch , h , w , C rois : NROI x 5 output: pooled_features: NROI x 7 x 7 x C ''' return roi_pool_op.roi_pool(features, rois, pooled_height, pooled_width, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] # Input[0] is the Feature map and Input[1] is the ROI data print(input) return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): # only use the first input ??? 因为 roi-data[0]才是rois,其他索引对应的是别的信息 # pooled_height=7;pooled_width=7;spatial_scale=1.0/16 if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] print input # input[0]是'conv5_3'[0]; input[1]是'roi-data'[0] return roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name=name)[0]
def roi_pool(self, input, pooled_height, pooled_width, spatial_scale, name): # only use the first input if isinstance(input[0], tuple): input[0] = input[0][0] if isinstance(input[1], tuple): input[1] = input[1][0] print "RoI input[0] = ", input[0], " input [1]= ", input[1], output = roi_pool_op.roi_pool(input[0], input[1], pooled_height, pooled_width, spatial_scale, name=name)[0] print "RoI output =", output return output