flava
mindnlp.transformers.models.flava.configuration_flava
¶
FLAVA model configurations
mindnlp.transformers.models.flava.configuration_flava.FlavaConfig
¶
Bases: PretrainedConfig
[FlavaConfig
] is the configuration class to store the configuration of a [FlavaModel
]. It is used to
instantiate FLAVA model according to the specified arguments, defining the text model, image model, image codebook
and multimodal model configs. Instantiating a configuration with the defaults will yield a similar configuration to
that of the FLAVA facebook/flava-full architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
text_config |
Dictionary of configuration options used to initialize [
TYPE:
|
image_config |
Dictionary of configuration options used to initialize [
TYPE:
|
multimodal_config |
Dictionary of configuration options used to initialize [
TYPE:
|
hidden_size |
Dimensionality of the encoder layers and the pooler layer.
TYPE:
|
layer_norm_eps |
The epsilon used by the layer normalization layers.
TYPE:
|
projection_dim |
Dimentionality of text and image projection layers.
TYPE:
|
logit_scale_init_value |
The inital value of the logit_scale paramter. Default is used as per the original FLAVA/CLIP implementation.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
ce_ignore_index |
Cross entropy index to ignore.
TYPE:
|
mim_weight |
Weight to be assigned to MIM (Masked Image Modeling) unimodal loss
TYPE:
|
mlm_weight |
Weight to be assigned to MLM (Masked Language Modeling) unimodal loss
TYPE:
|
global_contrastive_weight |
Weight to be assigned to global contrastive cross-alignment loss.
TYPE:
|
itm_weight |
Weight to be assigned to image-text matching multimodal loss.
TYPE:
|
mmm_image_weight |
Weight to be assigned to MMM loss's image part.
TYPE:
|
mmm_text_weight |
Weight to be assigned to MMM loss's text part.
TYPE:
|
global_backprop_contrastive |
Whether to use global backpropgation through all workers in contrastive loss.
TYPE:
|
skip_unmasked_multimodal_encoder |
Whether to skip running unmasked multimodal encoder whose outputs are not used by FLAVA losses.
TYPE:
|
return_loss |
Whether to return loss or not
TYPE:
|
kwargs |
Dictionary of keyword arguments.
TYPE:
|
Example
>>> from transformers import FlavaConfig, FlavaModel, FlavaForPreTraining
...
>>> # Initializing a FlavaConfig with style configuration
>>> configuration = FlavaConfig()
...
>>> # Initializing a FlavaModel and FlavaForPreTraining model (with random weights) from the style configuration
>>> model = FlavaModel(configuration)
>>> model_pre = FlavaForPreTraining(configuration)
...
>>> # Accessing the model configuration
>>> configuration = model.config
>>> configuration_pre = model_pre.config
Source code in mindnlp/transformers/models/flava/configuration_flava.py
570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 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 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
|
mindnlp.transformers.models.flava.configuration_flava.FlavaConfig.from_configs(image_config, text_config, multimodal_config, image_codebook_config, **kwargs)
classmethod
¶
Instantiate a [FlavaConfig
] (or a derived class) from flava text model configuration, flava image model
configuration, flava multimodal model and flava codebook model configuration.
RETURNS | DESCRIPTION |
---|---|
[ |
Source code in mindnlp/transformers/models/flava/configuration_flava.py
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 |
|
mindnlp.transformers.models.flava.configuration_flava.FlavaImageCodebookConfig
¶
Bases: PretrainedConfig
[FlavaImageCodebookConfig
] is the configuration class to store the configuration of a [FlavaImageCodebook
]. It
is used to instantiate an FLAVA model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the FLAVA
facebook/flava-image-codebook architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
num_groups |
Number of groups to be created. This parameter as of now doesn't affect the model and is used for some internal calculation and estimations.
TYPE:
|
input_channels |
Number of channels in the image to be passed.
TYPE:
|
num_blocks_per_group |
Number of conv-based blocks per group.
TYPE:
|
hidden_size |
Size of hidden dim for the blocks.
TYPE:
|
vocab_size |
Size of the output vocabulary for the codebook.
TYPE:
|
freeze |
Whether to freeze the weights of the model.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
kwargs |
Dictionary of keyword arguments.
TYPE:
|
Example
>>> from transformers import FlavaImageCodebookConfig, FlavaImageCodebook
...
>>> # Initializing a FlavaImageCodebook with style configuration
>>> configuration = FlavaImageCodebookConfig()
...
>>> # Initializing a FlavaImageCodebook model (with random weights) from the style configuration
>>> model = FlavaImageCodebook(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
Source code in mindnlp/transformers/models/flava/configuration_flava.py
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 496 497 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 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 |
|
mindnlp.transformers.models.flava.configuration_flava.FlavaImageConfig
¶
Bases: PretrainedConfig
This is the configuration class to store the configuration of a [FlavaImageModel
]. It is used to instantiate an
FLAVA model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the FLAVA facebook/flava-full architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
hidden_size |
Dimensionality of the encoder layers and the pooler layer.
TYPE:
|
num_hidden_layers |
Number of hidden layers in the Transformer encoder.
TYPE:
|
num_attention_heads |
Number of attention heads for each attention layer in the Transformer encoder.
TYPE:
|
intermediate_size |
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
TYPE:
|
hidden_act |
The non-linear activation function (function or string) in the encoder and pooler. If string,
TYPE:
|
hidden_dropout_prob |
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
TYPE:
|
attention_probs_dropout_prob |
The dropout ratio for the attention probabilities.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
layer_norm_eps |
The epsilon used by the layer normalization layers.
TYPE:
|
image_size |
The size (resolution) of each image.
TYPE:
|
patch_size |
The size (resolution) of each patch.
TYPE:
|
num_channels |
The number of input channels.
TYPE:
|
qkv_bias |
Whether to add a bias to the queries, keys and values.
TYPE:
|
mask_token |
Whether to use a mask token or not. Used in MIM (Masked Image Modeling) loss for FLAVA.
TYPE:
|
vocab_size |
Vocabulary size of the [
TYPE:
|
Example
>>> from transformers import FlavaImageConfig, FlavaImageModel
...
>>> # Initializing a FlavaImageModel with style configuration
>>> configuration = FlavaImageConfig()
...
>>> # Initializing a FlavaImageModel model (with random weights) from the style configuration
>>> model = FlavaImageModel(configuration)
...
>>> # Accessing the model configuration
>>> configuration = model.config
Source code in mindnlp/transformers/models/flava/configuration_flava.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
|
mindnlp.transformers.models.flava.configuration_flava.FlavaMultimodalConfig
¶
Bases: PretrainedConfig
This is the configuration class to store the configuration of a [FlavaMultimodalModel
]. It is used to instantiate
an FLAVA model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the FLAVA facebook/flava-full architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
hidden_size |
Dimensionality of the encoder layers and the pooler layer.
TYPE:
|
num_hidden_layers |
Number of hidden layers in the Transformer encoder.
TYPE:
|
num_attention_heads |
Number of attention heads for each attention layer in the Transformer encoder.
TYPE:
|
intermediate_size |
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
TYPE:
|
hidden_act |
The non-linear activation function (function or string) in the encoder and pooler. If string,
TYPE:
|
hidden_dropout_prob |
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
TYPE:
|
attention_probs_dropout_prob |
The dropout ratio for the attention probabilities.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
layer_norm_eps |
The epsilon used by the layer normalization layers.
TYPE:
|
qkv_bias |
Whether to add a bias to the queries, keys and values.
TYPE:
|
use_cls_token |
Whether to use an extra CLS token for multimodal settings. Usually needed by the FLAVA model.
TYPE:
|
Example
>>> from transformers import FlavaMultimodalConfig, FlavaMultimodalModel
...
>>> # Initializing a FlavaMultimodalModel with style configuration
>>> configuration = FlavaMultimodalConfig()
...
>>> # Initializing a FlavaMultimodalModel model (with random weights) from the style configuration
>>> model = FlavaMultimodalModel(configuration)
...
>>> # Accessing the model configuration
>>> configuration = model.config
Source code in mindnlp/transformers/models/flava/configuration_flava.py
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 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 455 456 457 |
|
mindnlp.transformers.models.flava.configuration_flava.FlavaTextConfig
¶
Bases: PretrainedConfig
This is the configuration class to store the configuration of a [FlavaTextModel
]. It is used to instantiate an
FLAVA model according to the specified arguments, defining the model architecture.
Instantiating a configuration with the defaults will yield a similar configuration to that of the FLAVA facebook/flava-full architecture.
Configuration objects inherit from [PretrainedConfig
] and can be used to control the model outputs. Read the
documentation from [PretrainedConfig
] for more information.
PARAMETER | DESCRIPTION |
---|---|
vocab_size |
Vocabulary size of the BERT model. Defines the number of different tokens that can be represented by the
TYPE:
|
type_vocab_size |
The vocabulary size of the
TYPE:
|
max_position_embeddings |
The maximum sequence length that this model might ever be used with. Typically set this to something large just in case (e.g., 512 or 1024 or 2048). For VL, max_length passed to model is 77.
TYPE:
|
position_embedding_type |
Type of position embedding. Choose one of
TYPE:
|
hidden_size |
Dimensionality of the encoder layers and the pooler layer.
TYPE:
|
num_hidden_layers |
Number of hidden layers in the Transformer encoder.
TYPE:
|
num_attention_heads |
Number of attention heads for each attention layer in the Transformer encoder.
TYPE:
|
intermediate_size |
Dimensionality of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
TYPE:
|
hidden_act |
The non-linear activation function (function or string) in the encoder and pooler. If string,
TYPE:
|
hidden_dropout_prob |
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
TYPE:
|
attention_probs_dropout_prob |
The dropout ratio for the attention probabilities.
TYPE:
|
initializer_range |
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
TYPE:
|
layer_norm_eps |
The epsilon used by the layer normalization layers.
TYPE:
|
image_size |
The size (resolution) of each image.
TYPE:
|
patch_size |
The size (resolution) of each patch.
TYPE:
|
num_channels |
The number of input channels.
TYPE:
|
qkv_bias |
Whether to add a bias to the queries, keys and values.
TYPE:
|
Example
>>> from transformers import FlavaTextConfig, FlavaTextModel
...
>>> # Initializing a FlavaTextModel with style configuration
>>> configuration = FlavaTextConfig()
...
>>> # Initializing a FlavaTextModel model (with random weights) from the style configuration
>>> model = FlavaTextModel(configuration)
...
>>> # Accessing the model configuration
>>> configuration = model.config
Source code in mindnlp/transformers/models/flava/configuration_flava.py
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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 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 |
|
mindnlp.transformers.models.flava.feature_extraction_flava
¶
Feature extractor class for FLAVA.
mindnlp.transformers.models.flava.image_processing_flava
¶
Image processor class for Flava.
mindnlp.transformers.models.flava.image_processing_flava.FlavaImageProcessor
¶
Bases: BaseImageProcessor
Constructs a Flava image processor.
PARAMETER | DESCRIPTION |
---|---|
do_resize |
Whether to resize the image's (height, width) dimensions to the specified
TYPE:
|
size |
224, "width": 224}
TYPE:
|
resample |
Resampling filter to use if resizing the image. Can be overridden by the
TYPE:
|
do_center_crop |
Whether to center crop the images. Can be overridden by the
TYPE:
|
crop_size |
224, "width": 224}
TYPE:
|
do_rescale |
Whether to rescale the image by the specified scale
TYPE:
|
rescale_factor |
Scale factor to use if rescaling the image. Can be overridden by the
TYPE:
|
do_normalize |
Whether to normalize the image. Can be overridden by the
TYPE:
|
image_mean |
Mean to use if normalizing the image. This is a float or list of floats the length of the number of
channels in the image. Can be overridden by the
TYPE:
|
image_std |
Standard deviation to use if normalizing the image. This is a float or list of floats the length of the
number of channels in the image. Can be overridden by the
TYPE:
|
return_image_mask |
Whether to return the image mask. Can be overridden by the
TYPE:
|
input_size_patches |
Number of patches in the image in height and width direction. 14x14 = 196 total patches. Can be overridden
by the
TYPE:
|
total_mask_patches |
Total number of patches that should be masked. Can be overridden by the
TYPE:
|
mask_group_min_patches |
Minimum number of patches that should be masked. Can be overridden by the
TYPE:
|
mask_group_max_patches |
Maximum number of patches that should be masked. Can be overridden by the
TYPE:
|
mask_group_min_aspect_ratio |
Minimum aspect ratio of the mask window. Can be overridden by the
TYPE:
|
mask_group_max_aspect_ratio |
Maximum aspect ratio of the mask window. Can be overridden by the
TYPE:
|
codebook_do_resize |
Whether to resize the input for codebook to a certain. Can be overridden by the
TYPE:
|
codebook_size |
224, "width": 224}
TYPE:
|
codebook_resample |
Resampling filter to use if resizing the codebook image. Can be overridden by the
TYPE:
|
codebook_do_center_crop |
Whether to crop the input for codebook at the center. If the input size is smaller than
TYPE:
|
codebook_crop_size |
224, "width": 224}
TYPE:
|
codebook_do_rescale |
Whether to rescale the input for codebook by the specified scale
TYPE:
|
codebook_rescale_factor |
Defines the scale factor to use if rescaling the codebook image. Can be overridden by the
TYPE:
|
codebook_do_map_pixels |
Whether to map the pixel values of the codebook input to (1 - 2e)x + e. Can be overridden by the
TYPE:
|
codebook_do_normalize |
Whether or not to normalize the input for codebook with
TYPE:
|
codebook_image_mean |
The sequence of means for each channel, to be used when normalizing images for codebook. Can be overridden
by the
TYPE:
|
codebook_image_std |
The sequence of standard deviations for each channel, to be used when normalizing images for codebook. Can
be overridden by the
TYPE:
|
Source code in mindnlp/transformers/models/flava/image_processing_flava.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 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 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 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 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 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 455 456 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 496 497 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 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 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 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 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
|
mindnlp.transformers.models.flava.image_processing_flava.FlavaImageProcessor.from_dict(image_processor_dict, **kwargs)
classmethod
¶
Overrides the from_dict
method from the base class to make sure parameters are updated if image processor is
created using from_dict and kwargs e.g. FlavaImageProcessor.from_pretrained(checkpoint, codebook_size=600)
Source code in mindnlp/transformers/models/flava/image_processing_flava.py
342 343 344 345 346 347 348 349 350 351 352 353 |
|
mindnlp.transformers.models.flava.image_processing_flava.FlavaImageProcessor.preprocess(images, do_resize=None, size=None, resample=None, do_center_crop=None, crop_size=None, do_rescale=None, rescale_factor=None, do_normalize=None, image_mean=None, image_std=None, return_image_mask=None, input_size_patches=None, total_mask_patches=None, mask_group_min_patches=None, mask_group_max_patches=None, mask_group_min_aspect_ratio=None, mask_group_max_aspect_ratio=None, return_codebook_pixels=None, codebook_do_resize=None, codebook_size=None, codebook_resample=None, codebook_do_center_crop=None, codebook_crop_size=None, codebook_do_rescale=None, codebook_rescale_factor=None, codebook_do_map_pixels=None, codebook_do_normalize=None, codebook_image_mean=None, codebook_image_std=None, return_tensors=None, data_format=ChannelDimension.FIRST, input_data_format=None, **kwargs)
¶
Preprocess an image or batch of images.
PARAMETER | DESCRIPTION |
---|---|
images |
Image to preprocess. Expects a single or batch of images with pixel values ranging from 0 to 255. If
passing in images with pixel values between 0 and 1, set
TYPE:
|
do_resize |
Whether to resize the image.
TYPE:
|
size |
Size of the image.
TYPE:
|
resample |
Resampling filter to use if resizing the image. This can be one of the enum
TYPE:
|
do_center_crop |
Whether to center crop the image.
TYPE:
|
crop_size |
Size of the center crop. Only has an effect if
TYPE:
|
do_rescale |
Whether to rescale the image values between [0 - 1].
TYPE:
|
rescale_factor |
Rescale factor to rescale the image by if
TYPE:
|
do_normalize |
Whether to normalize the image.
TYPE:
|
image_mean |
Image mean.
TYPE:
|
image_std |
Image standard deviation.
TYPE:
|
return_image_mask |
Whether to return the image mask.
TYPE:
|
input_size_patches |
Size of the patches to extract from the image.
TYPE:
|
total_mask_patches |
Total number of patches to extract from the image.
TYPE:
|
mask_group_min_patches |
Minimum number of patches to extract from the image.
TYPE:
|
mask_group_max_patches |
Maximum number of patches to extract from the image.
TYPE:
|
mask_group_min_aspect_ratio |
Minimum aspect ratio of the patches to extract from the image.
TYPE:
|
mask_group_max_aspect_ratio |
Maximum aspect ratio of the patches to extract from the image.
TYPE:
|
return_codebook_pixels |
Whether to return the codebook pixels.
TYPE:
|
codebook_do_resize |
Whether to resize the codebook pixels.
TYPE:
|
codebook_size |
Size of the codebook pixels.
TYPE:
|
codebook_resample |
Resampling filter to use if resizing the codebook pixels. This can be one of the enum
TYPE:
|
codebook_do_center_crop |
Whether to center crop the codebook pixels.
TYPE:
|
codebook_crop_size |
Size of the center crop of the codebook pixels. Only has an effect if
TYPE:
|
codebook_do_rescale |
Whether to rescale the codebook pixels values between [0 - 1].
TYPE:
|
codebook_rescale_factor |
Rescale factor to rescale the codebook pixels by if
TYPE:
|
codebook_do_map_pixels |
Whether to map the codebook pixels values.
TYPE:
|
codebook_do_normalize |
Whether to normalize the codebook pixels.
TYPE:
|
codebook_image_mean |
Codebook pixels mean to normalize the codebook pixels by if
TYPE:
|
codebook_image_std |
Codebook pixels standard deviation to normalize the codebook pixels by if
TYPE:
|
return_tensors |
The type of tensors to return. Can be one of:
TYPE:
|
data_format |
The channel dimension format for the output image. Can be one of:
TYPE:
|
input_data_format |
The channel dimension format for the input image. If unset, the channel dimension format is inferred from the input image. Can be one of:
TYPE:
|
Source code in mindnlp/transformers/models/flava/image_processing_flava.py
492 493 494 495 496 497 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 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 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 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 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
|
mindnlp.transformers.models.flava.image_processing_flava.FlavaImageProcessor.resize(image, size, resample=PILImageResampling.BICUBIC, data_format=None, input_data_format=None, **kwargs)
¶
Resize an image to (size["height"], size["width"])
.
PARAMETER | DESCRIPTION |
---|---|
image |
Image to resize.
TYPE:
|
size |
Dictionary in the format
TYPE:
|
resample |
TYPE:
|
data_format |
The channel dimension format for the output image. If unset, the channel dimension format of the input image is used. Can be one of:
TYPE:
|
input_data_format |
The channel dimension format for the input image. If unset, the channel dimension format is inferred from the input image. Can be one of:
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ndarray
|
|
Source code in mindnlp/transformers/models/flava/image_processing_flava.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 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 |
|
mindnlp.transformers.models.flava.modeling_flava
¶
Mindspore FLAVA model.
mindnlp.transformers.models.flava.modeling_flava.FlavaForPreTraining
¶
Bases: FlavaPreTrainedModel
Source code in mindnlp/transformers/models/flava/modeling_flava.py
1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaForPreTraining.forward(input_ids=None, input_ids_masked=None, pixel_values=None, codebook_pixel_values=None, attention_mask=None, token_type_ids=None, bool_masked_pos=None, position_ids=None, image_attention_mask=None, skip_unmasked_multimodal_encoder=None, mlm_labels=None, mim_labels=None, itm_labels=None, output_attentions=None, output_hidden_states=True, return_dict=None, return_loss=None)
¶
Example
>>> from PIL import Image
>>> import requests
>>> from transformers import FlavaForPreTraining, AutoProcessor
...
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream=True).raw)
...
>>> model = FlavaForPreTraining.from_pretrained("facebook/flava-full")
>>> processor = AutoProcessor.from_pretrained("facebook/flava-full")
...
>>> text = ["a photo of a cat"]
...
>>> inputs = processor(
... images=[image],
... text=text,
... return_masks=True,
... return_codebook_pixels=True,
... padding=True,
... max_length=77,
... return_tensors="pt",
... )
...
...
>>> output = model(**inputs)
Return
Union[Tuple[mindspore.Tensor], FlavaForPreTrainingOutput]
Source code in mindnlp/transformers/models/flava/modeling_flava.py
1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaForPreTrainingOutput
dataclass
¶
Bases: ModelOutput
Output from FlavaForPreTraining containing embeddings, and outputs from individual encoders.
Note that image_embeddings
and text_embeddings
returned are similar to pooled output returned from a
transformer. If you want embeddings for contrastive loss or retrieval use a FLAVA model's image_projection
and
text_projection
layers on image_embeddings
and text_embeddings
respectively.
PARAMETER | DESCRIPTION |
---|---|
loss |
Total loss calculated for this model.
TYPE:
|
loss_info |
Detailed info for FLAVA Pretraining losses. Check
TYPE:
|
image_output |
The output of the [
TYPE:
|
text_output |
The output of the [
TYPE:
|
image_masked_output |
The output of the [
TYPE:
|
text_masked_output |
The output of the [
TYPE:
|
contrastive_logits_per_image |
The scaled dot product scores between
TYPE:
|
contrastive_logits_per_text |
The scaled dot product scores between
TYPE:
|
Source code in mindnlp/transformers/models/flava/modeling_flava.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 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 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 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 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaImageEmbeddings
¶
Bases: Module
Construct the CLS token, position and patch embeddings. Optionally, also the mask token.
Source code in mindnlp/transformers/models/flava/modeling_flava.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 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 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaImageEmbeddings.interpolate_pos_encoding(embeddings, height, width)
¶
This method allows to interpolate the pre-trained position encodings, to be able to use the model on higher resolution images.
Source: https://github.com/facebookresearch/dino/blob/de9ee3df6cf39fac952ab558447af1fa1365362a/image_transformer.py#L174
Source code in mindnlp/transformers/models/flava/modeling_flava.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaImageModel
¶
Bases: FlavaPreTrainedModel
Source code in mindnlp/transformers/models/flava/modeling_flava.py
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaLayer
¶
Bases: Module
This corresponds to the Block class in the timm implementation.
Source code in mindnlp/transformers/models/flava/modeling_flava.py
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 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaLosses
dataclass
¶
Bases: ModelOutput
Class representing pretraining losses from FLAVA model
Source code in mindnlp/transformers/models/flava/modeling_flava.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaModel
¶
Bases: FlavaPreTrainedModel
Source code in mindnlp/transformers/models/flava/modeling_flava.py
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaModel.forward(input_ids=None, pixel_values=None, attention_mask=None, token_type_ids=None, bool_masked_pos=None, position_ids=None, image_attention_mask=None, skip_multimodal_encoder=None, output_attentions=None, output_hidden_states=True, return_dict=None)
¶
RETURNS | DESCRIPTION |
---|---|
Union[Tuple, FlavaOutput]
|
|
Example
>>> from PIL import Image
>>> import requests
>>> from transformers import AutoProcessor, FlavaModel
...
>>> model = FlavaModel.from_pretrained("facebook/flava-full")
>>> processor = AutoProcessor.from_pretrained("facebook/flava-full")
...
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream=True).raw)
...
>>> inputs = processor(text=["a photo of a cat"], images=image, return_tensors="pt", padding=True)
...
>>> outputs = model(**inputs)
...
>>> image_embeddings = outputs.image_embeddings
>>> text_embeddings = outputs.text_embeddings
>>> multimodal_embeddings = outputs.multimodal_embeddings
...
>>> outputs.image_embeddings.shape
torch.Size([1, 197, 768])
>>> text_embeddings.shape
torch.Size([1, 7, 768])
>>> multimodal_embeddings.shape
torch.Size([1, 205, 768])
Source code in mindnlp/transformers/models/flava/modeling_flava.py
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaModelOutput
dataclass
¶
Bases: ModelOutput
Output from FlavaModel containing embeddings and outputs from individual encoders.
Note that image_embeddings
and text_embeddigns
returned are similar to pooled output returned from a
transformer. If you want embeddings for contrastive loss or retrieval use a FLAVA model's image_projection
and
text_projection
layers on image_embeddings
and text_embeddings
respectively.
PARAMETER | DESCRIPTION |
---|---|
image_output |
The output of the [
TYPE:
|
text_output |
The output of the [
TYPE:
|
multimodal_output |
The output of the [
TYPE:
|
Source code in mindnlp/transformers/models/flava/modeling_flava.py
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 97 98 99 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaMultimodalModel
¶
Bases: FlavaPreTrainedModel
Source code in mindnlp/transformers/models/flava/modeling_flava.py
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaPreTrainedModel
¶
Bases: PreTrainedModel
An abstract class to handle weights initialization and a simple interface for downloading and loading pretrained models.
Source code in mindnlp/transformers/models/flava/modeling_flava.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaSelfOutput
¶
Bases: Module
The residual connection is defined in FlavaLayer (same as ViTLayer) instead of here (as is the case with other models), due to the layernorm applied before each block.
Source code in mindnlp/transformers/models/flava/modeling_flava.py
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaTextEmbeddings
¶
Bases: Module
Construct the embeddings from word, position and token_type embeddings.
Source code in mindnlp/transformers/models/flava/modeling_flava.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 |
|
mindnlp.transformers.models.flava.modeling_flava.FlavaTextModel
¶
Bases: FlavaPreTrainedModel
Source code in mindnlp/transformers/models/flava/modeling_flava.py
836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
|
mindnlp.transformers.models.flava.modeling_flava.PatchEmbeddings
¶
Bases: Module
Image to Patch Embedding.
Source code in mindnlp/transformers/models/flava/modeling_flava.py
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 |
|
mindnlp.transformers.models.flava.processing_flava
¶
Image/Text processor class for FLAVA
mindnlp.transformers.models.flava.processing_flava.FlavaProcessor
¶
Bases: ProcessorMixin
Constructs a FLAVA processor which wraps a FLAVA image processor and a FLAVA tokenizer into a single processor.
[FlavaProcessor
] offers all the functionalities of [FlavaImageProcessor
] and [BertTokenizerFast
]. See the
[~FlavaProcessor.__call__
] and [~FlavaProcessor.decode
] for more information.
PARAMETER | DESCRIPTION |
---|---|
image_processor |
The image processor is a required input.
TYPE:
|
tokenizer |
The tokenizer is a required input.
TYPE:
|
Source code in mindnlp/transformers/models/flava/processing_flava.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 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 151 152 153 154 155 156 157 158 159 160 161 162 163 |
|
mindnlp.transformers.models.flava.processing_flava.FlavaProcessor.__call__(images=None, text=None, add_special_tokens=True, padding=False, truncation=False, max_length=None, stride=0, pad_to_multiple_of=None, return_image_mask=None, return_codebook_pixels=None, return_token_type_ids=None, return_attention_mask=None, return_overflowing_tokens=False, return_special_tokens_mask=False, return_offsets_mapping=False, return_length=False, verbose=True, return_tensors=None, **kwargs)
¶
This method uses [FlavaImageProcessor.__call__
] method to prepare image(s) for the model, and
[BertTokenizerFast.__call__
] to prepare text for the model.
Please refer to the docstring of the above two methods for more information.
Source code in mindnlp/transformers/models/flava/processing_flava.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
|
mindnlp.transformers.models.flava.processing_flava.FlavaProcessor.batch_decode(*args, **kwargs)
¶
This method forwards all its arguments to BertTokenizerFast's [~PreTrainedTokenizer.batch_decode
]. Please
refer to the docstring of this method for more information.
Source code in mindnlp/transformers/models/flava/processing_flava.py
129 130 131 132 133 134 |
|
mindnlp.transformers.models.flava.processing_flava.FlavaProcessor.decode(*args, **kwargs)
¶
This method forwards all its arguments to BertTokenizerFast's [~PreTrainedTokenizer.decode
]. Please refer to
the docstring of this method for more information.
Source code in mindnlp/transformers/models/flava/processing_flava.py
136 137 138 139 140 141 |
|