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 interpolate_pos_encoding(self, embeddings) -> tf.Tensor:
"""
This method is a modified version of the interpolation function for ViT-mae model at the decoder, that
allows to interpolate the pre-trained decoder position encodings, to be able to use the model on higher
resolution image... |
This method is a modified version of the interpolation function for ViT-mae model at the decoder, that
allows to interpolate the pre-trained decoder position encodings, to be able to use the model on higher
resolution images.
Source:
https://github.com/facebookresearch/dino/blo... | interpolate_pos_encoding | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def patchify(self, pixel_values, interpolate_pos_encoding: bool = False):
"""
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)` or `(batch_size, num_channels, height, width)`):
Pixel values.
interpolate_pos_encoding (`bool`, defa... |
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)` or `(batch_size, num_channels, height, width)`):
Pixel values.
interpolate_pos_encoding (`bool`, default `False`):
interpolation flag passed during the forward pass.
... | patchify | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def unpatchify(self, patchified_pixel_values, original_image_size: Optional[Tuple[int, int]] = None):
"""
Args:
patchified_pixel_values (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
original_image_size (`... |
Args:
patchified_pixel_values (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
original_image_size (`Tuple[int, int]`, *optional*):
Original image size.
Returns:
`tf.Tensor` of ... | unpatchify | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def forward_loss(self, pixel_values, pred, mask, interpolate_pos_encoding: bool = False):
"""
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)`):
Pixel values.
pred (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 *... |
Args:
pixel_values (`tf.Tensor` of shape `(batch_size, height, width, num_channels)`):
Pixel values.
pred (`tf.Tensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Predicted pixel values.
mask (`tf.Tensor` of shape `(bat... | forward_loss | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_tf_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_tf_vit_mae.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
noise: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optio... |
interpolate_pos_encoding (`bool`, *optional*, default `False`):
Whether to interpolate the pre-trained position encodings. This is mainly used to use the model on higher
resolution images.
noise (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optional*):
... | forward | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def interpolate_pos_encoding(self, embeddings: torch.Tensor) -> torch.Tensor:
"""
This method is a modified version of the interpolation function for ViT-mae model at the decoder, that
allows to interpolate the pre-trained decoder position encodings, to be able to use the model on higher
... |
This method is a modified version of the interpolation function for ViT-mae model at the decoder, that
allows to interpolate the pre-trained decoder position encodings, to be able to use the model on higher
resolution images.
Adapted from:
https://github.com/facebookresearch/di... | interpolate_pos_encoding | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def patchify(self, pixel_values, interpolate_pos_encoding: bool = False):
"""
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
interpolate_pos_encoding (`bool`, *optional*, default `False`):
... |
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
interpolate_pos_encoding (`bool`, *optional*, default `False`):
interpolation flag passed during the forward pass.
Returns:
`... | patchify | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def unpatchify(self, patchified_pixel_values, original_image_size: Optional[Tuple[int, int]] = None):
"""
Args:
patchified_pixel_values (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
original_image... |
Args:
patchified_pixel_values (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Patchified pixel values.
original_image_size (`Tuple[int, int]`, *optional*):
Original image size.
Returns:
`torch.... | unpatchify | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward_loss(self, pixel_values, pred, mask, interpolate_pos_encoding: bool = False):
"""
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
pred (`torch.FloatTensor` of shape `(batch_size, num_patches,... |
Args:
pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
Pixel values.
pred (`torch.FloatTensor` of shape `(batch_size, num_patches, patch_size**2 * num_channels)`:
Predicted pixel values.
mask (`torch.Flo... | forward_loss | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
noise: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optio... |
interpolate_pos_encoding (`bool`, *optional*, default `False`):
Whether to interpolate the pre-trained position encodings. This is mainly used to use the model on higher
resolution images.
noise (`torch.FloatTensor` of shape `(batch_size, sequence_length)`, *optional*):
... | forward | python | huggingface/transformers | src/transformers/models/vit_mae/modeling_vit_mae.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_mae/modeling_vit_mae.py | Apache-2.0 |
def __init__(self, config: ViTMSNConfig, use_mask_token: bool = False):
r"""
use_mask_token (`bool`, *optional*, defaults to `False`):
Whether to use a mask token for masked image modeling.
"""
super().__init__(config)
self.config = config
self.embeddings = V... |
use_mask_token (`bool`, *optional*, defaults to `False`):
Whether to use a mask token for masked image modeling.
| __init__ | python | huggingface/transformers | src/transformers/models/vit_msn/modeling_vit_msn.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_msn/modeling_vit_msn.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)`, *optional*):
Boolean masked positions. Indicates which patches are masked (1) and which aren't (0).
Examples:
```python
>>> from transformers import AutoImageProcessor, ViTMSNModel
>>> import... | forward | python | huggingface/transformers | src/transformers/models/vit_msn/modeling_vit_msn.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_msn/modeling_vit_msn.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,
interpolate_pos_encoding: Option... |
Examples:
```python
>>> from transformers import AutoImageProcessor, ViTMSNForImageClassification
>>> import torch
>>> from PIL import Image
>>> import requests
>>> torch.manual_seed(2) # doctest: +IGNORE_RESULT
>>> url = "http://images.cocodataset.or... | forward | python | huggingface/transformers | src/transformers/models/vit_msn/modeling_vit_msn.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vit_msn/modeling_vit_msn.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_encoding: bool = False,
return_dict: Optional... |
Examples:
```python
>>> import av
>>> import numpy as np
>>> from transformers import VivitImageProcessor, VivitModel
>>> from huggingface_hub import hf_hub_download
>>> np.random.seed(0)
>>> def read_video_pyav(container, indices):
... '... | forward | python | huggingface/transformers | src/transformers/models/vivit/modeling_vivit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vivit/modeling_vivit.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
labels: Optional[torch.LongTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
interpolate_pos_en... |
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/vivit/modeling_vivit.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/vivit/modeling_vivit.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
truncation: bool = False,
pad_to_multiple_of: Optional[int] = None,
return_at... |
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/wav2vec2/feature_extraction_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/feature_extraction_wav2vec2.py | Apache-2.0 |
def forward(
self,
input_values: Optional[torch.Tensor],
attention_mask: Optional[torch.Tensor] = None,
mask_time_indices: Optional[torch.BoolTensor] = None,
sampled_negative_indices: Optional[torch.BoolTensor] = None,
output_attentions: Optional[bool] = None,
out... |
mask_time_indices (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices to mask extracted features for contrastive loss. When in training mode, model learns to predict
masked extracted features in *config.proj_codevector_dim* space.
sampled_negative_... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2/modeling_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/modeling_wav2vec2.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 [`Wav2Vec2ForCTC... |
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 [`Wav2Vec2ForCTC`] with adapters. Uses 'eng' by
default.
| __init__ | python | huggingface/transformers | src/transformers/models/wav2vec2/modeling_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/modeling_wav2vec2.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/wav2vec2/modeling_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/modeling_wav2vec2.py | Apache-2.0 |
def __call__(
self,
audio: AudioInput = None,
text: Optional[Union[str, List[str], TextInput, PreTokenizedInput]] = None,
images=None,
videos=None,
**kwargs: Unpack[Wav2Vec2ProcessorKwargs],
):
"""
This method forwards all its arguments to Wav2Vec2Feat... |
This method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.__call__`] and returns its output.
| __call__ | python | huggingface/transformers | src/transformers/models/wav2vec2/processing_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/processing_wav2vec2.py | Apache-2.0 |
def pad(self, *args, **kwargs):
"""
This method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output.
"""
# For backward compatibility
if self._in_target_context_manager:
return self.current_processo... |
This method forwards all its arguments to Wav2Vec2FeatureExtractor's
[`~Wav2Vec2FeatureExtractor.pad`] and returns its output.
| pad | python | huggingface/transformers | src/transformers/models/wav2vec2/processing_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/processing_wav2vec2.py | Apache-2.0 |
def _tokenize(self, text, **kwargs):
"""
Converts a string into a sequence of tokens (string), using the tokenizer.
"""
if self.do_lower_case:
text = text.upper()
return list(text.replace(" ", self.word_delimiter_token)) |
Converts a string into a sequence of tokens (string), using the tokenizer.
| _tokenize | python | huggingface/transformers | src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
padding: Union[bool, str, PaddingStrategy] = False,
max_length: Optional[int] = None,
pad_to_multiple_of: Optional[int] = None,
padding_side: Optional[str] = None,
... |
Main method to tokenize and prepare for the model one or several sequence(s) or one or several pair(s) of
sequences.
Args:
raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
The sequence or batch of sequences to be padded. Each sequen... | __call__ | python | huggingface/transformers | src/transformers/models/wav2vec2/tokenization_wav2vec2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2/tokenization_wav2vec2.py | Apache-2.0 |
def _compute_new_attention_mask(hidden_states: torch.Tensor, seq_lens: torch.Tensor):
"""
Computes an attention mask of the form `(batch, seq_len)` with an attention for each element in the batch that
stops at the corresponding element in `seq_lens`.
Args:
hidden_states (`torch.FloatTensor` of s... |
Computes an attention mask of the form `(batch, seq_len)` with an attention for each element in the batch that
stops at the corresponding element in `seq_lens`.
Args:
hidden_states (`torch.FloatTensor` of shape `(batch, seq_len, *)`):
The sequences to mask, where `*` is any number of se... | _compute_new_attention_mask | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | Apache-2.0 |
def forward(
self,
input_features: Optional[torch.Tensor],
attention_mask: Optional[torch.Tensor] = None,
mask_time_indices: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Opt... |
input_features (`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 ins... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | Apache-2.0 |
def forward(
self,
input_features: 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] = No... |
input_features (`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 ins... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | Apache-2.0 |
def forward(
self,
input_features: 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] = No... |
input_features (`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 ins... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | Apache-2.0 |
def forward(
self,
input_features: Optional[torch.Tensor],
attention_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... |
input_features (`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 ins... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/modeling_wav2vec2_bert.py | Apache-2.0 |
def __call__(
self,
audio: AudioInput = None,
text: Optional[Union[str, List[str], TextInput, PreTokenizedInput]] = None,
images=None,
videos=None,
**kwargs: Unpack[Wav2Vec2BertProcessorKwargs],
):
"""
Main method to prepare for the model one or severa... |
Main method to prepare for the model one or several sequences(s) and audio(s). This method forwards the `audio`
and `kwargs` arguments to SeamlessM4TFeatureExtractor's [`~SeamlessM4TFeatureExtractor.__call__`] if `audio` is not
`None` to pre-process the audio. To prepare the target sequences(s)... | __call__ | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/processing_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/processing_wav2vec2_bert.py | Apache-2.0 |
def pad(self, input_features=None, labels=None, **kwargs):
"""
If `input_features` is not `None`, this method forwards the `input_features` and `kwargs` arguments to SeamlessM4TFeatureExtractor's [`~SeamlessM4TFeatureExtractor.pad`] to pad the input features.
If `labels` is not `None`, this meth... |
If `input_features` is not `None`, this method forwards the `input_features` and `kwargs` arguments to SeamlessM4TFeatureExtractor's [`~SeamlessM4TFeatureExtractor.pad`] to pad the input features.
If `labels` is not `None`, this method forwards the `labels` and `kwargs` arguments to PreTrainedTokenizer... | pad | python | huggingface/transformers | src/transformers/models/wav2vec2_bert/processing_wav2vec2_bert.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_bert/processing_wav2vec2_bert.py | Apache-2.0 |
def forward(
self,
input_values: Optional[torch.Tensor],
attention_mask: Optional[torch.Tensor] = None,
mask_time_indices: Optional[torch.BoolTensor] = None,
sampled_negative_indices: Optional[torch.BoolTensor] = None,
output_attentions: Optional[bool] = None,
out... |
mask_time_indices (`torch.BoolTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices to mask extracted features for contrastive loss. When in training mode, model learns to predict
masked extracted features in *config.proj_codevector_dim* space.
sampled_negative_... | forward | python | huggingface/transformers | src/transformers/models/wav2vec2_conformer/modeling_wav2vec2_conformer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_conformer/modeling_wav2vec2_conformer.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/wav2vec2_conformer/modeling_wav2vec2_conformer.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_conformer/modeling_wav2vec2_conformer.py | Apache-2.0 |
def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
r"""
Instantiate a [`Wav2Vec2ProcessorWithLM`] from a pretrained Wav2Vec2 processor.
<Tip>
This class method is simply calling the feature extractor's
[`~feature_extraction_utils.FeatureExtractionMixin.from_pret... |
Instantiate a [`Wav2Vec2ProcessorWithLM`] from a pretrained Wav2Vec2 processor.
<Tip>
This class method is simply calling the feature extractor's
[`~feature_extraction_utils.FeatureExtractionMixin.from_pretrained`], Wav2Vec2CTCTokenizer's
[`~tokenization_utils_base.PreTrainedT... | from_pretrained | python | huggingface/transformers | src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def __call__(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to the feature extractor's
[`~FeatureExtractionMixin.__call__`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards a... |
When used in normal mode, this method forwards all its arguments to the feature extractor's
[`~FeatureExtractionMixin.__call__`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all its arguments to
Wav2Vec2CTCTokenizer... | __call__ | python | huggingface/transformers | src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | Apache-2.0 |
def pad(self, *args, **kwargs):
"""
When used in normal mode, this method forwards all its arguments to the feature extractor's
[`~FeatureExtractionMixin.pad`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all its arg... |
When used in normal mode, this method forwards all its arguments to the feature extractor's
[`~FeatureExtractionMixin.pad`] and returns its output. If used in the context
[`~Wav2Vec2ProcessorWithLM.as_target_processor`] this method forwards all its arguments to
Wav2Vec2CTCTokenizer's [`... | pad | python | huggingface/transformers | src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.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 [`WavLMForCTC`] ... |
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 [`WavLMForCTC`] with adapters. Uses 'eng' by
default.
| __init__ | python | huggingface/transformers | src/transformers/models/wavlm/modeling_wavlm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wavlm/modeling_wavlm.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/wavlm/modeling_wavlm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/wavlm/modeling_wavlm.py | Apache-2.0 |
def _get_generation_config(
is_multilingual: bool,
num_languages: int = 100,
openai_version: Optional[str] = None,
) -> GenerationConfig:
"""
Loads the appropriate generation config from HF repo
"""
if openai_version is not None:
repo = f"openai/whisper-{openai_version}"
elif not... |
Loads the appropriate generation config from HF repo
| _get_generation_config | python | huggingface/transformers | src/transformers/models/whisper/convert_openai_to_hf.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/convert_openai_to_hf.py | Apache-2.0 |
def __call__(
self,
raw_speech: Union[np.ndarray, List[float], List[np.ndarray], List[List[float]]],
truncation: bool = True,
pad_to_multiple_of: Optional[int] = None,
return_tensors: Optional[Union[str, TensorType]] = None,
return_attention_mask: Optional[bool] = None,
... |
Main method to featurize and prepare for the model one or several sequence(s). Implementation uses PyTorch for
the STFT computation if available, otherwise a slower NumPy based one.
Args:
raw_speech (`np.ndarray`, `List[float]`, `List[np.ndarray]`, `List[List[float]]`):
... | __call__ | python | huggingface/transformers | src/transformers/models/whisper/feature_extraction_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/feature_extraction_whisper.py | Apache-2.0 |
def generate(
self,
input_features: Optional[torch.Tensor] = None,
generation_config: Optional[GenerationConfig] = None,
logits_processor: Optional[LogitsProcessorList] = None,
stopping_criteria: Optional[StoppingCriteriaList] = None,
prefix_allowed_tokens_fn: Optional[Ca... |
Transcribes or translates log-mel input features to a sequence of auto-regressively generated token ids.
<Tip warning={true}>
Most generation-controlling parameters are set in `generation_config` which, if not passed, will be set to the
model's default generation configuration. You ca... | generate | python | huggingface/transformers | src/transformers/models/whisper/generation_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/generation_whisper.py | Apache-2.0 |
def call(
self,
input_ids=None,
attention_mask=None,
position_ids=None,
encoder_hidden_states=None,
head_mask=None,
cross_attn_head_mask=None,
past_key_values=None,
inputs_embeds=None,
use_cache=None,
output_attentions=None,
... |
Args:
input_ids (`tf.Tensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`WhisperTokenizer`]. See [`PreTrained... | call | python | huggingface/transformers | src/transformers/models/whisper/modeling_tf_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_tf_whisper.py | Apache-2.0 |
def forward(
self,
input_ids=None,
attention_mask=None,
encoder_hidden_states=None,
head_mask=None,
cross_attn_head_mask=None,
past_key_values=None,
inputs_embeds=None,
position_ids=None,
use_cache=None,
output_attentions=None,
... |
Args:
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you
provide it.
Indices can be obtained using [`WhisperTokenizer`]. See [`Pre... | forward | python | huggingface/transformers | src/transformers/models/whisper/modeling_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_features: Optional[torch.FloatTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.Tensor] = N... |
input_features (`torch.FloatTensor` of shape `(batch_size, feature_size, sequence_length)`):
Float values mel features extracted from the raw speech waveform. Raw speech waveform can be obtained by
loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.nd... | forward | python | huggingface/transformers | src/transformers/models/whisper/modeling_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_features: Optional[torch.FloatTensor] = None,
attention_mask: Optional[torch.LongTensor] = None,
decoder_input_ids: Optional[torch.LongTensor] = None,
decoder_attention_mask: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.Tensor] = N... |
input_features (`torch.FloatTensor` of shape `(batch_size, feature_size, sequence_length)`):
Float values mel features extracted from the raw speech waveform. Raw speech waveform can be obtained by
loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.nd... | forward | python | huggingface/transformers | src/transformers/models/whisper/modeling_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
encoder_outputs: Optional[Tuple[torch.FloatTensor]] = None,
head_mask: Optional[torch.Tensor] = None,
cross_attn_head_mask: Optional[torch.Tensor] = None,
... |
encoder_outputs (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention
if the model is configured as a decoder.
cross_attn_head_mask (`torch.Te... | forward | python | huggingface/transformers | src/transformers/models/whisper/modeling_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def forward(
self,
input_features: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.Tensor] = None,
encoder_outputs: Optional[Tuple[Tuple[torch.FloatTensor]]] = None,
labels: Optional[torch.LongTensor] = None,
output_attentions: Optional[bool] = None,
... |
input_features (`torch.FloatTensor` of shape `(batch_size, feature_size, sequence_length)`):
Float values mel features extracted from the raw speech waveform. Raw speech waveform can be obtained by
loading a `.flac` or `.wav` audio file into an array of type `List[float]` or a `numpy.nd... | forward | python | huggingface/transformers | src/transformers/models/whisper/modeling_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/modeling_whisper.py | Apache-2.0 |
def __call__(self, *args, **kwargs):
"""
Forwards the `audio` argument to WhisperFeatureExtractor's [`~WhisperFeatureExtractor.__call__`] and the `text`
argument to [`~WhisperTokenizer.__call__`]. Please refer to the docstring of the above two methods for more
information.
"""
... |
Forwards the `audio` argument to WhisperFeatureExtractor's [`~WhisperFeatureExtractor.__call__`] and the `text`
argument to [`~WhisperTokenizer.__call__`]. Please refer to the docstring of the above two methods for more
information.
| __call__ | python | huggingface/transformers | src/transformers/models/whisper/processing_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/processing_whisper.py | Apache-2.0 |
def _compute_offsets(self, token_ids, time_precision=0.02, segment_size=1500):
"""
Compute offsets for a given tokenized input
Args:
token_ids (`Union[int, List[int], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtained using the `__ca... |
Compute offsets for a given tokenized input
Args:
token_ids (`Union[int, List[int], np.ndarray, torch.Tensor, tf.Tensor]`):
List of tokenized input ids. Can be obtained using the `__call__` method.
time_precision (`float`, *optional*, defaults to 0.02):
... | _compute_offsets | python | huggingface/transformers | src/transformers/models/whisper/tokenization_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/tokenization_whisper.py | Apache-2.0 |
def decode(
self,
token_ids,
skip_special_tokens: bool = False,
clean_up_tokenization_spaces: Optional[bool] = None,
output_offsets: bool = False,
time_precision: float = 0.02,
decode_with_timestamps: bool = False,
normalize: bool = False,
basic_no... |
Converts a sequence of ids in a string, using the tokenizer and vocabulary with options to remove special
tokens and clean up tokenization spaces.
Similar to doing `self.convert_tokens_to_string(self.convert_ids_to_tokens(token_ids))`.
Args:
token_ids (`Union[int, List[int... | decode | python | huggingface/transformers | src/transformers/models/whisper/tokenization_whisper.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/whisper/tokenization_whisper.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
he... |
encoder_hidden_states (`torch.FloatTensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of
the decoder.
encoder_attention_mask (`torch.LongTensor`... | forward | python | huggingface/transformers | src/transformers/models/xglm/modeling_xglm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xglm/modeling_xglm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
encoder_hidden_states: Optional[torch.Tensor] = None,
encoder_attention_mask: Optional[torch.Tensor] = None,
he... |
encoder_hidden_states (`torch.FloatTensor` of shape `(batch_size, encoder_sequence_length, hidden_size)`, *optional*):
Sequence of hidden-states at the output of the last layer of the encoder. Used in the cross-attention of
the decoder.
encoder_attention_mask (`torch.LongTensor`... | forward | python | huggingface/transformers | src/transformers/models/xglm/modeling_xglm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xglm/modeling_xglm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
langs: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
lengths: Optional[torch.Te... |
langs (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
A parallel sequence of tokens to be used to indicate the language of each token in the input. Indices are
languages ids which can be obtained from the language names by using two conversion mappings provide... | forward | python | huggingface/transformers | src/transformers/models/xlm/modeling_xlm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm/modeling_xlm.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
langs: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
lengths: Optional[torch.Te... |
langs (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
A parallel sequence of tokens to be used to indicate the language of each token in the input. Indices are
languages ids which can be obtained from the language names by using two conversion mappings provide... | forward | python | huggingface/transformers | src/transformers/models/xlm/modeling_xlm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm/modeling_xlm.py | Apache-2.0 |
def romanian_preprocessing(text):
"""Sennrich's WMT16 scripts for Romanian preprocessing, used by model `FacebookAI/xlm-mlm-enro-1024`"""
# https://github.com/rsennrich/wmt16-scripts/blob/master/preprocess/normalise-romanian.py
text = text.replace("\u015e", "\u0218").replace("\u015f", "\u0219")
text = t... | Sennrich's WMT16 scripts for Romanian preprocessing, used by model `FacebookAI/xlm-mlm-enro-1024` | romanian_preprocessing | python | huggingface/transformers | src/transformers/models/xlm/tokenization_xlm.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm/tokenization_xlm.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,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
... |
token_type_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Segment token indices to indicate first and second portions of the inputs. Indices are selected in `[0,1]`:
- 0 corresponds to a *sentence A* token,
- 1 corresponds to a *sentence B* t... | forward | python | huggingface/transformers | src/transformers/models/xlm_roberta/modeling_xlm_roberta.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm_roberta/modeling_xlm_roberta.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,
position_ids: Optional[torch.LongTensor] = None,
head_mask: Optional[torch.FloatTensor] = None,
... |
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the left-to-right language modeling loss (next word prediction). Indices should be in
`[-100, 0, ..., config.vocab_size]` (see `input_ids` docstring) Tokens with indices set to `-100` ... | forward | python | huggingface/transformers | src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
labels: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
head... |
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. [What are input... | forward | python | huggingface/transformers | src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlm_roberta_xl/modeling_xlm_roberta_xl.py | Apache-2.0 |
def call(
self,
input_ids: TFModelInputType | None = None,
attention_mask: np.ndarray | tf.Tensor | None = None,
mems: np.ndarray | tf.Tensor | None = None,
perm_mask: np.ndarray | tf.Tensor | None = None,
target_mapping: np.ndarray | tf.Tensor | None = None,
toke... |
labels (`tf.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the cross entropy classification loss. Indices should be in `[0, ...,
config.vocab_size - 1]`.
Return:
Examples:
```python
>>> import tensorflow as tf
... | call | python | huggingface/transformers | src/transformers/models/xlnet/modeling_tf_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_tf_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Tensor] = None,
target_mapping: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch... |
mems (`List[torch.FloatTensor]` of length `config.n_layers`):
Contains pre-computed hidden-states (see `mems` output below) . Can be used to speed up sequential
decoding. The token ids which have their past given to this model should not be passed as `input_ids` as
they have... | forward | python | huggingface/transformers | src/transformers/models/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Tensor] = None,
target_mapping: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch... |
mems (`List[torch.FloatTensor]` of length `config.n_layers`):
Contains pre-computed hidden-states (see `mems` output below) . Can be used to speed up sequential
decoding. The token ids which have their past given to this model should not be passed as `input_ids` as
they have... | forward | python | huggingface/transformers | src/transformers/models/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Tensor] = None,
target_mapping: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch... |
mems (`List[torch.FloatTensor]` of length `config.n_layers`):
Contains pre-computed hidden-states (see `mems` output below) . Can be used to speed up sequential
decoding. The token ids which have their past given to this model should not be passed as `input_ids` as
they have... | forward | python | huggingface/transformers | src/transformers/models/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Tensor] = None,
target_mapping: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch... |
mems (`List[torch.FloatTensor]` of length `config.n_layers`):
Contains pre-computed hidden-states (see `mems` output below) . Can be used to speed up sequential
decoding. The token ids which have their past given to this model should not be passed as `input_ids` as
they have... | forward | python | huggingface/transformers | src/transformers/models/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch.Tensor] = None,
input_mask: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Ten... |
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/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
mems: Optional[torch.Tensor] = None,
perm_mask: Optional[torch.Tensor] = None,
target_mapping: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch... |
mems (`List[torch.FloatTensor]` of length `config.n_layers`):
Contains pre-computed hidden-states (see `mems` output below) . Can be used to speed up sequential
decoding. The token ids which have their past given to this model should not be passed as `input_ids` as
they have... | forward | python | huggingface/transformers | src/transformers/models/xlnet/modeling_xlnet.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xlnet/modeling_xlnet.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
token_type_ids: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
head_mask: Optional... |
lang_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices of the language adapters that should be activated for each sample, respectively. Default: the index
that corresponds to `self.config.default_language`.
| forward | python | huggingface/transformers | src/transformers/models/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
he... |
lang_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices of the language adapters that should be activated for each sample, respectively. Default: the index
that corresponds to `self.config.default_language`.
labels (`torch.LongTensor` of shape... | forward | python | huggingface/transformers | src/transformers/models/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
he... |
lang_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices of the language adapters that should be activated for each sample, respectively. Default: the index
that corresponds to `self.config.default_language`.
labels (`torch.LongTensor` of shape... | forward | python | huggingface/transformers | src/transformers/models/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
he... |
lang_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices of the language adapters that should be activated for each sample, respectively. Default: the index
that corresponds to `self.config.default_language`.
labels (`torch.LongTensor` of shape... | forward | python | huggingface/transformers | src/transformers/models/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
labels: Optional[torch.LongTensor] = None,
position... |
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/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
lang_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.FloatTensor] = None,
token_type_ids: Optional[torch.LongTensor] = None,
position_ids: Optional[torch.LongTensor] = None,
he... |
lang_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Indices of the language adapters that should be activated for each sample, respectively. Default: the index
that corresponds to `self.config.default_language`.
labels (`torch.LongTensor` of shape... | forward | python | huggingface/transformers | src/transformers/models/xmod/modeling_xmod.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/xmod/modeling_xmod.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.Tensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.Tensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bo... |
Examples:
```python
>>> from transformers import AutoTokenizer, XCLIPTextModel
>>> model = XCLIPTextModel.from_pretrained("microsoft/xclip-base-patch32")
>>> tokenizer = AutoTokenizer.from_pretrained("microsoft/xclip-base-patch32")
>>> inputs = tokenizer(["a photo of ... | forward | python | huggingface/transformers | src/transformers/models/x_clip/modeling_x_clip.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/x_clip/modeling_x_clip.py | Apache-2.0 |
def forward(
self,
pixel_values: Optional[torch.FloatTensor] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] = None,
) -> Union[Tuple, BaseModelOutputWithPooling]:
r"""
Examples:
... |
Examples:
```python
>>> import av
>>> import torch
>>> import numpy as np
>>> from transformers import AutoProcessor, XCLIPVisionModel
>>> from huggingface_hub import hf_hub_download
>>> np.random.seed(0)
>>> def read_video_pyav(container, in... | forward | python | huggingface/transformers | src/transformers/models/x_clip/modeling_x_clip.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/x_clip/modeling_x_clip.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,
output_attentions... |
return_loss (`bool`, *optional*):
Whether or not to return the contrastive loss.
Examples:
```python
>>> import av
>>> import torch
>>> import numpy as np
>>> from transformers import AutoProcessor, AutoModel
>>> from huggingface_hub import... | forward | python | huggingface/transformers | src/transformers/models/x_clip/modeling_x_clip.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/x_clip/modeling_x_clip.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 CLIPTokenizerFast's [`~CLIPTokenizerFast.__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 CLIPTokenizerFast's [`~CLIPTokenizerFast.__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/x_clip/processing_x_clip.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/x_clip/processing_x_clip.py | Apache-2.0 |
def get_size_with_aspect_ratio(
image_size: Tuple[int, int], size: int, max_size: Optional[int] = None, mod_size: int = 16
) -> Tuple[int, int]:
"""
Computes the output image size given the input image size and the desired output size with multiple of divisible_size.
Args:
image_size (`Tuple[in... |
Computes the output image size given the input image size and the desired output size with multiple of divisible_size.
Args:
image_size (`Tuple[int, int]`):
The input image size.
size (`int`):
The desired output size.
max_size (`int`, *optional*):
Th... | get_size_with_aspect_ratio | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos.py | Apache-2.0 |
def pad(
self,
images: List[np.ndarray],
annotations: Optional[List[Dict[str, Any]]] = None,
constant_values: Union[float, Iterable[float]] = 0,
return_pixel_mask: bool = False,
return_tensors: Optional[Union[str, TensorType]] = None,
data_format: Optional[Channel... |
Pads a batch of images to the bottom and right of the image with zeros to the size of largest height and width
in the batch and optionally returns their corresponding pixel mask.
Args:
image (`np.ndarray`):
Image to pad.
annotations (`List[Dict[str, any]... | pad | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos.py | Apache-2.0 |
def preprocess(
self,
images: ImageInput,
annotations: Optional[Union[AnnotationType, List[AnnotationType]]] = None,
return_segmentation_masks: Optional[bool] = None,
masks_path: Optional[Union[str, pathlib.Path]] = None,
do_resize: Optional[bool] = None,
size: Op... |
Preprocess an image or a batch of images so that it can be used by the model.
Args:
images (`ImageInput`):
Image or batch 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 va... | preprocess | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos.py | Apache-2.0 |
def prepare_coco_detection_annotation(
image,
target,
return_segmentation_masks: bool = False,
input_data_format: Optional[Union[ChannelDimension, str]] = None,
):
"""
Convert the target in COCO format into the format expected by YOLOS.
"""
image_height, image_width = image.size()[-2:]
... |
Convert the target in COCO format into the format expected by YOLOS.
| prepare_coco_detection_annotation | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos_fast.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 parameters are updated if image processor is
created using from_dict and kwargs e.g. `YolosImageProcessorFast.from_pretrained(checkpoint, size=600,
ma... |
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. `YolosImageProcessorFast.from_pretrained(checkpoint, size=600,
max_size=800)`
| from_dict | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos_fast.py | Apache-2.0 |
def prepare_annotation(
self,
image: torch.Tensor,
target: Dict,
format: Optional[AnnotationFormat] = None,
return_segmentation_masks: Optional[bool] = None,
masks_path: Optional[Union[str, pathlib.Path]] = None,
input_data_format: Optional[Union[str, ChannelDimen... |
Prepare an annotation for feeding into YOLOS model.
| prepare_annotation | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos_fast.py | Apache-2.0 |
def post_process(self, outputs, target_sizes):
"""
Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x,
top_left_y, bottom_right_x, bottom_right_y) format. Only supports PyTorch.
Args:
outputs ([`YolosObjectDetectionOutput`]):
... |
Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x,
top_left_y, bottom_right_x, bottom_right_y) format. Only supports PyTorch.
Args:
outputs ([`YolosObjectDetectionOutput`]):
Raw outputs of the model.
target_s... | post_process | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos_fast.py | Apache-2.0 |
def post_process_object_detection(
self, outputs, threshold: float = 0.5, target_sizes: Union[TensorType, List[Tuple]] = None, top_k: int = 100
):
"""
Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x,
top_left_y, bottom_right_x, bottom_r... |
Converts the raw output of [`YolosForObjectDetection`] into final bounding boxes in (top_left_x,
top_left_y, bottom_right_x, bottom_right_y) format. Only supports PyTorch.
Args:
outputs ([`YolosObjectDetectionOutput`]):
Raw outputs of the model.
threshol... | post_process_object_detection | python | huggingface/transformers | src/transformers/models/yolos/image_processing_yolos_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/image_processing_yolos_fast.py | Apache-2.0 |
def forward(
self,
pixel_values: torch.FloatTensor,
labels: Optional[List[Dict]] = None,
output_attentions: Optional[bool] = None,
output_hidden_states: Optional[bool] = None,
return_dict: Optional[bool] = None,
) -> Union[Tuple, YolosObjectDetectionOutput]:
r... |
labels (`List[Dict]` of len `(batch_size,)`, *optional*):
Labels for computing the bipartite matching loss. List of dicts, each dictionary containing at least the
following 2 keys: `'class_labels'` and `'boxes'` (the class labels and bounding boxes of an image in the
batch r... | forward | python | huggingface/transformers | src/transformers/models/yolos/modeling_yolos.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/yolos/modeling_yolos.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: torch.Tensor,
layer_idx: int,
attention_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[ZambaHybridDynamicCache] = None,
output_attentions: Optional[bool] = False,
use_ca... |
Args:
hidden_states (`torch.FloatTensor`): output of previous Mamba layer of shape `(batch, seq_len, embed_dim)`
original_hidden_states (`torch.FloatTensor`): word embedding output of shape `(batch, seq_len, embed_dim)`.
This is concatenated with `hidden_states` (which i... | forward | python | huggingface/transformers | src/transformers/models/zamba/modeling_zamba.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba/modeling_zamba.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: Optional[torch.Tensor] = None,
layer_idx: Optional[int] = None,
attention_mask: Optional[torch.Tensor] = None,
causal_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[ZambaHybridD... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
`(batch, sequence_length)` where padding elements are indicated by 0.
past_key_value ... | forward | python | huggingface/transformers | src/transformers/models/zamba/modeling_zamba.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba/modeling_zamba.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: Optional[torch.Tensor] = None,
layer_idx: Optional[int] = None,
attention_mask: Optional[torch.Tensor] = None,
causal_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[ZambaHybridD... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
original_hidden_states (`torch.FloatTensor`): word embedding output that will be concatenated with
hidden activations to form the input of the shared transformer layer.
... | forward | python | huggingface/transformers | src/transformers/models/zamba/modeling_zamba.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba/modeling_zamba.py | Apache-2.0 |
def _check_and_enable_flash_attn_2(
cls,
config,
torch_dtype: Optional[torch.dtype] = None,
device_map: Optional[Union[str, Dict[str, int]]] = None,
hard_check_only: bool = False,
check_device_map: bool = False,
):
"""
Overloads `PreTrainedModel._check... |
Overloads `PreTrainedModel._check_and_enable_flash_attn_2` so as to DISABLE Flash Attention 2 by default on Zamba models.
Flash attention 2 is currently not supported in the HuggingFace implementation of Zamba v1.
| _check_and_enable_flash_attn_2 | python | huggingface/transformers | src/transformers/models/zamba/modeling_zamba.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba/modeling_zamba.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[ZambaHybridDynamicCache] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
... |
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/zamba/modeling_zamba.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba/modeling_zamba.py | Apache-2.0 |
def __init__(self, config: Zamba2Config, num_fwd_mem_blocks=None, block_id: Optional[int] = None):
"""
This MLP layer contributes to tied transformer blocks aimed to increasing compute without increasing model size. Because this layer
is tied, un-tied adapter modules (formally same as LoRA, but ... |
This MLP layer contributes to tied transformer blocks aimed to increasing compute without increasing model size. Because this layer
is tied, un-tied adapter modules (formally same as LoRA, but used in the base model) are added to the up and gate projectors to increase expressivity with a small memory o... | __init__ | python | huggingface/transformers | src/transformers/models/zamba2/modeling_zamba2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba2/modeling_zamba2.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: torch.Tensor,
layer_idx: int,
attention_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[Zamba2HybridDynamicCache] = None,
output_attentions: Optional[bool] = False,
posit... |
Args:
hidden_states (`torch.FloatTensor`): output of previous Mamba layer of shape `(batch, seq_len, embed_dim)`
original_hidden_states (`torch.FloatTensor`): word embedding output of shape `(batch, seq_len, embed_dim)`.
This is concatenated with `hidden_states` (which i... | forward | python | huggingface/transformers | src/transformers/models/zamba2/modeling_zamba2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba2/modeling_zamba2.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: Optional[torch.Tensor] = None,
layer_idx: Optional[int] = None,
attention_mask: Optional[torch.Tensor] = None,
causal_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[Zamba2Hybrid... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
`(batch, sequence_length)` where padding elements are indicated by 0.
past_key_value ... | forward | python | huggingface/transformers | src/transformers/models/zamba2/modeling_zamba2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba2/modeling_zamba2.py | Apache-2.0 |
def forward(
self,
hidden_states: torch.Tensor,
original_hidden_states: Optional[torch.Tensor] = None,
layer_idx: Optional[int] = None,
attention_mask: Optional[torch.Tensor] = None,
causal_mask: Optional[torch.Tensor] = None,
past_key_value: Optional[Zamba2Hybrid... |
Args:
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
original_hidden_states (`torch.FloatTensor`): word embedding output that will be concatenated with
hidden activations to form the input of the shared transformer layer.
... | forward | python | huggingface/transformers | src/transformers/models/zamba2/modeling_zamba2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba2/modeling_zamba2.py | Apache-2.0 |
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
attention_mask: Optional[torch.Tensor] = None,
position_ids: Optional[torch.LongTensor] = None,
past_key_values: Optional[Zamba2HybridDynamicCache] = None,
inputs_embeds: Optional[torch.FloatTensor] = None,
... |
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/zamba2/modeling_zamba2.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zamba2/modeling_zamba2.py | Apache-2.0 |
def convert_zoedepth_checkpoint(model_name, pytorch_dump_folder_path, push_to_hub):
"""
Copy/paste/tweak model's weights to our ZoeDepth structure.
"""
# define ZoeDepth configuration based on URL
config, _ = get_zoedepth_config(model_name)
# load original model
original_model = torch.hub.... |
Copy/paste/tweak model's weights to our ZoeDepth structure.
| convert_zoedepth_checkpoint | python | huggingface/transformers | src/transformers/models/zoedepth/convert_zoedepth_to_hf.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/convert_zoedepth_to_hf.py | Apache-2.0 |
def resize(
self,
image: np.ndarray,
size: Dict[str, int],
keep_aspect_ratio: bool = False,
ensure_multiple_of: int = 1,
resample: PILImageResampling = PILImageResampling.BILINEAR,
data_format: Optional[Union[str, ChannelDimension]] = None,
input_data_form... |
Resize an image to target size `(size["height"], size["width"])`. If `keep_aspect_ratio` is `True`, the image
is resized to the largest possible size such that the aspect ratio is preserved. If `ensure_multiple_of` is
set, the image is resized to a size that is a multiple of this value.
... | resize | python | huggingface/transformers | src/transformers/models/zoedepth/image_processing_zoedepth.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/image_processing_zoedepth.py | Apache-2.0 |
def pad_image(
self,
image: np.array,
mode: PaddingMode = PaddingMode.REFLECT,
data_format: Optional[Union[str, ChannelDimension]] = None,
input_data_format: Optional[Union[str, ChannelDimension]] = None,
):
"""
Pad an image as done in the original ZoeDepth im... |
Pad an image as done in the original ZoeDepth implementation.
Padding fixes the boundary artifacts in the output depth map.
Boundary artifacts are sometimes caused by the fact that the model is trained on NYU raw dataset
which has a black or white border around the image. This function... | pad_image | python | huggingface/transformers | src/transformers/models/zoedepth/image_processing_zoedepth.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/image_processing_zoedepth.py | Apache-2.0 |
def preprocess(
self,
images: ImageInput,
do_pad: Optional[bool] = None,
do_rescale: Optional[bool] = None,
rescale_factor: Optional[float] = None,
do_normalize: Optional[bool] = None,
image_mean: Optional[Union[float, List[float]]] = None,
image_std: Opti... |
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/zoedepth/image_processing_zoedepth.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/image_processing_zoedepth.py | Apache-2.0 |
def resize(
self,
images: "torch.Tensor",
size: SizeDict,
keep_aspect_ratio: bool = False,
ensure_multiple_of: int = 1,
interpolation: Optional["F.InterpolationMode"] = None,
) -> "torch.Tensor":
"""
Resize an image or batchd images to target size `(si... |
Resize an image or batchd images to target size `(size["height"], size["width"])`. If `keep_aspect_ratio` is `True`, the image
is resized to the largest possible size such that the aspect ratio is preserved. If `ensure_multiple_of` is
set, the image is resized to a size that is a multiple of th... | resize | python | huggingface/transformers | src/transformers/models/zoedepth/image_processing_zoedepth_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/image_processing_zoedepth_fast.py | Apache-2.0 |
def _pad_images(
self,
images: "torch.Tensor",
):
"""
Args:
image (`torch.Tensor`):
Image to pad.
"""
height, width = get_image_size(images, channel_dim=ChannelDimension.FIRST)
pad_height = int(np.sqrt(height / 2) * 3)
pad_... |
Args:
image (`torch.Tensor`):
Image to pad.
| _pad_images | python | huggingface/transformers | src/transformers/models/zoedepth/image_processing_zoedepth_fast.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/image_processing_zoedepth_fast.py | Apache-2.0 |
def __init__(self, n_classes=256, act=torch.softmax):
"""Compute log binomial distribution for n_classes
Args:
n_classes (`int`, *optional*, defaults to 256):
Number of output classes.
act (`torch.nn.Module`, *optional*, defaults to `torch.softmax`):
... | Compute log binomial distribution for n_classes
Args:
n_classes (`int`, *optional*, defaults to 256):
Number of output classes.
act (`torch.nn.Module`, *optional*, defaults to `torch.softmax`):
Activation function to apply to the output.
| __init__ | python | huggingface/transformers | src/transformers/models/zoedepth/modeling_zoedepth.py | https://github.com/huggingface/transformers/blob/master/src/transformers/models/zoedepth/modeling_zoedepth.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.