INNER CODE UNIT · Python

n_energy

lucasb-eyer/pydensecrf · pydensecrf/utils.py:33

    n_energy = -np.log((1.0 - gt_prob) / (n_labels - 1))
    p_energy = -np.log(gt_prob)

    # Note that the order of the following operations is important.
    # That's because the later ones overwrite part of the former ones, and only
    # after all of them is `U` correct!
    U = np.full((n_labels, len(labels)), n_energy, dtype='float32')
    U[labels - 1 if zero_unsure else labels, np.arange(U.shape[1])] = p_energy

    # Overwrite 0-labels using uniform probability, i.e. "unsure".
    if zero_unsure:
        U[:, labels == 0] = -np.log(1.0 / n_labels)

    return U


def compute_unary(labels, M, GT_PROB=0.5):
    """Deprecated, use `unary_from_labels` instead."""

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…