File size: 893 Bytes
e619b9a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#src/evaluate.py

import numpy as np
import pandas as pd
from sklearn.metrics import roc_curve
import tensorflow as tf
from reference.dataloader import load_image

MODEL_PATH = "models/iris_siamese.h5"
CSV_FILE = "pairs/iris_pairs.csv"

model = tf.keras.models.load_model(MODEL_PATH, compile=False)

df = pd.read_csv(CSV_FILE)

scores = []
labels = []

for _, row in df.iterrows():
    img1 = load_image(row["img1"])
    img2 = load_image(row["img2"])

    img1 = tf.expand_dims(img1, axis=0)
    img2 = tf.expand_dims(img2, axis=0)

    score = model.predict([img1, img2], verbose=0)[0][0]
    scores.append(score)
    labels.append(row["label"])

scores = np.array(scores)
labels = np.array(labels)

fpr, tpr, thresholds = roc_curve(labels, scores)

eer_threshold = thresholds[np.argmin(abs(fpr - (1 - tpr)))]

print("✅ EER Threshold:", eer_threshold)