Commenting out the ethnicity prediction for FairFace. Minor changes.
This commit is contained in:
@@ -10,8 +10,7 @@ from typing import Any, Callable
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logger = logging.getLogger(__name__)
|
||||
logger = logging.getLogger(f"facebias:{__name__}")
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -22,6 +21,8 @@ class FaceBox:
|
||||
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]]:
|
||||
lines = []
|
||||
with open(p, newline="") as csvfile:
|
||||
|
||||
@@ -70,9 +70,9 @@ class FairFace(BaseEstimator):
|
||||
y = y.cpu().detach().squeeze().numpy()
|
||||
|
||||
# Ethnicity prediction
|
||||
y_ethno = y[:4]
|
||||
ethno_score = np.exp(y_ethno) / np.sum(np.exp(y_ethno))
|
||||
ethno_pred = np.argmax(ethno_score)
|
||||
# y_ethno = y[:4]
|
||||
# ethno_score = np.exp(y_ethno) / np.sum(np.exp(y_ethno))
|
||||
# ethno_pred = np.argmax(ethno_score)
|
||||
|
||||
# Age prediction
|
||||
y_age = y[9:18]
|
||||
@@ -96,9 +96,9 @@ class FairFace(BaseEstimator):
|
||||
def capabilities() -> list[Capability]:
|
||||
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:
|
||||
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:
|
||||
return ['m', 'f']
|
||||
# elif cap == Capability.ETHNICITY:
|
||||
@@ -108,8 +108,7 @@ class FairFace(BaseEstimator):
|
||||
|
||||
|
||||
def _to_age_label(age):
|
||||
return FairFace.possible_classes(Capability.AGEGROUP)[age]
|
||||
# return "{}-{}".format(age * 10, age * 10 + 9)
|
||||
return FairFace.possible_capability_values(Capability.AGEGROUP)[age]
|
||||
|
||||
|
||||
def _to_ethno_label(val):
|
||||
|
||||
Reference in New Issue
Block a user