face_attribute_processing
🗿
Extract attributes from face images.
Classes:
Name | Description |
---|---|
FaceViews |
Class for face views. |
Functions:
Name | Description |
---|---|
cfd_var_converter |
Convert the |
display_face |
Display the |
display_set_of_faces |
Display a set of heads in a grid. |
face_image_path |
Construct the path to a face image. |
get_cfd_code_table |
Load the |
get_cfd_features |
Get |
get_cfd_features_for_models |
Get |
get_head_mapper_table |
Get the table for mapping head numbers to head indices. |
head_index_to_head_nr |
Convert the head index ( |
head_nr_to_index |
Convert the head number ( |
head_nr_to_main_matrix_index |
Convert a head number to a corresponding matrix index in the main study. |
head_nr_to_pilot_matrix_index |
Convert a head number to a corresponding matrix index for the pilot studies. |
heads_naming_converter_table |
Load the table for head naming conversion. |
list_faulty_heads |
List faulty heads (i.e., heads for which the reconstruction is not optimal). |
main_index_to_model_name |
Convert the head index to a head model name in the main study. |
main_matrix_index_to_head_nr |
Convert the index to a corresponding head number in the main study. |
pilot_index_to_model_name |
Convert the head index to the head model name. |
pilot_matrix_index_to_head_nr |
Convert the matrix index of a head to a head number in the pilot studies. |
FaceViews
🗿
FaceViews()
Class for face views.
Initialise FaceViews class.
Source code in code/facesim3d/modeling/face_attribute_processing.py
555 556 557 558 |
|
cfd_var_converter
🗿
cfd_var_converter(var_id_or_label: str) -> DataFrame
Convert the CFD
variable ID to a corresponding label name, and vice versa.
Source code in code/facesim3d/modeling/face_attribute_processing.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
display_face
🗿
display_face(
head_id: str | int,
data_mode: str = "3d-reconstructions",
angle: str | float | None = None,
interactive: bool = False,
show: bool = True,
verbose: bool = False,
) -> Image
Display the CFD
face given its head ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_id
|
str | int
|
either image name (e.g. "CFD-WF-001-003-N"), OR head number (e.g., "Head5"), OR head index |
required |
data_mode
|
str
|
path to the "2d-original", "3d-reconstructions", or "3d-perspectives" |
'3d-reconstructions'
|
angle
|
str | float | None
|
viewing angle of face to display [only if data_mode == "3d-perspectives"] |
None
|
interactive
|
bool
|
if True display 3D (.obj) in interactive mode. |
False
|
show
|
bool
|
if True show image |
True
|
verbose
|
bool
|
if True print the path to the image. |
False
|
Source code in code/facesim3d/modeling/face_attribute_processing.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
|
display_set_of_faces
🗿
display_set_of_faces(
list_head_ids: list[str | int],
data_mode: str,
num_suffix: str = "",
verbose: bool = False,
) -> tuple[Any, ndarray]
Display a set of heads in a grid.
Source code in code/facesim3d/modeling/face_attribute_processing.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
face_image_path
🗿
face_image_path(
head_id: str | int,
data_mode: str = "3d-reconstructions",
return_head_id: bool = False,
angle: float | str | None = None,
) -> str | tuple[str, int]
Construct the path to a face image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_id
|
str | int
|
Head number, as [str], e.g., "Head4", or as [int], e.g., 4. |
required |
data_mode
|
str
|
path to the "2d-original", "3d-reconstructions", or "3d-perspectives" |
'3d-reconstructions'
|
return_head_id
|
bool
|
whether to return the head number (as it appears in the rating files, 'TrialResults.csv') |
False
|
angle
|
float | str | None
|
for data_mode=="3d-perspectives", a face angle needs to be given. |
None
|
Returns:
Type | Description |
---|---|
str | tuple[str, int]
|
path to the face image |
Source code in code/facesim3d/modeling/face_attribute_processing.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 |
|
get_cfd_code_table
cached
🗿
get_cfd_code_table()
Load the CFD
code table.
Source code in code/facesim3d/modeling/face_attribute_processing.py
29 30 31 32 33 34 35 36 37 38 |
|
get_cfd_features
🗿
get_cfd_features(
set_name: str = "main",
drop_nan_col: bool = True,
physical_attr_only: bool = True,
) -> DataFrame
Get CFD
features.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
set_name
|
str
|
CFD set name |
'main'
|
drop_nan_col
|
bool
|
whether to drop columns that contain only nan |
True
|
physical_attr_only
|
bool
|
whether to drop columns that do not represent physical attributes |
True
|
Returns:
Type | Description |
---|---|
DataFrame
|
CFD feature table |
Source code in code/facesim3d/modeling/face_attribute_processing.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
|
get_cfd_features_for_models
🗿
get_cfd_features_for_models(
list_of_models: list[Any] | None = None,
physical_attr_only: bool = True,
) -> DataFrame
Get CFD
features for the given list of head models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
list_of_models
|
list[Any] | None
|
list of models |
None
|
physical_attr_only
|
bool
|
whether to drop columns that do not represent physical attributes |
True
|
Returns:
Type | Description |
---|---|
DataFrame
|
feature table for a list of models |
Source code in code/facesim3d/modeling/face_attribute_processing.py
99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
get_head_mapper_table
cached
🗿
get_head_mapper_table()
Get the table for mapping head numbers to head indices.
Source code in code/facesim3d/modeling/face_attribute_processing.py
114 115 116 117 |
|
head_index_to_head_nr
🗿
Convert the head index ('idx'
in 'headnmap.csv'
) to the head number ('Head#'
).
Note
This is the inverse function of head_nr_to_index()
.
For previous pilot experiments
This is not being used for the pilot experiment with fewer heads.
Returns:
Type | Description |
---|---|
str
|
head number |
Source code in code/facesim3d/modeling/face_attribute_processing.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
head_nr_to_index
🗿
Convert the head number ('Head#'
) to the head index ('idx'
in 'headnmap.csv'
).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_id
|
str | int | None
|
Head number, as [str], e.g., "Head4", or as [int], e.g., 4. |
required |
Returns:
Type | Description |
---|---|
int
|
head index |
Source code in code/facesim3d/modeling/face_attribute_processing.py
238 239 240 241 242 243 244 245 246 247 248 |
|
head_nr_to_main_matrix_index
🗿
Convert a head number to a corresponding matrix index in the main study.
Convert the head number (as they appear in the rating files, '*TrialResults*.csv'
) to the index as it
appears, e.g., in the similarity matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_id
|
str | int | None
|
Head number, as [str], e.g., "Head4", or as [int], e.g., 4. |
required |
Returns:
Type | Description |
---|---|
int
|
head index |
Source code in code/facesim3d/modeling/face_attribute_processing.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
head_nr_to_pilot_matrix_index
🗿
Convert a head number to a corresponding matrix index for the pilot studies.
Convert the head number (as they appear in the rating files, '*TrialResults*.csv'
) to the pilot index
as it appears, e.g., in the similarity matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
head_id
|
str | int | None
|
Head number, as [str], e.g., "Head4", or as [int], e.g., 4. |
required |
pilot_version
|
int
|
version of pilot (v1, v2) |
2
|
Returns:
Type | Description |
---|---|
int
|
head index |
Source code in code/facesim3d/modeling/face_attribute_processing.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
|
heads_naming_converter_table
🗿
heads_naming_converter_table(
pilot_version: int | None = None,
) -> DataFrame
Load the table for head naming conversion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pilot_version
|
int | None
|
None: for the main experiment, OR for pilot: 1, OR: 2. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
converter table |
Source code in code/facesim3d/modeling/face_attribute_processing.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
list_faulty_heads
🗿
List faulty heads (i.e., heads for which the reconstruction is not optimal).
DECA has a reported reconstructed error in the eyes (misalignment of the eyes), and open mouth, which is not open in the original image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run
|
bool
|
if True: open all images and fill in the faulty heads in the table. |
False
|
suffix
|
str
|
path suffix hinting to the focus of the observation among the face stimuli (e.g., 'eyes') |
''
|
Returns:
Type | Description |
---|---|
DataFrame
|
the list of faulty heads (IDs) |
Source code in code/facesim3d/modeling/face_attribute_processing.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
main_index_to_model_name
🗿
Convert the head index to a head model name in the main study.
Convert the main study index as it appears, e.g., in the similarity matrix to the name of the corresponding head
model (as it appears in the CFD
feature table (PFA
)).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face_idx
|
int
|
head index in pilot |
required |
Returns:
Type | Description |
---|---|
str
|
name of the head model |
Source code in code/facesim3d/modeling/face_attribute_processing.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
main_matrix_index_to_head_nr
🗿
Convert the index to a corresponding head number in the main study.
Convert the main index as it appears, e.g., in the similarity matrix to the corresponding head number
(as they appear in the rating files, '*TrialResults*.csv'
).
Note
This is the inverse function of head_nr_to_main_matrix_index()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
face_idx
|
int
|
head index in the main study |
required |
Returns:
Type | Description |
---|---|
str
|
the head number |
Source code in code/facesim3d/modeling/face_attribute_processing.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
pilot_index_to_model_name
🗿
Convert the head index to the head model name.
Convert the pilot index as it appears, e.g., in the similarity matrix to the corresponding name of the head model
(as it appears in the CFD
feature table (PFA
)).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pilot_face_idx
|
int
|
head index in the pilot experiment |
required |
pilot_version
|
int
|
the version of pilot experiment (v1, v2) |
2
|
Returns:
Type | Description |
---|---|
str
|
name of the head model |
Source code in code/facesim3d/modeling/face_attribute_processing.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|
pilot_matrix_index_to_head_nr
🗿
Convert the matrix index of a head to a head number in the pilot studies.
Convert the pilot index as it appears, e.g., in the similarity matrix to the corresponding head number
(as they appear in the rating files, '*TrialResults*.csv'
).
Note
This is the inverse function of head_nr_to_pilot_matrix_index()
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pilot_face_idx
|
int
|
head index in the pilot matrix |
required |
pilot_version
|
int
|
version of pilot experiment (v1, v2) |
2
|
Returns:
Type | Description |
---|---|
str
|
the head number |
Source code in code/facesim3d/modeling/face_attribute_processing.py
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|