selvaneyas's picture
Upload 7 files
e619b9a verified
raw
history blame contribute delete
893 Bytes
#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)