Skip to content
Snippets Groups Projects
eval_SAR_TMR.py 975 B
Newer Older
Hatef OTROSHI's avatar
Hatef OTROSHI committed
# SPDX-FileCopyrightText: Copyright © 2024 Idiap Research Institute <contact@idiap.ch>
# SPDX-FileContributor: Hatef OTROSHI <hatef.otroshi@idiap.ch>
# SPDX-License-Identifier: MIT
import bob.bio.base

impostors, genuines = bob.bio.base.score.load.split_csv_scores('results/scores-dev.csv')
_, invertes = bob.bio.base.score.load.split_csv_scores('results/scores_inversion-dev.csv')

import numpy as np
def fmr_fnmr(neg, pos, threshold):
    fmr, fnmr = 0, 0
    fmr = np.mean(np.where(np.array(neg) >= threshold,1,0))
    fnmr = np.mean(np.where(np.array(pos) < threshold,1,0))
    return fmr, fnmr

from bob.measure import far_threshold


for FMR in [1e-2,1e-3]:
    threshold = far_threshold(impostors, genuines, far_value=FMR)
    fmr,fnmr = fmr_fnmr(impostors, genuines, threshold)
    _,uSAR   = fmr_fnmr(impostors, invertes, threshold)
    
    x = fmr
    SAR = 1-uSAR
    TMR = 1-fnmr
    
    print(f'FMR: {FMR} \t threshold: {threshold} \t TMR: {TMR}, SAR: {SAR}')