code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def forward( self, input_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, attention_mask: Optional[torch.LongTensor] = None, head_mask: Optional[torch.FloatTensor] = None, output_attentions: Optional[bool] = None, output_hi...
Examples: ```python >>> import torch >>> from transformers import AutoConfig, AutoTokenizer, TvpModel >>> model = TvpModel.from_pretrained("Jiqing/tiny-random-tvp") >>> tokenizer = AutoTokenizer.from_pretrained("Jiqing/tiny-random-tvp") >>> pixel_values = torc...
forward
python
huggingface/transformers
src/transformers/models/tvp/modeling_tvp.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/tvp/modeling_tvp.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, attention_mask: Optional[torch.LongTensor] = None, labels: Optional[Tuple[torch.Tensor]] = None, head_mask: Optional[torch.FloatTensor] = None, outpu...
labels (`torch.FloatTensor` of shape `(batch_size, 3)`, *optional*): The labels contains duration, start time, and end time of the video corresponding to the text. Examples: ```python >>> import torch >>> from transformers import AutoConfig, AutoTokenizer, TvpForVid...
forward
python
huggingface/transformers
src/transformers/models/tvp/modeling_tvp.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/tvp/modeling_tvp.py
Apache-2.0
def __call__(self, text=None, videos=None, return_tensors=None, **kwargs): """ Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text` and `kwargs` arguments to BertTokenizerFast's [`~BertTokenizerFast.__call__`] if `text` is not `None` to e...
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text` and `kwargs` arguments to BertTokenizerFast's [`~BertTokenizerFast.__call__`] if `text` is not `None` to encode the text. To prepare the image(s), this method forwards the `videos` and...
__call__
python
huggingface/transformers
src/transformers/models/tvp/processing_tvp.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/tvp/processing_tvp.py
Apache-2.0
def post_process_video_grounding(self, logits, video_durations): """ Compute the time of the video. Args: logits (`torch.Tensor`): The logits output of TvpForVideoGrounding. video_durations (`float`): The video's duration. Returns...
Compute the time of the video. Args: logits (`torch.Tensor`): The logits output of TvpForVideoGrounding. video_durations (`float`): The video's duration. Returns: start (`float`): The start time of the video. ...
post_process_video_grounding
python
huggingface/transformers
src/transformers/models/tvp/processing_tvp.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/tvp/processing_tvp.py
Apache-2.0
def combine_image_text_embeddings( image_embeddings, inputs_embeds, bbox, visual_bbox, attention_mask=None, num_patches=14, max_len=0, image_size=224, patch_size=16, ): """ Combine the image and text embeddings for the input to the encoder/decoder of UDOP. First, the ima...
Combine the image and text embeddings for the input to the encoder/decoder of UDOP. First, the image embeddings are created by checking for each visual patch if it is inside the bounding box of a token. If it is, the visual patch is combined with the token embedding. Then, the visual bounding boxes are co...
combine_image_text_embeddings
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def __init__(self, hidden_size, eps=1e-6): """ Construct a layernorm module in the Udop style. No bias and no subtraction of mean. """ super().__init__() self.weight = nn.Parameter(torch.ones(hidden_size)) self.variance_epsilon = eps
Construct a layernorm module in the Udop style. No bias and no subtraction of mean.
__init__
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def __init__(self, modules: Sequence[RelativePositionBiasBase]): """ Class which sums up various computed biases. Args: modules (Sequence[RelativePositionBiasBase]): List of relative bias modules. """ super().__init__() self.biases = nn.Module...
Class which sums up various computed biases. Args: modules (Sequence[RelativePositionBiasBase]): List of relative bias modules.
__init__
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def create_relative_bias(config: UdopConfig) -> Sequence[RelativePositionBiasBase]: """ Creates empty list or one/multiple relative biases. :param config: Model's configuration :return: Sequence with created bias modules. """ bias_list = [] if hasattr(config, "relative_bias_args"): for ...
Creates empty list or one/multiple relative biases. :param config: Model's configuration :return: Sequence with created bias modules.
create_relative_bias
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def forward( self, input_ids: Optional[Tensor] = None, attention_mask: Optional[Tensor] = None, bbox: Optional[Dict[str, Any]] = None, pixel_values: Optional[Tensor] = None, visual_bbox: Optional[Dict[str, Any]] = None, decoder_input_ids: Optional[Tensor] = None, ...
bbox (`torch.LongTensor` of shape `({0}, 4)`, *optional*): Bounding boxes of each input sequence tokens. Selected in the range `[0, config.max_2d_position_embeddings-1]`. Each bounding box should be a normalized version in (x0, y0, x1, y1) format, where (x0, y0) corresponds ...
forward
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def forward( self, input_ids: Optional[Tensor] = None, attention_mask: Optional[Tensor] = None, bbox: Optional[Dict[str, Any]] = None, pixel_values: Optional[Tensor] = None, visual_bbox: Optional[Dict[str, Any]] = None, decoder_input_ids: Optional[Tensor] = None, ...
bbox (`torch.LongTensor` of shape `({0}, 4)`, *optional*): Bounding boxes of each input sequence tokens. Selected in the range `[0, config.max_2d_position_embeddings-1]`. Each bounding box should be a normalized version in (x0, y0, x1, y1) format, where (x0, y0) corresponds ...
forward
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def forward( self, input_ids: Optional[Tensor] = None, bbox: Optional[Dict[str, Any]] = None, attention_mask: Optional[Tensor] = None, pixel_values: Optional[Tensor] = None, visual_bbox: Optional[Dict[str, Any]] = None, head_mask: Optional[Tensor] = None, ...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. T5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained using...
forward
python
huggingface/transformers
src/transformers/models/udop/modeling_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/modeling_udop.py
Apache-2.0
def __call__( self, images: Optional[ImageInput] = None, text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None, # The following is to capture `text_pair` argument that may be passed as a positional argument. # See transformers.processing_utils...
This method first forwards the `images` argument to [`~UdopImageProcessor.__call__`]. In case [`UdopImageProcessor`] was initialized with `apply_ocr` set to `True`, it passes the obtained words and bounding boxes along with the additional arguments to [`~UdopTokenizer.__call__`] and returns the...
__call__
python
huggingface/transformers
src/transformers/models/udop/processing_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/processing_udop.py
Apache-2.0
def batch_encode_plus_boxes( self, batch_text_or_text_pairs: Union[ List[TextInput], List[TextInputPair], List[PreTokenizedInput], ], is_pair: Optional[bool] = None, boxes: Optional[List[List[List[int]]]] = None, word_labels: Optional[L...
Tokenize and prepare for the model a list of sequences or a list of pairs of sequences. Args: batch_text_or_text_pairs (`List[str]`, `List[Tuple[str, str]]`, `List[List[str]]`, `List[Tuple[List[str], List[str]]]`, and for not-fast tokenizers, also `List[List[int]]`, `List[Tuple[List[int], ...
batch_encode_plus_boxes
python
huggingface/transformers
src/transformers/models/udop/tokenization_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/tokenization_udop.py
Apache-2.0
def encode_boxes( self, text: Union[TextInput, PreTokenizedInput, EncodedInput], text_pair: Optional[Union[TextInput, PreTokenizedInput, EncodedInput]] = None, boxes: Optional[List[List[int]]] = None, word_labels: Optional[List[List[int]]] = None, add_special_tokens: bool...
Args: Converts a string to a sequence of ids (integer), using the tokenizer and vocabulary. Same as doing `self.convert_tokens_to_ids(self.tokenize(text))`. text (`str`, `List[str]` or `List[int]`): The first sequence to be encoded. This can be a string, a list of st...
encode_boxes
python
huggingface/transformers
src/transformers/models/udop/tokenization_udop.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/udop/tokenization_udop.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.FloatTensor] = N...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.FloatTensor] = N...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, head_mask: Optional[torch.FloatTensor] = None, inputs_embeds: Optional[torch.FloatTensor] = None, output_attentions: Optional[bool] = None, output_...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.Tensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.LongTensor] = None, head_mask: Optional[torch.Tensor] = None, ...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_ids: Optional[torch.Tensor] = None, attention_mask: Optional[torch.Tensor] = None, head_mask: Optional[torch.Tensor] = None, inputs_embeds: Optional[torch.Tensor] = None, labels: Optional[torch.Tensor] = None, output_attentions: Optional[b...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.FloatTensor] = N...
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`): Indices of input sequence tokens in the vocabulary. UMT5 is a model with relative position embeddings so you should be able to pad the inputs on both the right and the left. Indices can be obtained usi...
forward
python
huggingface/transformers
src/transformers/models/umt5/modeling_umt5.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/umt5/modeling_umt5.py
Apache-2.0
def forward( self, input_values: Optional[torch.Tensor], attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, ) -> Union[Tuple, UniSpeechForPreTraining...
Example: ```python >>> import torch >>> from transformers import AutoFeatureExtractor, UniSpeechForPreTraining >>> feature_extractor = AutoFeatureExtractor.from_pretrained("microsoft/unispeech-large-1500h-cv") >>> model = UniSpeechForPreTraining.from_pretrained("micros...
forward
python
huggingface/transformers
src/transformers/models/unispeech/modeling_unispeech.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech/modeling_unispeech.py
Apache-2.0
def __init__(self, config, target_lang: Optional[str] = None): r""" target_lang (`str`, *optional*): Language id of adapter weights. Adapter weights are stored in the format adapter.<lang>.safetensors or adapter.<lang>.bin. Only relevant when using an instance of [`UniSpeechForCT...
target_lang (`str`, *optional*): Language id of adapter weights. Adapter weights are stored in the format adapter.<lang>.safetensors or adapter.<lang>.bin. Only relevant when using an instance of [`UniSpeechForCTC`] with adapters. Uses 'eng' by default.
__init__
python
huggingface/transformers
src/transformers/models/unispeech/modeling_unispeech.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech/modeling_unispeech.py
Apache-2.0
def forward( self, input_values: Optional[torch.Tensor], attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, labels: Optional[torch.Tensor] = None...
input_values (`torch.FloatTensor` of shape `(batch_size, sequence_length)`): Float values of input raw speech waveform. Values can be obtained by loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.ndarray`, *e.g.* via the soundfile library (`pip insta...
forward
python
huggingface/transformers
src/transformers/models/unispeech/modeling_unispeech.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech/modeling_unispeech.py
Apache-2.0
def forward( self, input_values: Optional[torch.Tensor], attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, ) -> Union[Tuple, UniSpeechSatForPreTrain...
Example: ```python >>> import torch >>> from transformers import AutoFeatureExtractor, UniSpeechSatForPreTraining >>> from transformers.models.unispeech_sat.modeling_unispeech_sat import _compute_mask_indices >>> feature_extractor = AutoFeatureExtractor.from_pretrained...
forward
python
huggingface/transformers
src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
Apache-2.0
def __init__(self, config, target_lang: Optional[str] = None): r""" target_lang (`str`, *optional*): Language id of adapter weights. Adapter weights are stored in the format adapter.<lang>.safetensors or adapter.<lang>.bin. Only relevant when using an instance of [`UniSpeechSatFo...
target_lang (`str`, *optional*): Language id of adapter weights. Adapter weights are stored in the format adapter.<lang>.safetensors or adapter.<lang>.bin. Only relevant when using an instance of [`UniSpeechSatForCTC`] with adapters. Uses 'eng' by default.
__init__
python
huggingface/transformers
src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
Apache-2.0
def forward( self, input_values: Optional[torch.Tensor], attention_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, labels: Optional[torch.Tensor] = None...
input_values (`torch.FloatTensor` of shape `(batch_size, sequence_length)`): Float values of input raw speech waveform. Values can be obtained by loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.ndarray`, *e.g.* via the soundfile library (`pip insta...
forward
python
huggingface/transformers
src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/unispeech_sat/modeling_unispeech_sat.py
Apache-2.0
def mel_spectrogram(self, waveform: np.ndarray) -> np.ndarray: """ Calculates log MEL spectrograms from a batch of waveforms. Note that the input waveform(s) will be padded by `int(self.n_fft - self.hop_length) / 2` on both sides using the `reflect` padding mode. Args: wavef...
Calculates log MEL spectrograms from a batch of waveforms. Note that the input waveform(s) will be padded by `int(self.n_fft - self.hop_length) / 2` on both sides using the `reflect` padding mode. Args: waveform (`np.ndarray` of shape `(length,)`): The input wavefor...
mel_spectrogram
python
huggingface/transformers
src/transformers/models/univnet/feature_extraction_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/feature_extraction_univnet.py
Apache-2.0
def generate_noise( self, noise_length: int, generator: Optional[np.random.Generator] = None, ) -> np.ndarray: """ Generates a random noise sequence of standard Gaussian noise for use in the `noise_sequence` argument of [`UnivNetModel.forward`]. Args: ...
Generates a random noise sequence of standard Gaussian noise for use in the `noise_sequence` argument of [`UnivNetModel.forward`]. Args: spectrogram_length (`int`): The length (dim 0) of the generated noise. model_in_channels (`int`, *optional*, defaults...
generate_noise
python
huggingface/transformers
src/transformers/models/univnet/feature_extraction_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/feature_extraction_univnet.py
Apache-2.0
def batch_decode(self, waveforms, waveform_lengths=None) -> List[np.ndarray]: r""" Removes padding from generated audio after running [`UnivNetModel.forward`]. This returns a ragged list of 1D audio waveform arrays and not a single tensor/array because in general the waveforms will have differen...
Removes padding from generated audio after running [`UnivNetModel.forward`]. This returns a ragged list of 1D audio waveform arrays and not a single tensor/array because in general the waveforms will have different lengths after removing padding. Args: waveforms (`torch.Flo...
batch_decode
python
huggingface/transformers
src/transformers/models/univnet/feature_extraction_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/feature_extraction_univnet.py
Apache-2.0
def __call__( self, raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]], sampling_rate: Optional[int] = None, padding: Union[bool, str, PaddingStrategy] = True, max_length: Optional[int] = None, truncation: bool = True, pad_to_multiple_...
Main method to featurize and prepare for the model one or several sequence(s). Args: raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`): The sequence or batch of sequences to be padded. Each sequence can be a numpy array, a list of float ...
__call__
python
huggingface/transformers
src/transformers/models/univnet/feature_extraction_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/feature_extraction_univnet.py
Apache-2.0
def forward(self, spectrogram: torch.FloatTensor): """ Maps a conditioning log-mel spectrogram to a tensor of convolutional kernels and biases, for use in location variable convolutional layers. Note that the input spectrogram should have shape (batch_size, input_channels, seq_length). ...
Maps a conditioning log-mel spectrogram to a tensor of convolutional kernels and biases, for use in location variable convolutional layers. Note that the input spectrogram should have shape (batch_size, input_channels, seq_length). Args: spectrogram (`torch.FloatTensor` of ...
forward
python
huggingface/transformers
src/transformers/models/univnet/modeling_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/modeling_univnet.py
Apache-2.0
def forward( self, input_features: torch.FloatTensor, noise_sequence: Optional[torch.FloatTensor] = None, padding_mask: Optional[torch.FloatTensor] = None, generator: Optional[torch.Generator] = None, return_dict: Optional[bool] = None, ) -> Union[Tuple[torch.FloatTen...
input_features (`torch.FloatTensor`): Tensor containing the log-mel spectrograms. Can be batched and of shape `(batch_size, sequence_length, config.num_mel_channels)`, or un-batched and of shape `(sequence_length, config.num_mel_channels)`. noise_sequence (`torch.FloatTensor`, *...
forward
python
huggingface/transformers
src/transformers/models/univnet/modeling_univnet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/univnet/modeling_univnet.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, labels: Optional[torch.Tensor] = None, return_dict: Optional[bool] = None, ) -> Union[tuple, SemanticSegmenterOutput]...
labels (`torch.LongTensor` of shape `(batch_size, height, width)`, *optional*): Ground truth semantic segmentation maps for computing the loss. Indices should be in `[0, ..., config.num_labels - 1]`. If `config.num_labels > 1`, a classification loss is computed (Cross-Entropy). ...
forward
python
huggingface/transformers
src/transformers/models/upernet/modeling_upernet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/upernet/modeling_upernet.py
Apache-2.0
def forward( self, pixel_values: torch.FloatTensor, bool_masked_pos: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = N...
bool_masked_pos (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*): Boolean masked positions. Indicates which patches are masked (1) and which aren't (0). Each video in the batch must have the same number of masked patches. If `None`, then all patches are consider...
forward
python
huggingface/transformers
src/transformers/models/videomae/modeling_videomae.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/videomae/modeling_videomae.py
Apache-2.0
def forward( self, pixel_values: torch.FloatTensor, bool_masked_pos: torch.BoolTensor, head_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, ) -> Uni...
bool_masked_pos (`torch.BoolTensor` of shape `(batch_size, sequence_length)`): Boolean masked positions. Indicates which patches are masked (1) and which aren't (0). Each video in the batch must have the same number of masked patches. Sequence length is `(num_frames // tubelet_size) * ...
forward
python
huggingface/transformers
src/transformers/models/videomae/modeling_videomae.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/videomae/modeling_videomae.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.Tensor] = None, head_mask: Optional[torch.Tensor] = None, labels: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = No...
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*): Labels for computing the image classification/regression loss. Indices should be in `[0, ..., config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If `config.n...
forward
python
huggingface/transformers
src/transformers/models/videomae/modeling_videomae.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/videomae/modeling_videomae.py
Apache-2.0
def preprocess( self, images: Optional[List[ImageInput]] = None, videos: Optional[List[VideoInput]] = None, do_resize: Optional[bool] = None, size: Optional[Dict[str, int]] = None, resample: PILImageResampling = None, do_center_crop: Optional[bool] = None, ...
Preprocess an image or batch of images. Args: images (`ImageInput`, *optional*): List of images 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 `do_rescal...
preprocess
python
huggingface/transformers
src/transformers/models/video_llava/image_processing_video_llava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/video_llava/image_processing_video_llava.py
Apache-2.0
def get_image_features( self, pixel_values_images: torch.FloatTensor, vision_feature_layer: Optional[Union[int, List[int]]] = None, vision_feature_select_strategy: Optional[str] = None, ): """ Obtains image last hidden states from the vision tower and apply multimodal...
Obtains image last hidden states from the vision tower and apply multimodal projection. Args: pixel_values_images (`torch.FloatTensor]` of shape `(batch_size, channels, height, width)`) The tensors corresponding to the input images. vision_feature_layer (`Union[i...
get_image_features
python
huggingface/transformers
src/transformers/models/video_llava/modeling_video_llava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/video_llava/modeling_video_llava.py
Apache-2.0
def get_video_features( self, pixel_values_videos: torch.FloatTensor, vision_feature_layer: Optional[Union[int, List[int]]] = None, ): """ Obtains video last hidden states from the vision tower and apply multimodal projection. Args: pixel_values_videos (`...
Obtains video last hidden states from the vision tower and apply multimodal projection. Args: pixel_values_videos (`torch.FloatTensor]` of shape `(batch_size, num_frames, channels, height, width)`) The tensors corresponding to the input videos. vision_feature_lay...
get_video_features
python
huggingface/transformers
src/transformers/models/video_llava/modeling_video_llava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/video_llava/modeling_video_llava.py
Apache-2.0
def forward( self, input_ids: torch.LongTensor = None, pixel_values_images: torch.FloatTensor = None, pixel_values_videos: torch.FloatTensor = None, attention_mask: Optional[torch.Tensor] = None, position_ids: Optional[torch.LongTensor] = None, past_key_values: Op...
pixel_values_images (`torch.FloatTensor` of shape `(batch_size, num_channels, image_size, image_size)): The tensors corresponding to the input images. Pixel values can be obtained using [`AutoImageProcessor`]. See [`VideoLlavaImageProcessor.__call__`] for details ([]`LlavaProcessor`] us...
forward
python
huggingface/transformers
src/transformers/models/video_llava/modeling_video_llava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/video_llava/modeling_video_llava.py
Apache-2.0
def __call__( self, text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None, images: ImageInput = None, videos: ImageInput = None, padding: Union[bool, str, PaddingStrategy] = False, truncation: Union[bool, str, TruncationStrategy] = Non...
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text` and `kwargs` arguments to LlamaTokenizerFast's [`~LlamaTokenizerFast.__call__`] if `text` is not `None` to encode the text. To prepare the image(s), this method forwards the `images` a...
__call__
python
huggingface/transformers
src/transformers/models/video_llava/processing_video_llava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/video_llava/processing_video_llava.py
Apache-2.0
def from_dict(cls, image_processor_dict: Dict[str, Any], **kwargs): """ Overrides the `from_dict` method from the base class to make sure `pad_and_return_pixel_mask` is updated if image processor is created using from_dict and kwargs e.g. `ViltImageProcessor.from_pretrained(checkpoint, p...
Overrides the `from_dict` method from the base class to make sure `pad_and_return_pixel_mask` is updated if image processor is created using from_dict and kwargs e.g. `ViltImageProcessor.from_pretrained(checkpoint, pad_and_return_pixel_mask=False)`
from_dict
python
huggingface/transformers
src/transformers/models/vilt/image_processing_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/image_processing_vilt.py
Apache-2.0
def _preprocess( self, images: list["torch.Tensor"], do_resize: bool, size: SizeDict, interpolation: Optional["F.InterpolationMode"], size_divisor: Optional[int], do_pad: bool, do_rescale: bool, rescale_factor: float, do_normalize: bool, ...
Preprocess an image or batch of images. This method overrides the base class method to include padding and pixel mask generation.
_preprocess
python
huggingface/transformers
src/transformers/models/vilt/image_processing_vilt_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/image_processing_vilt_fast.py
Apache-2.0
def resize( self, images: "torch.Tensor", size: SizeDict, interpolation: Optional["F.InterpolationMode"] = None, size_divisor: Optional[int] = None, ) -> "torch.Tensor": """ Resize an image or batch of images to specified size. Args: image...
Resize an image or batch of images to specified size. Args: images (`torch.Tensor`): Image or batch of images to resize. size (`Dict[str, int]`): Size dictionary with shortest_edge key. interpolation (`F.InterpolationMode`, *optional*): Interpolation method to use. ...
resize
python
huggingface/transformers
src/transformers/models/vilt/image_processing_vilt_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/image_processing_vilt_fast.py
Apache-2.0
def _pad_batch( self, images: list["torch.Tensor"], return_tensors: Optional[Union[str, TensorType]], ) -> tuple: """ Pad a batch of images to the same size based on the maximum dimensions. Args: images (`list[torch.Tensor]`): List of images to pad. ...
Pad a batch of images to the same size based on the maximum dimensions. Args: images (`list[torch.Tensor]`): List of images to pad. return_tensors (`str` or `TensorType`, *optional*): The type of tensors to return. Returns: `tuple`: Tuple containing padded ...
_pad_batch
python
huggingface/transformers
src/transformers/models/vilt/image_processing_vilt_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/image_processing_vilt_fast.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.FloatTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, pixel_mask: Optional[torch.LongTensor] = None, ...
image_embeds (`torch.FloatTensor` of shape `(batch_size, num_patches, hidden_size)`, *optional*): Optionally, instead of passing `pixel_values`, you can choose to directly pass an embedded representation. This is useful if you want more control over how to convert `pixel_values` into pa...
forward
python
huggingface/transformers
src/transformers/models/vilt/modeling_vilt.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vilt/modeling_vilt.py
Apache-2.0
def get_image_features( self, pixel_values: torch.FloatTensor, vision_feature_layers: Optional[Union[int, List[int]]] = None ): """ Obtains image last hidden states from the vision tower and apply multimodal projection. Args: pixel_values (`torch.FloatTensor]` of shape `...
Obtains image last hidden states from the vision tower and apply multimodal projection. Args: pixel_values (`torch.FloatTensor]` of shape `(batch_size, channels, height, width)`) The tensors corresponding to the input images. vision_feature_layers (`Union[int, Li...
get_image_features
python
huggingface/transformers
src/transformers/models/vipllava/modeling_vipllava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vipllava/modeling_vipllava.py
Apache-2.0
def forward( self, input_ids: torch.LongTensor = None, pixel_values: torch.FloatTensor = None, attention_mask: Optional[torch.Tensor] = None, position_ids: Optional[torch.LongTensor] = None, past_key_values: Optional[List[torch.FloatTensor]] = None, inputs_embeds:...
vision_feature_layers (`Union[int, List[int]]`, *optional*): The vision feature layer, or the list of indexes of the layers to select the vision feature.
forward
python
huggingface/transformers
src/transformers/models/vipllava/modeling_vipllava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vipllava/modeling_vipllava.py
Apache-2.0
def forward( self, input_ids: torch.LongTensor = None, pixel_values: torch.FloatTensor = None, attention_mask: Optional[torch.Tensor] = None, position_ids: Optional[torch.LongTensor] = None, past_key_values: Optional[List[torch.FloatTensor]] = None, inputs_embeds:...
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*): Labels for computing the masked language modeling loss. Indices should either be in `[0, ..., config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored ...
forward
python
huggingface/transformers
src/transformers/models/vipllava/modeling_vipllava.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vipllava/modeling_vipllava.py
Apache-2.0
def encode( self, pixel_values: jnp.ndarray, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, train: bool = False, params: Optional[dict] = None, dropout_rng: PRNGKey = None, ): ...
Returns: Example: ```python >>> from transformers import AutoImageProcessor, FlaxVisionEncoderDecoderModel >>> from PIL import Image >>> import requests >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" >>> image = Image.open(requests....
encode
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
Apache-2.0
def decode( self, decoder_input_ids, encoder_outputs, decoder_attention_mask: Optional[jnp.ndarray] = None, decoder_position_ids: Optional[jnp.ndarray] = None, past_key_values: Optional[dict] = None, output_attentions: Optional[bool] = None, output_hidden_...
Returns: Example: ```python >>> from transformers import AutoImageProcessor, FlaxVisionEncoderDecoderModel >>> import jax.numpy as jnp >>> from PIL import Image >>> import requests >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" ...
decode
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
Apache-2.0
def __call__( self, pixel_values: jnp.ndarray, decoder_input_ids: Optional[jnp.ndarray] = None, decoder_attention_mask: Optional[jnp.ndarray] = None, decoder_position_ids: Optional[jnp.ndarray] = None, output_attentions: Optional[bool] = None, output_hidden_states...
Returns: Examples: ```python >>> from transformers import FlaxVisionEncoderDecoderModel, AutoImageProcessor, AutoTokenizer >>> from PIL import Image >>> import requests >>> url = "http://images.cocodataset.org/val2017/000000039769.jpg" >>> image = Imag...
__call__
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
Apache-2.0
def from_encoder_decoder_pretrained( cls, encoder_pretrained_model_name_or_path: Optional[Union[str, os.PathLike]] = None, decoder_pretrained_model_name_or_path: Optional[Union[str, os.PathLike]] = None, *model_args, **kwargs, ) -> FlaxPreTrainedModel: r""" In...
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model checkpoints. Params: encoder_pretrained_model_name_or_path (`Union[str, os.PathLike]`, *optional*): Information necessary to initiate the encoder. Can be either: ...
from_encoder_decoder_pretrained
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_flax_vision_encoder_decoder.py
Apache-2.0
def from_encoder_decoder_pretrained( cls, encoder_pretrained_model_name_or_path: Optional[str] = None, decoder_pretrained_model_name_or_path: Optional[str] = None, *model_args, **kwargs, ) -> TFPreTrainedModel: r""" Instantiate an encoder and a decoder from on...
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model checkpoints. Params: encoder_pretrained_model_name_or_path (`str`, *optional*): Information necessary to initiate the encoder. Can be either: ...
from_encoder_decoder_pretrained
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py
Apache-2.0
def call( self, pixel_values: np.ndarray | tf.Tensor | None = None, decoder_input_ids: np.ndarray | tf.Tensor | None = None, decoder_attention_mask: np.ndarray | tf.Tensor | None = None, encoder_outputs: Optional[Union[Tuple, TFBaseModelOutput]] = None, past_key_values: O...
Returns: Examples: ```python >>> from transformers import AutoImageProcessor, AutoTokenizer, TFVisionEncoderDecoderModel >>> from PIL import Image >>> import requests >>> image_processor = AutoImageProcessor.from_pretrained("google/vit-base-patch16-224-in21k")...
call
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_tf_vision_encoder_decoder.py
Apache-2.0
def from_encoder_decoder_pretrained( cls, encoder_pretrained_model_name_or_path: Optional[str] = None, decoder_pretrained_model_name_or_path: Optional[str] = None, *model_args, **kwargs, ) -> PreTrainedModel: r""" Instantiate an encoder and a decoder from one ...
Instantiate an encoder and a decoder from one or two base classes of the library from pretrained model checkpoints. The model is set in evaluation mode by default using `model.eval()` (Dropout modules are deactivated). To train the model, you need to first set it back in training mode...
from_encoder_decoder_pretrained
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.FloatTensor] = None, decoder_input_ids: Optional[torch.LongTensor] = None, decoder_attention_mask: Optional[torch.BoolTensor] = None, encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None, past_key_values: Optional[Tupl...
decoder_input_ids (`torch.LongTensor` of shape `(batch_size, target_sequence_length)`, *optional*): Indices of decoder input sequence tokens in the vocabulary. Indices can be obtained using [`PreTrainedTokenizer`]. See [`PreTrainedTokenizer.encode`] and [`PreTrainedTokenize...
forward
python
huggingface/transformers
src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
Apache-2.0
def from_vision_text_pretrained( cls, vision_model_name_or_path: Optional[str] = None, text_model_name_or_path: Optional[str] = None, *model_args, **kwargs, ) -> FlaxPreTrainedModel: """ Params: vision_model_name_or_path (`str`, *optional*, default...
Params: vision_model_name_or_path (`str`, *optional*, defaults to `None`): Information necessary to initiate the vision model. Can be either: - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co. - A p...
from_vision_text_pretrained
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_flax_vision_text_dual_encoder.py
Apache-2.0
def call( self, input_ids: tf.Tensor | None = None, pixel_values: tf.Tensor | None = None, attention_mask: tf.Tensor | None = None, position_ids: tf.Tensor | None = None, return_loss: Optional[bool] = None, token_type_ids: tf.Tensor | None = None, output_a...
Returns: Examples: ```python >>> from PIL import Image >>> import requests >>> from transformers import ( ... TFVisionTextDualEncoderModel, ... VisionTextDualEncoderProcessor, ... AutoImageProcessor, ... AutoTokenizer, ...
call
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py
Apache-2.0
def from_vision_text_pretrained( cls, vision_model_name_or_path: Optional[str] = None, text_model_name_or_path: Optional[str] = None, *model_args, **kwargs, ) -> TFPreTrainedModel: """ Params: vision_model_name_or_path (`str`, *optional*, defaults ...
Params: vision_model_name_or_path (`str`, *optional*, defaults to `None`): Information necessary to initiate the vision model. Can be either: - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co. - A p...
from_vision_text_pretrained
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_tf_vision_text_dual_encoder.py
Apache-2.0
def __init__( self, config: Optional[VisionTextDualEncoderConfig] = None, vision_model: Optional[PreTrainedModel] = None, text_model: Optional[PreTrainedModel] = None, ): r""" vision_model (`PreTrainedModel`): The vision model to use. text_model (`...
vision_model (`PreTrainedModel`): The vision model to use. text_model (`PreTrainedModel`): The text model to use.
__init__
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, pixel_values: Optional[torch.FloatTensor] = None, attention_mask: Optional[torch.Tensor] = None, position_ids: Optional[torch.LongTensor] = None, return_loss: Optional[bool] = None, token_type_ids: O...
return_loss (`bool`, *optional*): Whether or not to return the contrastive loss. Examples: ```python >>> from PIL import Image >>> import requests >>> from transformers import ( ... VisionTextDualEncoderModel, ... VisionTextDualEncod...
forward
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
Apache-2.0
def from_vision_text_pretrained( cls, vision_model_name_or_path: Optional[str] = None, text_model_name_or_path: Optional[str] = None, *model_args, **kwargs, ) -> PreTrainedModel: """ Params: vision_model_name_or_path (`str`, *optional*, defaults to...
Params: vision_model_name_or_path (`str`, *optional*, defaults to `None`): Information necessary to initiate the vision model. Can be either: - A string, the *model id* of a pretrained model hosted inside a model repo on huggingface.co. - A p...
from_vision_text_pretrained
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/modeling_vision_text_dual_encoder.py
Apache-2.0
def __call__( self, images: Optional[ImageInput] = None, text: Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None, audio=None, videos=None, **kwargs: Unpack[VisionTextDualEncoderProcessorKwargs], ) -> BatchEncoding: """ ...
Main method to prepare for the model one or several sequences(s) and image(s). This method forwards the `text` and `kwargs` arguments to VisionTextDualEncoderTokenizer's [`~PreTrainedTokenizer.__call__`] if `text` is not `None` to encode the text. To prepare the image(s), this method forwards t...
__call__
python
huggingface/transformers
src/transformers/models/vision_text_dual_encoder/processing_vision_text_dual_encoder.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vision_text_dual_encoder/processing_vision_text_dual_encoder.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
visual_embeds (`torch.FloatTensor` of shape `(batch_size, visual_seq_length, visual_embedding_dim)`, *optional*): The embedded representation of the visual inputs, generally derived using using an object detector. visual_attention_mask (`torch.FloatTensor` of shape `(batch_size, visual_seq_...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
visual_embeds (`torch.FloatTensor` of shape `(batch_size, visual_seq_length, visual_embedding_dim)`, *optional*): The embedded representation of the visual inputs, generally derived using using an object detector. visual_attention_mask (`torch.FloatTensor` of shape `(batch_size, visual_seq_...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
input_ids (`torch.LongTensor` of shape `(batch_size, num_choices, sequence_length)`): Indices of input sequence tokens in the vocabulary. Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and [`PreTrainedTokenizer.__call__`] for details. ...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
visual_embeds (`torch.FloatTensor` of shape `(batch_size, visual_seq_length, visual_embedding_dim)`, *optional*): The embedded representation of the visual inputs, generally derived using using an object detector. visual_attention_mask (`torch.FloatTensor` of shape `(batch_size, visual_seq_...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
visual_embeds (`torch.FloatTensor` of shape `(batch_size, visual_seq_length, visual_embedding_dim)`, *optional*): The embedded representation of the visual inputs, generally derived using using an object detector. visual_attention_mask (`torch.FloatTensor` of shape `(batch_size, visual_seq_...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def forward( self, input_ids: Optional[torch.LongTensor] = None, attention_mask: Optional[torch.LongTensor] = None, token_type_ids: Optional[torch.LongTensor] = None, position_ids: Optional[torch.LongTensor] = None, head_mask: Optional[torch.LongTensor] = None, in...
visual_embeds (`torch.FloatTensor` of shape `(batch_size, visual_seq_length, visual_embedding_dim)`, *optional*): The embedded representation of the visual inputs, generally derived using using an object detector. visual_attention_mask (`torch.FloatTensor` of shape `(batch_size, visual_seq_...
forward
python
huggingface/transformers
src/transformers/models/visual_bert/modeling_visual_bert.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/visual_bert/modeling_visual_bert.py
Apache-2.0
def preprocess( self, images: ImageInput, do_resize: Optional[bool] = None, size: Optional[Dict[str, int]] = None, resample: PILImageResampling = None, do_rescale: Optional[bool] = None, rescale_factor: Optional[float] = None, do_normalize: Optional[bool] ...
Preprocess an image or batch of images. Args: images (`ImageInput`): 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 `do_rescale=False`. ...
preprocess
python
huggingface/transformers
src/transformers/models/vit/image_processing_vit.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit/image_processing_vit.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.Tensor] = None, bool_masked_pos: Optional[torch.BoolTensor] = None, head_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, interpolate_pos_enc...
bool_masked_pos (`torch.BoolTensor` of shape `(batch_size, num_patches)`): Boolean masked positions. Indicates which patches are masked (1) and which aren't (0). Examples: ```python >>> from transformers import AutoImageProcessor, ViTForMaskedImageModeling >>> impor...
forward
python
huggingface/transformers
src/transformers/models/vit/modeling_vit.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit/modeling_vit.py
Apache-2.0
def add_decomposed_relative_positions(attn, queries, rel_pos_h, rel_pos_w, q_size, k_size): """ Calculate decomposed Relative Positional Embeddings as introduced in [MViT2](https://github.com/facebookresearch/mvit/blob/19786631e330df9f3622e5402b4a419a263a2c80/mvit/models/attention.py). Args: at...
Calculate decomposed Relative Positional Embeddings as introduced in [MViT2](https://github.com/facebookresearch/mvit/blob/19786631e330df9f3622e5402b4a419a263a2c80/mvit/models/attention.py). Args: attn (`torch.Tensor`): Attention map. queries (`torch.Tensor`): Query...
add_decomposed_relative_positions
python
huggingface/transformers
src/transformers/models/vitdet/modeling_vitdet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitdet/modeling_vitdet.py
Apache-2.0
def window_partition(hidden_state, window_size): """ Partition into non-overlapping windows with padding if needed. Args: hidden_state (`torch.Tensor`): Input tokens with [batch_size, height, width, num_channels]. window_size (`int`): Window size. Returns: ...
Partition into non-overlapping windows with padding if needed. Args: hidden_state (`torch.Tensor`): Input tokens with [batch_size, height, width, num_channels]. window_size (`int`): Window size. Returns: `tuple(torch.FloatTensor)` comprising various element...
window_partition
python
huggingface/transformers
src/transformers/models/vitdet/modeling_vitdet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitdet/modeling_vitdet.py
Apache-2.0
def window_unpartition(windows, window_size, pad_height_width, height_width): """ Window unpartition into original sequences and removing padding. Args: windows (`torch.Tensor`): Input tokens with [batch_size * num_windows, window_size, window_size, num_channels]. window_size (`...
Window unpartition into original sequences and removing padding. Args: windows (`torch.Tensor`): Input tokens with [batch_size * num_windows, window_size, window_size, num_channels]. window_size (`int`): Window size. pad_height_width (`Tuple[int]`): ...
window_unpartition
python
huggingface/transformers
src/transformers/models/vitdet/modeling_vitdet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitdet/modeling_vitdet.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.Tensor] = None, head_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, ) -> Union[Tuple, BaseModelOutput]: ...
Examples: ```python >>> from transformers import VitDetConfig, VitDetModel >>> import torch >>> config = VitDetConfig() >>> model = VitDetModel(config) >>> pixel_values = torch.randn(1, 3, 224, 224) >>> with torch.no_grad(): ... outputs = ...
forward
python
huggingface/transformers
src/transformers/models/vitdet/modeling_vitdet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitdet/modeling_vitdet.py
Apache-2.0
def forward( self, pixel_values: torch.Tensor, output_hidden_states: Optional[bool] = None, output_attentions: Optional[bool] = None, return_dict: Optional[bool] = None, ) -> BackboneOutput: r""" Examples: ```python >>> from transformers impor...
Examples: ```python >>> from transformers import VitDetConfig, VitDetBackbone >>> import torch >>> config = VitDetConfig() >>> model = VitDetBackbone(config) >>> pixel_values = torch.randn(1, 3, 224, 224) >>> with torch.no_grad(): ... outp...
forward
python
huggingface/transformers
src/transformers/models/vitdet/modeling_vitdet.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitdet/modeling_vitdet.py
Apache-2.0
def preprocess( self, images: list["torch.Tensor"], trimaps: list["torch.Tensor"], **kwargs: Unpack[VitMatteFastImageProcessorKwargs], ) -> BatchFeature: r""" trimaps (`list[torch.Tensor]`): The trimaps to preprocess. """ validate_kwargs(ca...
trimaps (`list[torch.Tensor]`): The trimaps to preprocess.
preprocess
python
huggingface/transformers
src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
Apache-2.0
def _prepare_input_trimaps( self, trimaps: ImageInput, device: Optional["torch.device"] = None ) -> list["torch.Tensor"]: """ Prepare input trimaps for processing,m this can not yet deal with nested list Args: trimaps ('ImageInout): The input trimaps to b...
Prepare input trimaps for processing,m this can not yet deal with nested list Args: trimaps ('ImageInout): The input trimaps to be process, should not be nested device('Optional['torch.device'] defaults to 'self.device'): The device to process th...
_prepare_input_trimaps
python
huggingface/transformers
src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
Apache-2.0
def _pad_image( self, images: "torch.tensor", size_divisibility: int = 32, ) -> "torch.tensor": """ Pads an image or batched images constantly so that width and height are divisible by size_divisibility Args: image (`torch,tensor`): Image ...
Pads an image or batched images constantly so that width and height are divisible by size_divisibility Args: image (`torch,tensor`): Image to pad. size_divisibility (`int`, *optional*, defaults to 32): The width and height of the image will be pa...
_pad_image
python
huggingface/transformers
src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitmatte/image_processing_vitmatte_fast.py
Apache-2.0
def forward( self, pixel_values: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, labels: Optional[torch.Tensor] = None, return_dict: Optional[bool] = None, ): r""" labels (`torch.Lon...
labels (`torch.LongTensor` of shape `(batch_size, height, width)`, *optional*): Ground truth image matting for computing the loss. Examples: ```python >>> from transformers import VitMatteImageProcessor, VitMatteForImageMatting >>> import torch >>> from PIL...
forward
python
huggingface/transformers
src/transformers/models/vitmatte/modeling_vitmatte.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitmatte/modeling_vitmatte.py
Apache-2.0
def box_to_center_and_scale( box: Union[Tuple, List, np.ndarray], image_width: int, image_height: int, normalize_factor: float = 200.0, padding_factor: float = 1.25, ): """ Encodes a bounding box in COCO format into (center, scale). Args: box (`Tuple`, `List`, or `np.ndarray`): ...
Encodes a bounding box in COCO format into (center, scale). Args: box (`Tuple`, `List`, or `np.ndarray`): Bounding box in COCO format (top_left_x, top_left_y, width, height). image_width (`int`): Image width. image_height (`int`): Image height. ...
box_to_center_and_scale
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def coco_to_pascal_voc(bboxes: np.ndarray) -> np.ndarray: """ Converts bounding boxes from the COCO format to the Pascal VOC format. In other words, converts from (top_left_x, top_left_y, width, height) format to (top_left_x, top_left_y, bottom_right_x, bottom_right_y). Args: bboxes (`np.n...
Converts bounding boxes from the COCO format to the Pascal VOC format. In other words, converts from (top_left_x, top_left_y, width, height) format to (top_left_x, top_left_y, bottom_right_x, bottom_right_y). Args: bboxes (`np.ndarray` of shape `(batch_size, 4)): Bounding boxes in...
coco_to_pascal_voc
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def get_keypoint_predictions(heatmaps: np.ndarray) -> Tuple[np.ndarray, np.ndarray]: """Get keypoint predictions from score maps. Args: heatmaps (`np.ndarray` of shape `(batch_size, num_keypoints, height, width)`): Model predicted heatmaps. Returns: tuple: A tuple containing ag...
Get keypoint predictions from score maps. Args: heatmaps (`np.ndarray` of shape `(batch_size, num_keypoints, height, width)`): Model predicted heatmaps. Returns: tuple: A tuple containing aggregated results. - coords (`np.ndarray` of shape `(batch_size, num_keypoints, 2)`)...
get_keypoint_predictions
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def post_dark_unbiased_data_processing(coords: np.ndarray, batch_heatmaps: np.ndarray, kernel: int = 3) -> np.ndarray: """DARK post-pocessing. Implemented by unbiased_data_processing. Paper references: - Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimati...
DARK post-pocessing. Implemented by unbiased_data_processing. Paper references: - Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimation (CVPR 2020). - Zhang et al. Distribution-Aware Coordinate Representation for Human Pose Estimation (CVPR 2020). Ar...
post_dark_unbiased_data_processing
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def transform_preds(coords: np.ndarray, center: np.ndarray, scale: np.ndarray, output_size: np.ndarray) -> np.ndarray: """Get final keypoint predictions from heatmaps and apply scaling and translation to map them back to the image. Note: num_keypoints: K Args: coords (`np.ndarray` of s...
Get final keypoint predictions from heatmaps and apply scaling and translation to map them back to the image. Note: num_keypoints: K Args: coords (`np.ndarray` of shape `(num_keypoints, ndims)`): * If ndims=2, corrds are predicted keypoint location. * If ndims=4, c...
transform_preds
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def get_warp_matrix(theta: float, size_input: np.ndarray, size_dst: np.ndarray, size_target: np.ndarray): """ Calculate the transformation matrix under the constraint of unbiased. Paper ref: Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimation (CVPR 2020)...
Calculate the transformation matrix under the constraint of unbiased. Paper ref: Huang et al. The Devil is in the Details: Delving into Unbiased Data Processing for Human Pose Estimation (CVPR 2020). Source: https://github.com/open-mmlab/mmpose/blob/master/mmpose/core/post_processing/post_transforms.py ...
get_warp_matrix
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def affine_transform( self, image: np.array, center: Tuple[float], scale: Tuple[float], rotation: float, size: Dict[str, int], data_format: Optional[ChannelDimension] = None, input_data_format: Optional[Union[str, ChannelDimension]] = None, ) -> np.arr...
Apply an affine transformation to an image. Args: image (`np.array`): Image to transform. center (`Tuple[float]`): Center of the bounding box (x, y). scale (`Tuple[float]`): Scale of the bounding box with respect to he...
affine_transform
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def preprocess( self, images: ImageInput, boxes: Union[List[List[float]], np.ndarray], do_affine_transform: Optional[bool] = None, size: Optional[Dict[str, int]] = None, do_rescale: Optional[bool] = None, rescale_factor: Optional[float] = None, do_normaliz...
Preprocess an image or batch of images. Args: images (`ImageInput`): 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 `do_rescale=False`. ...
preprocess
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def keypoints_from_heatmaps( self, heatmaps: np.ndarray, center: np.ndarray, scale: np.ndarray, kernel: int = 11, ): """ Get final keypoint predictions from heatmaps and transform them back to the image. Args: heatmaps (`np.ndarray...
Get final keypoint predictions from heatmaps and transform them back to the image. Args: heatmaps (`np.ndarray` of shape `(batch_size, num_keypoints, height, width])`): Model predicted heatmaps. center (`np.ndarray` of shape `(batch_size, 2)`): ...
keypoints_from_heatmaps
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def post_process_pose_estimation( self, outputs: "VitPoseEstimatorOutput", boxes: Union[List[List[List[float]]], np.ndarray], kernel_size: int = 11, threshold: Optional[float] = None, target_sizes: Union[TensorType, List[Tuple]] = None, ): """ Transfor...
Transform the heatmaps into keypoint predictions and transform them back to the image. Args: outputs (`VitPoseEstimatorOutput`): VitPoseForPoseEstimation model outputs. boxes (`List[List[List[float]]]` or `np.ndarray`): List or array of bounding ...
post_process_pose_estimation
python
huggingface/transformers
src/transformers/models/vitpose/image_processing_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/image_processing_vitpose.py
Apache-2.0
def flip_back(output_flipped, flip_pairs, target_type="gaussian-heatmap"): """Flip the flipped heatmaps back to the original form. Args: output_flipped (`torch.tensor` of shape `(batch_size, num_keypoints, height, width)`): The output heatmaps obtained from the flipped images. flip_...
Flip the flipped heatmaps back to the original form. Args: output_flipped (`torch.tensor` of shape `(batch_size, num_keypoints, height, width)`): The output heatmaps obtained from the flipped images. flip_pairs (`torch.Tensor` of shape `(num_keypoints, 2)`): Pairs of keypoin...
flip_back
python
huggingface/transformers
src/transformers/models/vitpose/modeling_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/modeling_vitpose.py
Apache-2.0
def forward( self, pixel_values: torch.Tensor, dataset_index: Optional[torch.Tensor] = None, flip_pairs: Optional[torch.Tensor] = None, labels: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, ...
dataset_index (`torch.Tensor` of shape `(batch_size,)`): Index to use in the Mixture-of-Experts (MoE) blocks of the backbone. This corresponds to the dataset index used during training, e.g. For the single dataset index 0 refers to the corresponding dataset. For the multiple datasets i...
forward
python
huggingface/transformers
src/transformers/models/vitpose/modeling_vitpose.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose/modeling_vitpose.py
Apache-2.0
def forward( self, pixel_values: torch.Tensor, dataset_index: Optional[torch.Tensor] = None, head_mask: Optional[torch.Tensor] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None, ):...
dataset_index (`torch.Tensor` of shape `(batch_size,)`): Index to use in the Mixture-of-Experts (MoE) blocks of the backbone. This corresponds to the dataset index used during training, e.g. index 0 refers to COCO. Examples: ```python >>> from transformers imp...
forward
python
huggingface/transformers
src/transformers/models/vitpose_backbone/modeling_vitpose_backbone.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vitpose_backbone/modeling_vitpose_backbone.py
Apache-2.0
def forward( self, input_ids: Optional[torch.Tensor] = None, attention_mask: Optional[torch.Tensor] = None, speaker_id: Optional[int] = None, output_attentions: Optional[bool] = None, output_hidden_states: Optional[bool] = None, return_dict: Optional[bool] = None,...
speaker_id (`int`, *optional*): Which speaker embedding to use. Only used for multispeaker models. labels (`torch.FloatTensor` of shape `(batch_size, config.spectrogram_bins, sequence_length)`, *optional*): Float values of target spectrogram. Timesteps set to `-100.0` are ignore...
forward
python
huggingface/transformers
src/transformers/models/vits/modeling_vits.py
https://github.com/huggingface/transformers/blob/master/src/transformers/models/vits/modeling_vits.py
Apache-2.0