Commenting out the ethnicity prediction for FairFace. Minor changes.

This commit is contained in:
2026-05-05 15:18:43 +01:00
parent 20cf80d94e
commit af43c00aa0
2 changed files with 9 additions and 9 deletions

View File

@@ -10,8 +10,7 @@ from typing import Any, Callable
import cv2 import cv2
import numpy as np import numpy as np
logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(f"facebias:{__name__}")
logger = logging.getLogger(__name__)
@dataclass @dataclass
@@ -22,6 +21,8 @@ class FaceBox:
y2: int y2: int
# TODO(gschardong): Convert all CSV reading functions to pandas
def load_metadata(p: Path, key_id="image", key_proc_fn=None) -> dict[str, dict[str, str]]: def load_metadata(p: Path, key_id="image", key_proc_fn=None) -> dict[str, dict[str, str]]:
lines = [] lines = []
with open(p, newline="") as csvfile: with open(p, newline="") as csvfile:

View File

@@ -70,9 +70,9 @@ class FairFace(BaseEstimator):
y = y.cpu().detach().squeeze().numpy() y = y.cpu().detach().squeeze().numpy()
# Ethnicity prediction # Ethnicity prediction
y_ethno = y[:4] # y_ethno = y[:4]
ethno_score = np.exp(y_ethno) / np.sum(np.exp(y_ethno)) # ethno_score = np.exp(y_ethno) / np.sum(np.exp(y_ethno))
ethno_pred = np.argmax(ethno_score) # ethno_pred = np.argmax(ethno_score)
# Age prediction # Age prediction
y_age = y[9:18] y_age = y[9:18]
@@ -96,9 +96,9 @@ class FairFace(BaseEstimator):
def capabilities() -> list[Capability]: def capabilities() -> list[Capability]:
return [Capability.AGEGROUP, Capability.SEX] #, Capability.ETHNICITY] return [Capability.AGEGROUP, Capability.SEX] #, Capability.ETHNICITY]
def possible_capability_values(cap: Capability) -> list: def possible_capability_values(cap: Capability) -> list[str]:
if cap == Capability.AGEGROUP: if cap == Capability.AGEGROUP:
return ["0-2", "3-9", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70+"] return ["00-02", "03-09", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70+"]
elif cap == Capability.SEX: elif cap == Capability.SEX:
return ['m', 'f'] return ['m', 'f']
# elif cap == Capability.ETHNICITY: # elif cap == Capability.ETHNICITY:
@@ -108,8 +108,7 @@ class FairFace(BaseEstimator):
def _to_age_label(age): def _to_age_label(age):
return FairFace.possible_classes(Capability.AGEGROUP)[age] return FairFace.possible_capability_values(Capability.AGEGROUP)[age]
# return "{}-{}".format(age * 10, age * 10 + 9)
def _to_ethno_label(val): def _to_ethno_label(val):