(num_gbboxes, tp, fp, scores,
                           remove_zero_scores=True,
                           metrics_collections=None,
                           updates_collections=None,
                           name=None)
Streaming computation of True and False Positive arrays. This metrics
    also keeps track of scores and number of grountruth objects.
Streaming computation of True and False Positive arrays. This metrics
    also keeps track of scores and number of grountruth objects.
Streaming computation of True and False Positive arrays . This metrics also keeps track of scores and number of grountruth objects .
def streaming_tp_fp_arrays(num_gbboxes, tp, fp, scores,
                           remove_zero_scores=True,
                           metrics_collections=None,
                           updates_collections=None,
                           name=None):
    """Streaming computation of True and False Positive arrays. This metrics
    also keeps track of scores and number of grountruth objects.
    """
    # Input dictionaries: dict outputs as streaming metrics.
    if isinstance(scores, dict) or isinstance(fp, dict):
        d_values = {}
        d_update_ops = {}
        for c in num_gbboxes.keys():
            scope = 'streaming_tp_fp_%s' % c
            v, up = streaming_tp_fp_arrays(num_gbboxes[c], tp[c], fp[c], scores[c],
                                           remove_zero_scores,
                                           metrics_collections,
                                           updates_collections,
                                           name=scope)
            d_values[c] = v
            d_update_ops[c] = up
        return d_values, d_update_ops

    # Input Tensors...
    with variable_scope.variable_scope(name, 'streaming_tp_fp',
                                       [num_gbboxes, tp, fp, scores]):
        num_gbboxes = math_ops.to_int64(num_gbboxes)
        scores = math_ops.to_float(scores)
        stype = tf.bool
        tp = tf.cast(tp, stype)
        fp = tf.cast(fp, stype)
        # Reshape TP and FP tensors and clean away 0 class values.
        scores = tf.reshape(scores, [-1])
        tp = tf.reshape(tp, [-1])
        fp = tf.reshape(fp, [-1])
        # Remove TP and FP both false.
        mask = tf.logical_or(tp, fp)
        if remove_zero_scores:
            rm_threshold = 1e-4
            mask = tf.logical_and(mask, tf.greater(scores, rm_threshold))
            scores = tf.boolean_mask(scores, mask)
            tp = tf.boolean_mask(tp, mask)
            fp = tf.boolean_mask(fp, mask)

        # Local variables accumlating information over batches.
        v_nobjects = _create_local('v_num_gbboxes', shape=[], dtype=tf.int64)
        v_ndetections = _create_local('v_num_detections', shape=[], dtype=tf.int32)
        v_scores = _create_local('v_scores', shape=[0, ])
        v_tp = _create_local('v_tp', shape=[0, ], dtype=stype)
        v_fp = _create_local('v_fp', shape=[0, ], dtype=stype)

        # Update operations.
        nobjects_op = state_ops.assign_add(v_nobjects,
                                           tf.reduce_sum(num_gbboxes))
        ndetections_op = state_ops.assign_add(v_ndetections,
                                              tf.size(scores, out_type=tf.int32))
        scores_op = state_ops.assign(v_scores, tf.concat([v_scores, scores], axis=0),
                                     validate_shape=False)
        tp_op = state_ops.assign(v_tp, tf.concat([v_tp, tp], axis=0),
                                 validate_shape=False)
        fp_op = state_ops.assign(v_fp, tf.concat([v_fp, fp], axis=0),
                                 validate_shape=False)

        # Value and update ops.
        val = (v_nobjects, v_ndetections, v_tp, v_fp, v_scores)
        with ops.control_dependencies([nobjects_op, ndetections_op,
                                       scores_op, tp_op, fp_op]):
            update_op = (nobjects_op, ndetections_op, tp_op, fp_op, scores_op)

        val = [tf.convert_to_tensor(_) for _ in val]
        if metrics_collections:
            ops.add_to_collections(metrics_collections, val)
        if updates_collections:
            ops.add_to_collections(updates_collections, update_op)
        return val, update_op
def streaming_tp_fp_arrays ( num_gbboxes , tp , fp , scores , remove_zero_scores = True , metrics_collections = None , updates_collections = None , name = None ) : # Input dictionaries: dict outputs as streaming metrics. if isinstance ( scores , dict ) or isinstance ( fp , dict ) : d_values = { } d_update_ops = { } for c in num_gbboxes . keys ( ) : scope = 'streaming_tp_fp_%s' % c v , up = streaming_tp_fp_arrays ( num_gbboxes [ c ] , tp [ c ] , fp [ c ] , scores [ c ] , remove_zero_scores , metrics_collections , updates_collections , name = scope ) d_values [ c ] = v d_update_ops [ c ] = up return d_values , d_update_ops # Input Tensors... with variable_scope . variable_scope ( name , 'streaming_tp_fp' , [ num_gbboxes , tp , fp , scores ] ) : num_gbboxes = math_ops . to_int64 ( num_gbboxes ) scores = math_ops . to_float ( scores ) stype = tf . bool tp = tf . cast ( tp , stype ) fp = tf . cast ( fp , stype ) # Reshape TP and FP tensors and clean away 0 class values. scores = tf . reshape ( scores , [ - 1 ] ) tp = tf . reshape ( tp , [ - 1 ] ) fp = tf . reshape ( fp , [ - 1 ] ) # Remove TP and FP both false. mask = tf . logical_or ( tp , fp ) if remove_zero_scores : rm_threshold = 1e-4 mask = tf . logical_and ( mask , tf . greater ( scores , rm_threshold ) ) scores = tf . boolean_mask ( scores , mask ) tp = tf . boolean_mask ( tp , mask ) fp = tf . boolean_mask ( fp , mask ) # Local variables accumlating information over batches. v_nobjects = _create_local ( 'v_num_gbboxes' , shape = [ ] , dtype = tf . int64 ) v_ndetections = _create_local ( 'v_num_detections' , shape = [ ] , dtype = tf . int32 ) v_scores = _create_local ( 'v_scores' , shape = [ 0 , ] ) v_tp = _create_local ( 'v_tp' , shape = [ 0 , ] , dtype = stype ) v_fp = _create_local ( 'v_fp' , shape = [ 0 , ] , dtype = stype ) # Update operations. nobjects_op = state_ops . assign_add ( v_nobjects , tf . reduce_sum ( num_gbboxes ) ) ndetections_op = state_ops . assign_add ( v_ndetections , tf . size ( scores , out_type = tf . int32 ) ) scores_op = state_ops . assign ( v_scores , tf . concat ( [ v_scores , scores ] , axis = 0 ) , validate_shape = False ) tp_op = state_ops . assign ( v_tp , tf . concat ( [ v_tp , tp ] , axis = 0 ) , validate_shape = False ) fp_op = state_ops . assign ( v_fp , tf . concat ( [ v_fp , fp ] , axis = 0 ) , validate_shape = False ) # Value and update ops. val = ( v_nobjects , v_ndetections , v_tp , v_fp , v_scores ) with ops . control_dependencies ( [ nobjects_op , ndetections_op , scores_op , tp_op , fp_op ] ) : update_op = ( nobjects_op , ndetections_op , tp_op , fp_op , scores_op ) val = [ tf . convert_to_tensor ( _ ) for _ in val ] if metrics_collections : ops . add_to_collections ( metrics_collections , val ) if updates_collections : ops . add_to_collections ( updates_collections , update_op ) return val , update_op