anchor_scales = [3, 4, 5] # BBOX OP # INV inv_blobs_op OP = return to the original Coordinate # INV target_inv_blobs_op OP = return to the original Coordinate (indices ) inv_blobs_op , target_inv_blobs_op = inv_transform_layer(rpn_bbox_pred , cfg_key = phase_train , \ _feat_stride = _feat_stride , anchor_scales =anchor_scales , indices = indice_op) blobs_op, scores_op = roi.roi_proposal(rpn_cls, rpn_bbox_pred, im_dims, _feat_stride, anchor_scales, is_training=True) cost_op = rpn_cls_loss_op + rpn_bbox_loss_op train_cls_op = optimizer(rpn_cls_loss_op, lr=0.01) train_bbox_op = optimizer(rpn_bbox_loss_op, lr=0.001) train_op = optimizer(cost_op, lr=0.001) sess = sess_start() max_iter = 55000 * 100 for i in range(2, max_iter): src_img, src_gt_boxes = next_img_gtboxes(i) h, w = np.shape(src_img) src_im_dims = [(h, w)] rpn_cls_score = np.zeros( [1, int(math.ceil(h / 8.)), int(math.ceil(w / 8.)), 512]) rpn_labels, rpn_bbox_targets, rpn_bbox_inside_weights, rpn_bbox_outside_weights, bbox_targets, bbox_inside_weights, bbox_outside_weights = anchor_target( rpn_cls_score=rpn_cls_score,
rpn_bbox_pred = rpn_bbox_layer(top_conv) # CLS LOSS rpn_cls_loss_op ,A_op ,B_op = rpn_cls_loss(rpn_cls , rpn_labels_op) # BBOX LOSS # C_op : indiced rpn bbox pred op # D_op :indiced rpn target op # E_op : rpn_inside_weights # F_op : indices rpn_bbox_loss_op , diff_op , C_op , D_op ,E_op ,F_op = \ rpn_bbox_loss(rpn_bbox_pred ,bbox_targets_op , bbox_inside_weights_op , bbox_outside_weights_op , rpn_labels_op) cost_op = rpn_bbox_loss_op + rpn_cls_loss_op rpn_cls_train_op = optimizer(rpn_cls_loss_op) rpn_bbox_train_op = optimizer(rpn_bbox_loss_op ) train_op = optimizer(rpn_bbox_loss_op ) sess=sess_start() for i in range(2,55000 * 100): src_img , src_gt_boxes =next_img_gtboxes(i) h,w=np.shape(src_img) src_im_dims = [(h,w)] anchor_scales = [3,4,5] rpn_cls_score=np.zeros([1,int(math.ceil(h/8.)),int(math.ceil(w/8.)),512]) rpn_labels, rpn_bbox_targets, rpn_bbox_inside_weights, rpn_bbox_outside_weights, bbox_targets, bbox_inside_weights, bbox_outside_weights = anchor_target( rpn_cls_score=rpn_cls_score, gt_boxes=src_gt_boxes, im_dims=src_im_dims, _feat_stride=8, anchor_scales=anchor_scales) """
# fast rcnn blobs op shape : 1, N , 4 *n_classes # itr_fr_blobs_op = inv_transform_layer_fastrcnn(rois_op, itr_fr_bbox_target_op) # inv_ptl_rois_op = inv_transform_layer_fastrcnn(ptl_rois_op , ptl_bbox_targets_op) # 임시로 되돌려 만들어 본다 , ptl 은 추천된 박스 영상과 동일해야 한다. # FAST RCNN COST fr_cls_loss_op = fast_rcnn_cls_loss(fast_rcnn_cls_logits, ptl_labels_op) fr_bbox_loss_op = fast_rcnn_bbox_loss(fast_rcnn_bbox_logits, ptl_bbox_targets_op, ptl_bbox_inside_weights_op, ptl_bbox_outside_weights_op) # Train op and Loss op rpn_cost_op = rpn_cls_loss_op + rpn_bbox_loss_op fr_cost_op = fr_cls_loss_op + fr_bbox_loss_op cost_op = rpn_cost_op + fr_cost_op train_op = optimizer(cost_op, lr=0.0001) # Start Session sess = sess_start() # Saver saver = tf.train.Saver(max_to_keep=10) # Write log tb_writer = tf.summary.FileWriter('logs') tb_writer.add_graph(tf.get_default_graph()) # max_iter = 485 * 3000 max_acc = 0 # start Training start_time = time.time() for i in range(0, max_iter): try: