prepare_data
🗿
Prepare data for VGG
models.
Classes:
Name | Description |
---|---|
VGGFaceHumanjudgmentDataset |
Dataset for the |
VGGMultiViewDataset |
Dataset for the |
Functions:
Name | Description |
---|---|
get_multi_view_data |
Get the multi-view data. |
load_image_for_model |
Load an image for the |
prepare_data_for_human_judgment_model |
Prepare data for the |
prepare_data_for_multi_view_model |
Prepare data for the multi-view model. |
revert_model_image |
Revert a model-input-image to its original form. |
VGGFaceHumanjudgmentDataset
🗿
VGGFaceHumanjudgmentDataset(
session: str,
frozen_core: bool,
data_mode: str = "2d-original",
last_core_layer: str | None = None,
dtype: dtype = float32,
size: int | None = None,
exclusive_gender_trials: str | None = None,
heads: list[int] | ndarray[int] | int | None = None,
**kwargs
)
Bases: Dataset
Dataset for the VGG-Face
model variant, adapted for human similarity judgments.
Initialize the VGGFaceHumanjudgmentDataset
.
Methods:
Name | Description |
---|---|
display_triplet |
Display a triplet of images. |
Attributes:
Name | Type | Description |
---|---|---|
current_index |
Return the current index. |
|
data_mode |
Return the data mode. |
|
exclusive_gender_trials |
str | None
|
Return the |
last_core_layer |
Return the cut layer of the |
|
session_data |
Return the session data. |
|
vgg_core_output |
Return the |
Source code in code/facesim3d/modeling/VGG/prepare_data.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
exclusive_gender_trials
property
writable
🗿
exclusive_gender_trials: str | None
Return the exclusive_gender_trials
configuration.
display_triplet
🗿
Display a triplet of images.
Source code in code/facesim3d/modeling/VGG/prepare_data.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 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 |
|
VGGMultiViewDataset
🗿
VGGMultiViewDataset(
frozen_core: bool,
last_core_layer: str | None = None,
dtype: dtype = float32,
heads: list[int] | ndarray[int] | int | None = None,
**kwargs
)
Bases: Dataset
Dataset for the VGG-Multi-View-Face
model.
Initialize the VGGMultiViewDataset
.
Methods:
Name | Description |
---|---|
display_image |
Display face images with a specific angle. |
Attributes:
Name | Type | Description |
---|---|---|
current_index |
Return the current index. |
|
last_core_layer |
Return cut layer of the |
|
multi_view_data |
Return the session data. |
|
n_unique_faces |
Return the number of unique faces. |
|
vgg_core_output |
Return the |
Source code in code/facesim3d/modeling/VGG/prepare_data.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
|
display_image
🗿
Display face images with a specific angle.
Source code in code/facesim3d/modeling/VGG/prepare_data.py
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
|
get_multi_view_data
cached
🗿
get_multi_view_data() -> DataFrame
Get the multi-view data.
Source code in code/facesim3d/modeling/VGG/prepare_data.py
400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
|
load_image_for_model
🗿
load_image_for_model(
image_path: str | Path,
dtype: float64,
subtract_mean: bool = True,
) -> Tensor
Load an image for the VGG
model.
Source code in code/facesim3d/modeling/VGG/prepare_data.py
31 32 33 34 35 36 37 38 39 |
|
prepare_data_for_human_judgment_model
🗿
prepare_data_for_human_judgment_model(
session: str,
frozen_core: bool,
data_mode: str,
last_core_layer: str | None = None,
split_ratio: tuple = (0.7, 0.15, 0.15),
batch_size: int = 1,
shuffle: bool = True,
num_workers: int = 0,
dtype: dtype = float32,
size: int | None = None,
exclusive_gender_trials: str | None = None,
heads: list[int] | ndarray[int] | int | None = None,
**kwargs
) -> tuple[DataLoader, DataLoader, DataLoader]
Prepare data for the VGG-Face
-model for human similarity judgments.
Split the data into a train, validation and test set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
session
|
str
|
'2D' OR '3D' |
required |
frozen_core
|
bool
|
prepare data for frozen VGG core or not |
required |
data_mode
|
str
|
use "2d-original", "3d-reconstructions", or "3d-perspectives" as input images |
required |
last_core_layer
|
str | None
|
must be given if frozen_core is True |
None
|
split_ratio
|
tuple
|
ratio of train, validation and test set |
(0.7, 0.15, 0.15)
|
batch_size
|
int
|
batch size for dataloader |
1
|
shuffle
|
bool
|
shuffle data |
True
|
num_workers
|
int
|
number of workers for dataloader |
0
|
dtype
|
dtype
|
data type for images |
float32
|
size
|
int | None
|
optionally define total size of data (which then gets split) |
None
|
exclusive_gender_trials
|
str | None
|
use exclusive gender trials ['female' OR 'male'], OR None for all samples. |
None
|
heads
|
list[int] | ndarray[int] | int | None
|
optionally define subset of data, provide a list of head IDs or total number of heads IDs |
None
|
Returns:
Type | Description |
---|---|
tuple[DataLoader, DataLoader, DataLoader]
|
train_dataloader, validation_dataloader, test_dataloader |
Source code in code/facesim3d/modeling/VGG/prepare_data.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 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 393 394 395 396 397 |
|
prepare_data_for_multi_view_model
🗿
prepare_data_for_multi_view_model(
frozen_core: bool,
last_core_layer: str | None = None,
split_ratio: tuple = (0.8, 0.2, 0.0),
batch_size: int = 1,
shuffle: bool = True,
num_workers: int = 0,
dtype: dtype = float32,
heads: list[int] | ndarray[int] | int | None = None,
**kwargs
) -> tuple[DataLoader, DataLoader, DataLoader]
Prepare data for the multi-view model.
Split the data into a train, validation and test set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frozen_core
|
bool
|
prepare data for frozen VGG core or not |
required |
last_core_layer
|
str | None
|
must be given if frozen_core is True |
None
|
split_ratio
|
tuple
|
ratio of train, validation and test set. The test set always contains the frontal views of faces. If > (..., ..., 0.) take also more views into the test set. |
(0.8, 0.2, 0.0)
|
batch_size
|
int
|
batch size for dataloader |
1
|
shuffle
|
bool
|
shuffle data |
True
|
num_workers
|
int
|
number of workers for the dataloader |
0
|
dtype
|
dtype
|
data type for images |
float32
|
heads
|
list[int] | ndarray[int] | int | None
|
optionally define subset of data, provide a list of head IDs or total number of heads IDs |
None
|
Returns:
Type | Description |
---|---|
tuple[DataLoader, DataLoader, DataLoader]
|
train_dataloader, validation_dataloader, test_dataloader |
Source code in code/facesim3d/modeling/VGG/prepare_data.py
607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
|
revert_model_image
🗿
revert_model_image(
image: Tensor, add_mean: bool
) -> ndarray
Revert a model-input-image to its original form.
Source code in code/facesim3d/modeling/VGG/prepare_data.py
42 43 44 45 46 |
|