Пример #1
0
            mean_overlapping_bboxes = float(
                sum(rpn_accuracy_rpn_monitor)) / len(rpn_accuracy_rpn_monitor)
            rpn_accuracy_rpn_monitor = []
            dprint(
                'Average number of overlapping bounding boxes from RPN = {} for {} previous iterations'
                .format(mean_overlapping_bboxes, epoch_length))
            if mean_overlapping_bboxes == 0:
                dprint(
                    'RPN is not producing bounding boxes that overlap the ground truth boxes. Results will not be satisfactory. Keep training.'
                )

        X, Y, img_data = next(data_gen_train)

        loss_rpn = model_rpn.train_on_batch(X, Y)

        P_rpn = model_rpn.predict_on_batch(X)

        R = roi_helpers.rpn_to_roi(P_rpn[0],
                                   P_rpn[1],
                                   C,
                                   use_regr=True,
                                   overlap_thresh=0.7,
                                   max_boxes=300)

        # note: calc_iou converts from (x1,y1,x2,y2) to (x,y,w,h) format
        X2, Y1, Y2 = roi_helpers.calc_iou(R, img_data, C, class_mapping)

        if X2 is None:
            rpn_accuracy_rpn_monitor.append(0)
            rpn_accuracy_for_epoch.append(0)
            continue
Пример #2
0
	  '            this implementation relies on multiprocessing,\n',
	  '            you should not pass\n',
	  '            non picklable arguments to the generator\n',
	  "            as they can't be passed\n",
	  '            easily to children processes.\n',
	  '        verbose: verbosity mode, 0 or 1.\n',
	  '\n',
	  '    Returns:\n',
	  '        Numpy array(s) of predictions.\n',
	  '\n',
	  '    Raises:\n',
	  '        ValueError: In case the generator yields\n',
	  '            data in an invalid format.\n',
	"""

	preds_batch = model.predict_on_batch(val_img_array)

	"""
	(['  def predict_on_batch(self, x):\n',
	  '    Returns predictions for a single batch of samples.\n',
	  '\n',
	  '    Arguments:\n',
	  '        x: Input samples, as a Numpy array.\n',
	  '\n',
	  '    Returns:\n',
	  '        Numpy array(s) of predictions.\n',
	"""


# how weights of model are saved
model.save_weights("/Users/Natsume/Downloads/data_for_all/dogscats/experiments/weights.h5")