source
stringclasses 470
values | url
stringlengths 49
167
| file_type
stringclasses 1
value | chunk
stringlengths 1
512
| chunk_id
stringlengths 5
9
|
---|---|---|---|---|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforctc
|
.md
|
Wav2Vec2Bert Model with a `language modeling` head on top for Connectionist Temporal Classification (CTC).
Wav2Vec2Bert was proposed in [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech
Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael
Auli.
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving etc.).
|
315_7_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforctc
|
.md
|
library implements for all its model (such as downloading or saving etc.).
This model is a PyTorch [nn.Module](https://pytorch.org/docs/stable/nn.html#nn.Module) sub-class. Use it as a
regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
Parameters:
config ([`Wav2Vec2BertConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
315_7_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforctc
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
315_7_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforsequenceclassification
|
.md
|
Wav2Vec2Bert Model with a sequence classification head on top (a linear layer over the pooled output) for
tasks like SUPERB Keyword Spotting.
Wav2Vec2Bert was proposed in [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech
Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael
Auli.
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
315_8_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforsequenceclassification
|
.md
|
Auli.
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving etc.).
This model is a PyTorch [nn.Module](https://pytorch.org/docs/stable/nn.html#nn.Module) sub-class. Use it as a
regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
Parameters:
|
315_8_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforsequenceclassification
|
.md
|
Parameters:
config ([`Wav2Vec2BertConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
315_8_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforaudioframeclassification
|
.md
|
Wav2Vec2Bert Model with a frame classification head on top for tasks like Speaker Diarization.
Wav2Vec2Bert was proposed in [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech
Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael
Auli.
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving etc.).
|
315_9_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforaudioframeclassification
|
.md
|
library implements for all its model (such as downloading or saving etc.).
This model is a PyTorch [nn.Module](https://pytorch.org/docs/stable/nn.html#nn.Module) sub-class. Use it as a
regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
Parameters:
config ([`Wav2Vec2BertConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
315_9_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforaudioframeclassification
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
315_9_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforxvector
|
.md
|
Wav2Vec2Bert Model with an XVector feature extraction head on top for tasks like Speaker Verification.
Wav2Vec2Bert was proposed in [wav2vec 2.0: A Framework for Self-Supervised Learning of Speech
Representations](https://arxiv.org/abs/2006.11477) by Alexei Baevski, Henry Zhou, Abdelrahman Mohamed, Michael
Auli.
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
library implements for all its model (such as downloading or saving etc.).
|
315_10_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforxvector
|
.md
|
library implements for all its model (such as downloading or saving etc.).
This model is a PyTorch [nn.Module](https://pytorch.org/docs/stable/nn.html#nn.Module) sub-class. Use it as a
regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and behavior.
Parameters:
config ([`Wav2Vec2BertConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
315_10_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/wav2vec2-bert.md
|
https://huggingface.co/docs/transformers/en/model_doc/wav2vec2-bert/#wav2vec2bertforxvector
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
315_10_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/
|
.md
|
<!--Copyright 2021 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
316_0_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/
|
.md
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
|
316_0_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#overview
|
.md
|
The RoFormer model was proposed in [RoFormer: Enhanced Transformer with Rotary Position Embedding](https://arxiv.org/pdf/2104.09864v1.pdf) by Jianlin Su and Yu Lu and Shengfeng Pan and Bo Wen and Yunfeng Liu.
The abstract from the paper is the following:
*Position encoding in transformer architecture provides supervision for dependency modeling between elements at
different positions in the sequence. We investigate various methods to encode positional information in
|
316_1_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#overview
|
.md
|
different positions in the sequence. We investigate various methods to encode positional information in
transformer-based language models and propose a novel implementation named Rotary Position Embedding(RoPE). The
proposed RoPE encodes absolute positional information with rotation matrix and naturally incorporates explicit relative
position dependency in self-attention formulation. Notably, RoPE comes with valuable properties such as flexibility of
|
316_1_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#overview
|
.md
|
position dependency in self-attention formulation. Notably, RoPE comes with valuable properties such as flexibility of
being expand to any sequence lengths, decaying inter-token dependency with increasing relative distances, and
capability of equipping the linear self-attention with relative position encoding. As a result, the enhanced
transformer with rotary position embedding, or RoFormer, achieves superior performance in tasks with long texts. We
|
316_1_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#overview
|
.md
|
transformer with rotary position embedding, or RoFormer, achieves superior performance in tasks with long texts. We
release the theoretical analysis along with some preliminary experiment results on Chinese data. The undergoing
experiment for English benchmark will soon be updated.*
This model was contributed by [junnyu](https://huggingface.co/junnyu). The original code can be found [here](https://github.com/ZhuiyiTechnology/roformer).
|
316_1_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#usage-tips
|
.md
|
RoFormer is a BERT-like autoencoding model with rotary position embeddings. Rotary position embeddings have shown
improved performance on classification tasks with long texts.
|
316_2_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#resources
|
.md
|
- [Text classification task guide](../tasks/sequence_classification)
- [Token classification task guide](../tasks/token_classification)
- [Question answering task guide](../tasks/question_answering)
- [Causal language modeling task guide](../tasks/language_modeling)
- [Masked language modeling task guide](../tasks/masked_language_modeling)
- [Multiple choice task guide](../tasks/multiple_choice)
|
316_3_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
This is the configuration class to store the configuration of a [`RoFormerModel`]. It is used to instantiate an
RoFormer model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a similar configuration to that of the RoFormer
[junnyu/roformer_chinese_base](https://huggingface.co/junnyu/roformer_chinese_base) architecture.
|
316_4_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
[junnyu/roformer_chinese_base](https://huggingface.co/junnyu/roformer_chinese_base) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
Args:
vocab_size (`int`, *optional*, defaults to 50000):
Vocabulary size of the RoFormer model. Defines the number of different tokens that can be represented by
|
316_4_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
Vocabulary size of the RoFormer model. Defines the number of different tokens that can be represented by
the `inputs_ids` passed when calling [`RoFormerModel`] or [`TFRoFormerModel`].
embedding_size (`int`, *optional*, defaults to None):
Dimensionality of the encoder layers and the pooler layer. Defaults to the `hidden_size` if not provided.
hidden_size (`int`, *optional*, defaults to 768):
Dimension of the encoder layers and the pooler layer.
num_hidden_layers (`int`, *optional*, defaults to 12):
|
316_4_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
Dimension of the encoder layers and the pooler layer.
num_hidden_layers (`int`, *optional*, defaults to 12):
Number of hidden layers in the Transformer encoder.
num_attention_heads (`int`, *optional*, defaults to 12):
Number of attention heads for each attention layer in the Transformer encoder.
intermediate_size (`int`, *optional*, defaults to 3072):
Dimension of the "intermediate" (i.e., feed-forward) layer in the Transformer encoder.
hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
|
316_4_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
hidden_act (`str` or `function`, *optional*, defaults to `"gelu"`):
The non-linear activation function (function or string) in the encoder and pooler. If string, `"gelu"`,
`"relu"`, `"selu"` and `"gelu_new"` are supported.
hidden_dropout_prob (`float`, *optional*, defaults to 0.1):
The dropout probability for all fully connected layers in the embeddings, encoder, and pooler.
attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
The dropout ratio for the attention probabilities.
|
316_4_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
attention_probs_dropout_prob (`float`, *optional*, defaults to 0.1):
The dropout ratio for the attention probabilities.
max_position_embeddings (`int`, *optional*, defaults to 1536):
The maximum sequence length that this model might ever be used with. Typically set this to something large
just in case (e.g., 512 or 1024 or 1536).
type_vocab_size (`int`, *optional*, defaults to 2):
The vocabulary size of the `token_type_ids` passed when calling [`RoFormerModel`] or [`TFRoFormerModel`].
|
316_4_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
The vocabulary size of the `token_type_ids` passed when calling [`RoFormerModel`] or [`TFRoFormerModel`].
initializer_range (`float`, *optional*, defaults to 0.02):
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
layer_norm_eps (`float`, *optional*, defaults to 1e-12):
The epsilon used by the layer normalization layers.
is_decoder (`bool`, *optional*, defaults to `False`):
|
316_4_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
The epsilon used by the layer normalization layers.
is_decoder (`bool`, *optional*, defaults to `False`):
Whether the model is used as a decoder or not. If `False`, the model is used as an encoder.
use_cache (`bool`, *optional*, defaults to `True`):
Whether or not the model should return the last key/values attentions (not used by all models). Only
relevant if `config.is_decoder=True`.
rotary_value (`bool`, *optional*, defaults to `False`):
Whether or not apply rotary position embeddings on value layer.
|
316_4_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
rotary_value (`bool`, *optional*, defaults to `False`):
Whether or not apply rotary position embeddings on value layer.
Example:
```python
>>> from transformers import RoFormerModel, RoFormerConfig
|
316_4_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerconfig
|
.md
|
>>> # Initializing a RoFormer junnyu/roformer_chinese_base style configuration
>>> configuration = RoFormerConfig()
>>> # Initializing a model (with random weights) from the junnyu/roformer_chinese_base style configuration
>>> model = RoFormerModel(configuration)
>>> # Accessing the model configuration
>>> configuration = model.config
```
|
316_4_9
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
Construct a RoFormer tokenizer. Based on [Rust Jieba](https://pypi.org/project/rjieba/).
This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to
this superclass for more information regarding those methods.
Args:
vocab_file (`str`):
File containing the vocabulary.
do_lower_case (`bool`, *optional*, defaults to `True`):
Whether or not to lowercase the input when tokenizing.
do_basic_tokenize (`bool`, *optional*, defaults to `True`):
|
316_5_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
Whether or not to lowercase the input when tokenizing.
do_basic_tokenize (`bool`, *optional*, defaults to `True`):
Whether or not to do basic tokenization before WordPiece.
never_split (`Iterable`, *optional*):
Collection of tokens which will never be split during tokenization. Only has an effect when
`do_basic_tokenize=True`
unk_token (`str`, *optional*, defaults to `"[UNK]"`):
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.
|
316_5_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
The unknown token. A token that is not in the vocabulary cannot be converted to an ID and is set to be this
token instead.
sep_token (`str`, *optional*, defaults to `"[SEP]"`):
The separator token, which is used when building a sequence from multiple sequences, e.g. two sequences for
sequence classification or for a text and a question for question answering. It is also used as the last
token of a sequence built with special tokens.
pad_token (`str`, *optional*, defaults to `"[PAD]"`):
|
316_5_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
token of a sequence built with special tokens.
pad_token (`str`, *optional*, defaults to `"[PAD]"`):
The token used for padding, for example when batching sequences of different lengths.
cls_token (`str`, *optional*, defaults to `"[CLS]"`):
The classifier token which is used when doing sequence classification (classification of the whole sequence
instead of per-token classification). It is the first token of the sequence when built with special tokens.
|
316_5_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
instead of per-token classification). It is the first token of the sequence when built with special tokens.
mask_token (`str`, *optional*, defaults to `"[MASK]"`):
The token used for masking values. This is the token used when training this model with masked language
modeling. This is the token which the model will try to predict.
tokenize_chinese_chars (`bool`, *optional*, defaults to `True`):
Whether or not to tokenize Chinese characters.
This should likely be deactivated for Japanese (see this
|
316_5_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
Whether or not to tokenize Chinese characters.
This should likely be deactivated for Japanese (see this
[issue](https://github.com/huggingface/transformers/issues/328)).
strip_accents (`bool`, *optional*):
Whether or not to strip all accents. If this option is not specified, then it will be determined by the
value for `lowercase` (as in the original BERT).
Example:
```python
>>> from transformers import RoFormerTokenizer
|
316_5_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizer
|
.md
|
>>> tokenizer = RoFormerTokenizer.from_pretrained("junnyu/roformer_chinese_base")
>>> tokenizer.tokenize("今天天气非常好。")
['今', '天', '天', '气', '非常', '好', '。']
```
Methods: build_inputs_with_special_tokens
- get_special_tokens_mask
- create_token_type_ids_from_sequences
- save_vocabulary
|
316_5_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizerfast
|
.md
|
Construct a "fast" RoFormer tokenizer (backed by HuggingFace's *tokenizers* library).
[`RoFormerTokenizerFast`] is almost identical to [`BertTokenizerFast`] and runs end-to-end tokenization:
punctuation splitting and wordpiece. There are some difference between them when tokenizing Chinese.
This tokenizer inherits from [`PreTrainedTokenizerFast`] which contains most of the main methods. Users should
refer to this superclass for more information regarding those methods.
Example:
```python
|
316_6_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizerfast
|
.md
|
refer to this superclass for more information regarding those methods.
Example:
```python
>>> from transformers import RoFormerTokenizerFast
|
316_6_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformertokenizerfast
|
.md
|
>>> tokenizer = RoFormerTokenizerFast.from_pretrained("junnyu/roformer_chinese_base")
>>> tokenizer.tokenize("今天天气非常好。")
['今', '天', '天', '气', '非常', '好', '。']
```
Methods: build_inputs_with_special_tokens
<frameworkcontent>
<pt>
|
316_6_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformermodel
|
.md
|
The bare RoFormer Model transformer outputting raw hidden-states without any specific head on top.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
|
316_7_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformermodel
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
|
316_7_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformermodel
|
.md
|
The model can behave as an encoder (with only self-attention) as well as a decoder, in which case a layer of
cross-attention is added between the self-attention layers, following the architecture described in [Attention is
all you need](https://arxiv.org/abs/1706.03762) by Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit,
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.
|
316_7_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformermodel
|
.md
|
Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin.
To behave as an decoder the model needs to be initialized with the `is_decoder` argument of the configuration set
to `True`. To be used in a Seq2Seq model, the model needs to initialized with both `is_decoder` argument and
`add_cross_attention` set to `True`; an `encoder_hidden_states` is then expected as an input to the forward pass.
Methods: forward
|
316_7_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforcausallm
|
.md
|
RoFormer Model with a `language modeling` head on top for CLM fine-tuning.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
|
316_8_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforcausallm
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
316_8_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerformaskedlm
|
.md
|
RoFormer Model with a `language modeling` head on top.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
|
316_9_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerformaskedlm
|
.md
|
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
316_9_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforsequenceclassification
|
.md
|
RoFormer Model transformer with a sequence classification/regression head on top (a linear layer on top of the
pooled output) e.g. for GLUE tasks.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
|
316_10_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforsequenceclassification
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
316_10_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerformultiplechoice
|
.md
|
RoFormer Model with a multiple choice classification head on top (a linear layer on top of the pooled output and a
softmax) e.g. for RocStories/SWAG tasks.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
|
316_11_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerformultiplechoice
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
316_11_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerfortokenclassification
|
.md
|
RoFormer Model with a token classification head on top (a linear layer on top of the hidden-states output) e.g. for
Named-Entity-Recognition (NER) tasks.
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
|
316_12_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerfortokenclassification
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
|
316_12_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforquestionanswering
|
.md
|
RoFormer Model with a span classification head on top for extractive question-answering tasks like SQuAD (a linear
layers on top of the hidden-states output to compute `span start logits` and `span end logits`).
This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
behavior.
Parameters:
|
316_13_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#roformerforquestionanswering
|
.md
|
behavior.
Parameters:
config ([`RoFormerConfig`]): Model configuration class with all the parameters of the model.
Initializing with a config file does not load the weights associated with the model, only the
configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
Methods: forward
</pt>
<tf>
|
316_13_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformermodel
|
.md
|
No docstring available for TFRoFormerModel
Methods: call
|
316_14_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerformaskedlm
|
.md
|
No docstring available for TFRoFormerForMaskedLM
Methods: call
|
316_15_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerforcausallm
|
.md
|
No docstring available for TFRoFormerForCausalLM
Methods: call
|
316_16_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerforsequenceclassification
|
.md
|
No docstring available for TFRoFormerForSequenceClassification
Methods: call
|
316_17_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerformultiplechoice
|
.md
|
No docstring available for TFRoFormerForMultipleChoice
Methods: call
|
316_18_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerfortokenclassification
|
.md
|
No docstring available for TFRoFormerForTokenClassification
Methods: call
|
316_19_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#tfroformerforquestionanswering
|
.md
|
No docstring available for TFRoFormerForQuestionAnswering
Methods: call
</tf>
<jax>
|
316_20_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformermodel
|
.md
|
No docstring available for FlaxRoFormerModel
Methods: __call__
|
316_21_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformerformaskedlm
|
.md
|
No docstring available for FlaxRoFormerForMaskedLM
Methods: __call__
|
316_22_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformerforsequenceclassification
|
.md
|
No docstring available for FlaxRoFormerForSequenceClassification
Methods: __call__
|
316_23_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformerformultiplechoice
|
.md
|
No docstring available for FlaxRoFormerForMultipleChoice
Methods: __call__
|
316_24_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformerfortokenclassification
|
.md
|
No docstring available for FlaxRoFormerForTokenClassification
Methods: __call__
|
316_25_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/roformer.md
|
https://huggingface.co/docs/transformers/en/model_doc/roformer/#flaxroformerforquestionanswering
|
.md
|
No docstring available for FlaxRoFormerForQuestionAnswering
Methods: __call__
</jax>
</frameworkcontent>
|
316_26_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/
|
.md
|
<!--Copyright 2024 The HuggingFace Team. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
317_0_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/
|
.md
|
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.
-->
|
317_0_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
The OmDet-Turbo model was proposed in [Real-time Transformer-based Open-Vocabulary Detection with Efficient Fusion Head](https://arxiv.org/abs/2403.06892) by Tiancheng Zhao, Peng Liu, Xuan He, Lu Zhang, Kyusong Lee. OmDet-Turbo incorporates components from RT-DETR and introduces a swift multimodal fusion module to achieve real-time open-vocabulary object detection capabilities while maintaining high accuracy. The base model achieves performance of up to 100.2 FPS and 53.4 AP on COCO zero-shot.
|
317_1_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
The abstract from the paper is the following:
|
317_1_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
*End-to-end transformer-based detectors (DETRs) have shown exceptional performance in both closed-set and open-vocabulary object detection (OVD) tasks through the integration of language modalities. However, their demanding computational requirements have hindered their practical application in real-time object detection (OD) scenarios. In this paper, we scrutinize the limitations of two leading models in the OVDEval benchmark, OmDet and Grounding-DINO, and introduce OmDet-Turbo. This novel
|
317_1_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
the limitations of two leading models in the OVDEval benchmark, OmDet and Grounding-DINO, and introduce OmDet-Turbo. This novel transformer-based real-time OVD model features an innovative Efficient Fusion Head (EFH) module designed to alleviate the bottlenecks observed in OmDet and Grounding-DINO. Notably, OmDet-Turbo-Base achieves a 100.2 frames per second (FPS) with TensorRT and language cache techniques applied. Notably, in zero-shot scenarios on COCO and LVIS datasets, OmDet-Turbo achieves performance
|
317_1_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
language cache techniques applied. Notably, in zero-shot scenarios on COCO and LVIS datasets, OmDet-Turbo achieves performance levels nearly on par with current state-of-the-art supervised models. Furthermore, it establishes new state-of-the-art benchmarks on ODinW and OVDEval, boasting an AP of 30.1 and an NMS-AP of 26.86, respectively. The practicality of OmDet-Turbo in industrial applications is underscored by its exceptional performance on benchmark datasets and superior inference speed, positioning it
|
317_1_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
applications is underscored by its exceptional performance on benchmark datasets and superior inference speed, positioning it as a compelling choice for real-time object detection tasks.*
|
317_1_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#overview
|
.md
|
<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/transformers/model_doc/omdet_turbo_architecture.jpeg" alt="drawing" width="600"/>
<small> OmDet-Turbo architecture overview. Taken from the <a href="https://arxiv.org/abs/2403.06892">original paper</a>. </small>
This model was contributed by [yonigozlan](https://huggingface.co/yonigozlan).
The original code can be found [here](https://github.com/om-ai-lab/OmDet).
|
317_1_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#usage-tips
|
.md
|
One unique property of OmDet-Turbo compared to other zero-shot object detection models, such as [Grounding DINO](grounding-dino), is the decoupled classes and prompt embedding structure that allows caching of text embeddings. This means that the model needs both classes and task as inputs, where classes is a list of objects we want to detect and task is the grounded text used to guide open-vocabulary detection. This approach limits the scope of the open-vocabulary detection and makes the decoding process
|
317_2_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#usage-tips
|
.md
|
guide open-vocabulary detection. This approach limits the scope of the open-vocabulary detection and makes the decoding process faster.
|
317_2_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#usage-tips
|
.md
|
[`OmDetTurboProcessor`] is used to prepare the classes, task and image triplet. The task input is optional, and when not provided, it will default to `"Detect [class1], [class2], [class3], ..."`. To process the results from the model, one can use `post_process_grounded_object_detection` from [`OmDetTurboProcessor`]. Notably, this function takes in the input classes, as unlike other zero-shot object detection models, the decoupling of classes and task embeddings means that no decoding of the predicted class
|
317_2_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#usage-tips
|
.md
|
zero-shot object detection models, the decoupling of classes and task embeddings means that no decoding of the predicted class embeddings is needed in the post-processing step, and the predicted classes can be matched to the inputted ones directly.
|
317_2_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#single-image-inference
|
.md
|
Here's how to load the model and prepare the inputs to perform zero-shot object detection on a single image:
```python
>>> import torch
>>> import requests
>>> from PIL import Image
>>> from transformers import AutoProcessor, OmDetTurboForObjectDetection
>>> processor = AutoProcessor.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
>>> model = OmDetTurboForObjectDetection.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
|
317_3_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#single-image-inference
|
.md
|
>>> url = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image = Image.open(requests.get(url, stream=True).raw)
>>> text_labels = ["cat", "remote"]
>>> inputs = processor(image, text=text_labels, return_tensors="pt")
>>> with torch.no_grad():
... outputs = model(**inputs)
|
317_3_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#single-image-inference
|
.md
|
>>> # convert outputs (bounding boxes and class logits)
>>> results = processor.post_process_grounded_object_detection(
... outputs,
... target_sizes=[(image.height, image.width)],
... text_labels=text_labels,
... threshold=0.3,
... nms_threshold=0.3,
... )
>>> result = results[0]
>>> boxes, scores, text_labels = result["boxes"], result["scores"], result["text_labels"]
>>> for box, score, text_label in zip(boxes, scores, text_labels):
... box = [round(i, 2) for i in box.tolist()]
|
317_3_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#single-image-inference
|
.md
|
>>> for box, score, text_label in zip(boxes, scores, text_labels):
... box = [round(i, 2) for i in box.tolist()]
... print(f"Detected {text_label} with confidence {round(score.item(), 3)} at location {box}")
Detected remote with confidence 0.768 at location [39.89, 70.35, 176.74, 118.04]
Detected cat with confidence 0.72 at location [11.6, 54.19, 314.8, 473.95]
Detected remote with confidence 0.563 at location [333.38, 75.77, 370.7, 187.03]
|
317_3_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#single-image-inference
|
.md
|
Detected remote with confidence 0.563 at location [333.38, 75.77, 370.7, 187.03]
Detected cat with confidence 0.552 at location [345.15, 23.95, 639.75, 371.67]
```
|
317_3_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
OmDet-Turbo can perform batched multi-image inference, with support for different text prompts and classes in the same batch:
```python
>>> import torch
>>> import requests
>>> from io import BytesIO
>>> from PIL import Image
>>> from transformers import AutoProcessor, OmDetTurboForObjectDetection
>>> processor = AutoProcessor.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
>>> model = OmDetTurboForObjectDetection.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
|
317_4_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
>>> url1 = "http://images.cocodataset.org/val2017/000000039769.jpg"
>>> image1 = Image.open(BytesIO(requests.get(url1).content)).convert("RGB")
>>> text_labels1 = ["cat", "remote"]
>>> task1 = "Detect {}.".format(", ".join(text_labels1))
>>> url2 = "http://images.cocodataset.org/train2017/000000257813.jpg"
>>> image2 = Image.open(BytesIO(requests.get(url2).content)).convert("RGB")
>>> text_labels2 = ["boat"]
>>> task2 = "Detect everything that looks like a boat."
|
317_4_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
>>> url3 = "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
>>> image3 = Image.open(BytesIO(requests.get(url3).content)).convert("RGB")
>>> text_labels3 = ["statue", "trees"]
>>> task3 = "Focus on the foreground, detect statue and trees."
>>> inputs = processor(
... images=[image1, image2, image3],
... text=[text_labels1, text_labels2, text_labels3],
... task=[task1, task2, task3],
... return_tensors="pt",
... )
|
317_4_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
>>> with torch.no_grad():
... outputs = model(**inputs)
>>> # convert outputs (bounding boxes and class logits)
>>> results = processor.post_process_grounded_object_detection(
... outputs,
... text_labels=[text_labels1, text_labels2, text_labels3],
... target_sizes=[(image.height, image.width) for image in [image1, image2, image3]],
... threshold=0.2,
... nms_threshold=0.3,
... )
|
317_4_3
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
>>> for i, result in enumerate(results):
... for score, text_label, box in zip(
... result["scores"], result["text_labels"], result["boxes"]
... ):
... box = [round(i, 1) for i in box.tolist()]
... print(
... f"Detected {text_label} with confidence "
... f"{round(score.item(), 2)} at location {box} in image {i}"
... )
Detected remote with confidence 0.77 at location [39.9, 70.4, 176.7, 118.0] in image 0
|
317_4_4
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
... )
Detected remote with confidence 0.77 at location [39.9, 70.4, 176.7, 118.0] in image 0
Detected cat with confidence 0.72 at location [11.6, 54.2, 314.8, 474.0] in image 0
Detected remote with confidence 0.56 at location [333.4, 75.8, 370.7, 187.0] in image 0
Detected cat with confidence 0.55 at location [345.2, 24.0, 639.8, 371.7] in image 0
Detected boat with confidence 0.32 at location [146.9, 219.8, 209.6, 250.7] in image 1
|
317_4_5
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
Detected boat with confidence 0.32 at location [146.9, 219.8, 209.6, 250.7] in image 1
Detected boat with confidence 0.3 at location [319.1, 223.2, 403.2, 238.4] in image 1
Detected boat with confidence 0.27 at location [37.7, 220.3, 84.0, 235.9] in image 1
Detected boat with confidence 0.22 at location [407.9, 207.0, 441.7, 220.2] in image 1
Detected statue with confidence 0.73 at location [544.7, 210.2, 651.9, 502.8] in image 2
|
317_4_6
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
Detected statue with confidence 0.73 at location [544.7, 210.2, 651.9, 502.8] in image 2
Detected trees with confidence 0.25 at location [3.9, 584.3, 391.4, 785.6] in image 2
Detected trees with confidence 0.25 at location [1.4, 621.2, 118.2, 787.8] in image 2
Detected statue with confidence 0.2 at location [428.1, 205.5, 767.3, 759.5] in image 2
|
317_4_7
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#multi-image-inference
|
.md
|
```
|
317_4_8
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#omdetturboconfig
|
.md
|
This is the configuration class to store the configuration of a [`OmDetTurboForObjectDetection`].
It is used to instantiate a OmDet-Turbo model according to the specified arguments, defining the model architecture
Instantiating a configuration with the defaults will yield a similar configuration to that of the OmDet-Turbo
[omlab/omdet-turbo-swin-tiny-hf](https://huggingface.co/omlab/omdet-turbo-swin-tiny-hf) architecture.
|
317_5_0
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#omdetturboconfig
|
.md
|
[omlab/omdet-turbo-swin-tiny-hf](https://huggingface.co/omlab/omdet-turbo-swin-tiny-hf) architecture.
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
documentation from [`PretrainedConfig`] for more information.
Args:
text_config (`PretrainedConfig`, *optional*):
The configuration of the text backbone.
backbone_config (`PretrainedConfig`, *optional*):
The configuration of the vision backbone.
|
317_5_1
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#omdetturboconfig
|
.md
|
backbone_config (`PretrainedConfig`, *optional*):
The configuration of the vision backbone.
use_timm_backbone (`bool`, *optional*, defaults to `True`):
Whether to use the timm for the vision backbone.
backbone (`str`, *optional*, defaults to `"swin_tiny_patch4_window7_224"`):
The name of the pretrained vision backbone to use. If `use_pretrained_backbone=False` a randomly initialized
backbone with the same architecture `backbone` is used.
backbone_kwargs (`dict`, *optional*):
|
317_5_2
|
/Users/nielsrogge/Documents/python_projecten/transformers/docs/source/en/model_doc/omdet-turbo.md
|
https://huggingface.co/docs/transformers/en/model_doc/omdet-turbo/#omdetturboconfig
|
.md
|
backbone with the same architecture `backbone` is used.
backbone_kwargs (`dict`, *optional*):
Additional kwargs for the vision backbone.
use_pretrained_backbone (`bool`, *optional*, defaults to `False`):
Whether to use a pretrained vision backbone.
apply_layernorm_after_vision_backbone (`bool`, *optional*, defaults to `True`):
Whether to apply layer normalization on the feature maps of the vision backbone output.
image_size (`int`, *optional*, defaults to 640):
The size (resolution) of each image.
|
317_5_3
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.