id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
5,000 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerForQuestionAnswering | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from ...utils import auto_docstring, logging
from torch import nn
from typing import Callable, Optional, Union
import torch
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, Mult... | @auto_docstring
class RoFormerForQuestionAnswering(RoFormerPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, head_mask: O... | 5 | 0 | 41 | 5 | 30 | 7 | 4 | 0.2 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 3 | 90 | 11 | 66 | 29 | 45 | 13 | 33 | 16 | 30 | 7 | 2 | 2 | 8 |
5,001 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerForSequenceClassification | from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
from typing import Callable, Optional, Union
import torch
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClass... | @auto_docstring(custom_intro='\n RoFormer Model transformer with a sequence classification/regression head on top (a linear layer on top of the\n pooled output) e.g. for GLUE tasks.\n ')
class RoFormerForSequenceClassification(RoFormerPreTrainedModel):
def __init__(self, config):
pass
@auto_do... | 5 | 1 | 37 | 3 | 31 | 4 | 7 | 0.1 | 1 | 7 | 3 | 0 | 2 | 3 | 2 | 3 | 82 | 7 | 68 | 24 | 48 | 7 | 32 | 12 | 29 | 12 | 2 | 3 | 13 |
5,002 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerForTokenClassification | from torch import nn
from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from typing import Callable, Optional, Union
import torch
from ...ut... | @auto_docstring
class RoFormerForTokenClassification(RoFormerPreTrainedModel):
def __init__(self, config):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Optional[torch.FloatTensor]=None, token_type_ids: Optional[torch.LongTensor]=None, head_mask:... | 5 | 1 | 30 | 4 | 23 | 3 | 3 | 0.09 | 1 | 5 | 2 | 0 | 2 | 4 | 2 | 3 | 67 | 9 | 53 | 25 | 33 | 5 | 22 | 13 | 19 | 5 | 2 | 1 | 6 |
5,003 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerIntermediate | import torch
from torch import nn
from ...activations import ACT2FN, get_activation
class RoFormerIntermediate(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.intermediate_size)
if isinstance(config.hidden_act, str):
... |
class RoFormerIntermediate(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 6 | 0 | 6 | 0 | 2 | 0 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 13 | 1 | 12 | 5 | 9 | 0 | 11 | 5 | 8 | 2 | 1 | 1 | 3 |
5,004 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerLMPredictionHead | import torch
from torch import nn
class RoFormerLMPredictionHead(nn.Module):
def __init__(self, config):
super().__init__()
self.transform = RoFormerPredictionHeadTransform(config)
self.decoder = nn.Linear(config.embedding_size, config.vocab_size, bias=False)
self.bias = nn.Paramet... |
class RoFormerLMPredictionHead(nn.Module):
def __init__(self, config):
pass
def _tie_weights(self) -> None:
pass
def forward(self, hidden_states):
pass | 4 | 0 | 6 | 1 | 4 | 1 | 1 | 0.23 | 1 | 2 | 1 | 0 | 3 | 3 | 3 | 13 | 21 | 5 | 13 | 7 | 9 | 3 | 13 | 7 | 9 | 1 | 1 | 0 | 3 |
5,005 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerLayer | from ...utils.deprecation import deprecate_kwarg
from ...modeling_layers import GradientCheckpointingLayer
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer
class RoFormerLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_idx=None):
... |
class RoFormerLayer(GradientCheckpointingLayer):
def __init__(self, config, layer_idx=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states, attention_mask=None, sinusoidal_pos=None, head_mask=None, encoder_hidden_states=None, en... | 5 | 0 | 28 | 2 | 24 | 2 | 4 | 0.1 | 1 | 5 | 3 | 0 | 3 | 8 | 3 | 13 | 87 | 9 | 73 | 33 | 59 | 7 | 41 | 23 | 37 | 7 | 1 | 2 | 11 |
5,006 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerModel | from ...modeling_outputs import BaseModelOutputWithPastAndCrossAttentions, CausalLMOutputWithCrossAttentions, MaskedLMOutput, MultipleChoiceModelOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput
from typing import Callable, Optional, Union
from ...cache_utils import Cache, DynamicCac... | null | 8 | 1 | 28 | 3 | 18 | 7 | 5 | 0.42 | 1 | 7 | 3 | 0 | 5 | 4 | 5 | 6 | 164 | 23 | 99 | 37 | 73 | 42 | 53 | 22 | 47 | 17 | 2 | 2 | 23 |
5,007 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerOnlyMLMHead | import torch
from torch import nn
class RoFormerOnlyMLMHead(nn.Module):
def __init__(self, config):
super().__init__()
self.predictions = RoFormerLMPredictionHead(config)
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
prediction_scores = self.predictions(sequence_ou... |
class RoFormerOnlyMLMHead(nn.Module):
def __init__(self, config):
pass
def forward(self, sequence_output: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 2 | 1 | 2 | 12 | 8 | 1 | 7 | 5 | 4 | 0 | 7 | 5 | 4 | 1 | 1 | 0 | 2 |
5,008 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerOutput | import torch
from torch import nn
class RoFormerOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.intermediate_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Drop... |
class RoFormerOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
5,009 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerPreTrainedModel | from .configuration_roformer import RoFormerConfig
from ...utils import auto_docstring, logging
from torch import nn
from ...modeling_utils import PreTrainedModel
@auto_docstring
class RoFormerPreTrainedModel(PreTrainedModel):
config: RoFormerConfig
base_model_prefix = 'roformer'
supports_gradient_checkpoi... | @auto_docstring
class RoFormerPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 17 | 0 | 14 | 3 | 7 | 0.37 | 1 | 1 | 1 | 7 | 1 | 0 | 1 | 1 | 28 | 2 | 19 | 6 | 17 | 7 | 16 | 6 | 14 | 7 | 1 | 2 | 7 |
5,010 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerPredictionHeadTransform | from ...activations import ACT2FN, get_activation
from torch import nn
class RoFormerPredictionHeadTransform(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.embedding_size)
if isinstance(config.hidden_act, str):
self.... |
class RoFormerPredictionHeadTransform(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 15 | 1 | 14 | 6 | 11 | 0 | 13 | 6 | 10 | 2 | 1 | 1 | 3 |
5,011 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerSelfAttention | import torch
import math
from ...cache_utils import Cache, DynamicCache, EncoderDecoderCache
from torch import nn
from ...utils.deprecation import deprecate_kwarg
class RoFormerSelfAttention(nn.Module):
def __init__(self, config, layer_idx=None):
super().__init__()
if config.hidden_size % config.n... |
class RoFormerSelfAttention(nn.Module):
def __init__(self, config, layer_idx=None):
pass
@deprecate_kwarg('past_key_value', new_name='past_key_values', version='4.58')
def forward(self, hidden_states, attention_mask=None, sinusoidal_pos=None, head_mask=None, encoder_hidden_states=None, past_key_va... | 6 | 0 | 33 | 4 | 23 | 6 | 4 | 0.27 | 1 | 3 | 0 | 0 | 3 | 9 | 4 | 14 | 136 | 17 | 94 | 42 | 78 | 25 | 69 | 31 | 64 | 11 | 1 | 3 | 16 |
5,012 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerSelfOutput | from torch import nn
import torch
class RoFormerSelfOutput(nn.Module):
def __init__(self, config):
super().__init__()
self.dense = nn.Linear(config.hidden_size, config.hidden_size)
self.LayerNorm = nn.LayerNorm(config.hidden_size, eps=config.layer_norm_eps)
self.dropout = nn.Dropou... |
class RoFormerSelfOutput(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
5,013 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/modeling_roformer.py | transformers.models.roformer.modeling_roformer.RoFormerSinusoidalPositionalEmbedding | import numpy as np
import torch
from torch import nn
from typing import Callable, Optional, Union
class RoFormerSinusoidalPositionalEmbedding(nn.Embedding):
"""This module produces sinusoidal positional embeddings of any length."""
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Option... |
class RoFormerSinusoidalPositionalEmbedding(nn.Embedding):
'''This module produces sinusoidal positional embeddings of any length.'''
def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None) -> None:
pass
def _init_weight(self):
'''
Identical to ... | 5 | 3 | 8 | 0 | 7 | 2 | 1 | 0.3 | 1 | 4 | 0 | 0 | 2 | 1 | 3 | 3 | 32 | 3 | 23 | 12 | 17 | 7 | 17 | 10 | 13 | 2 | 1 | 0 | 4 |
5,014 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/tokenization_roformer.py | transformers.models.roformer.tokenization_roformer.RoFormerTokenizer | import collections
from ...tokenization_utils import PreTrainedTokenizer, _is_control, _is_punctuation, _is_whitespace
import os
from typing import Optional
class RoFormerTokenizer(PreTrainedTokenizer):
"""
Construct a RoFormer tokenizer. Based on [Rust Jieba](https://pypi.org/project/rjieba/).
This token... |
class RoFormerTokenizer(PreTrainedTokenizer):
'''
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 t... | 16 | 6 | 14 | 1 | 10 | 3 | 2 | 0.65 | 1 | 10 | 2 | 0 | 14 | 7 | 14 | 103 | 265 | 34 | 141 | 61 | 102 | 91 | 84 | 38 | 67 | 7 | 3 | 4 | 32 |
5,015 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/tokenization_roformer_fast.py | transformers.models.roformer.tokenization_roformer_fast.RoFormerTokenizerFast | from .tokenization_utils import JiebaPreTokenizer
from tokenizers.pre_tokenizers import BertPreTokenizer, PreTokenizer
import json
from ...tokenization_utils_fast import PreTrainedTokenizerFast
from typing import Optional
from tokenizers import normalizers
from .tokenization_roformer import RoFormerTokenizer
class RoF... |
class RoFormerTokenizerFast(PreTrainedTokenizerFast):
'''
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 di... | 7 | 2 | 16 | 2 | 10 | 4 | 1 | 0.57 | 1 | 5 | 1 | 0 | 7 | 2 | 7 | 95 | 144 | 25 | 76 | 43 | 46 | 43 | 39 | 21 | 31 | 2 | 3 | 1 | 10 |
5,016 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/roformer/tokenization_utils.py | transformers.models.roformer.tokenization_utils.JiebaPreTokenizer | from tokenizers import NormalizedString, PreTokenizedString, normalizers
class JiebaPreTokenizer:
def __init__(self, vocab) -> None:
self.vocab = vocab
self.normalizers = normalizers.BertNormalizer(clean_text=False, handle_chinese_chars=True, strip_accents=False, lowercase=False)
try:
... |
class JiebaPreTokenizer:
def __init__(self, vocab) -> None:
pass
def jieba_split(self, i: int, normalized_string: NormalizedString) -> list[NormalizedString]:
pass
def pre_tokenize(self, pretok: PreTokenizedString):
pass | 4 | 0 | 15 | 1 | 10 | 3 | 3 | 0.31 | 0 | 3 | 0 | 0 | 3 | 3 | 3 | 3 | 47 | 5 | 32 | 11 | 27 | 10 | 23 | 11 | 18 | 5 | 0 | 4 | 8 |
5,017 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/configuration_rt_detr.py | transformers.models.rt_detr.configuration_rt_detr.RTDetrConfig | from ...configuration_utils import PretrainedConfig
from ..auto import CONFIG_MAPPING
from ...utils.backbone_utils import verify_backbone_config_arguments
from .configuration_rt_detr_resnet import RTDetrResNetConfig
class RTDetrConfig(PretrainedConfig):
"""
This is the configuration class to store the configur... |
class RTDetrConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`RTDetrModel`]. It is used to instantiate a
RT-DETR model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a simila... | 10 | 2 | 43 | 1 | 38 | 4 | 2 | 0.97 | 1 | 4 | 1 | 0 | 3 | 55 | 4 | 4 | 335 | 16 | 162 | 127 | 95 | 157 | 74 | 65 | 69 | 3 | 1 | 1 | 6 |
5,018 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/configuration_rt_detr_resnet.py | transformers.models.rt_detr.configuration_rt_detr_resnet.RTDetrResNetConfig | from ...configuration_utils import PretrainedConfig
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices
class RTDetrResNetConfig(BackboneConfigMixin, PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`RTDetrResnetBackbone`]. ... |
class RTDetrResNetConfig(BackboneConfigMixin, PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`RTDetrResnetBackbone`]. It is used to instantiate an
ResNet model according to the specified arguments, defining the model architecture. Instantiating a configuration
w... | 2 | 1 | 29 | 0 | 29 | 0 | 2 | 1.47 | 2 | 3 | 0 | 0 | 1 | 11 | 1 | 6 | 87 | 8 | 32 | 27 | 17 | 47 | 17 | 14 | 15 | 2 | 1 | 1 | 2 |
5,019 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/image_processing_rt_detr.py | transformers.models.rt_detr.image_processing_rt_detr.RTDetrImageProcessor | from ...utils.generic import TensorType
from ...image_processing_utils import BaseImageProcessor, get_size_dict
import pathlib
from ...feature_extraction_utils import BatchFeature
from typing import Any, Optional, Union
from collections.abc import Iterable
from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFA... |
class RTDetrImageProcessor(BaseImageProcessor):
'''
Constructs a RT-DETR image processor.
Args:
format (`str`, *optional*, defaults to `AnnotationFormat.COCO_DETECTION`):
Data format of the annotations. One of "coco_detection" or "coco_panoptic".
do_resize (`bool`, *optional*, d... | 13 | 11 | 58 | 4 | 38 | 17 | 6 | 0.59 | 1 | 15 | 5 | 0 | 11 | 12 | 11 | 31 | 717 | 52 | 418 | 163 | 308 | 248 | 190 | 65 | 178 | 30 | 3 | 3 | 68 |
5,020 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/image_processing_rt_detr_fast.py | transformers.models.rt_detr.image_processing_rt_detr_fast.RTDetrImageProcessorFast | from .image_processing_rt_detr import get_size_with_aspect_ratio
from ...utils import TensorType, auto_docstring, is_torchvision_v2_available, requires_backends
import torch
from ...utils.import_utils import requires
from typing import Any, Optional, Union
import pathlib
from ...image_transforms import center_to_corner... | @auto_docstring
@requires(backends=('torchvision', 'torch'))
class RTDetrImageProcessorFast(BaseImageProcessorFast):
def __init__(self, **kwargs: Unpack[RTDetrFastImageProcessorKwargs]) -> None:
pass
def prepare_annotation(self, image: torch.Tensor, target: dict, format: Optional[AnnotationFormat]=Non... | 14 | 7 | 40 | 3 | 30 | 7 | 6 | 0.2 | 1 | 17 | 6 | 0 | 10 | 0 | 10 | 44 | 460 | 38 | 353 | 170 | 243 | 70 | 185 | 71 | 174 | 21 | 4 | 3 | 60 |
5,021 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrCSPRepLayer | from .configuration_rt_detr import RTDetrConfig
from torch import Tensor, nn
class RTDetrCSPRepLayer(nn.Module):
"""
Cross Stage Partial (CSP) network layer with RepVGG blocks.
"""
def __init__(self, config: RTDetrConfig):
super().__init__()
in_channels = config.encoder_hidden_dim * 2
... |
class RTDetrCSPRepLayer(nn.Module):
'''
Cross Stage Partial (CSP) network layer with RepVGG blocks.
'''
def __init__(self, config: RTDetrConfig):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 11 | 1 | 10 | 0 | 2 | 0.14 | 1 | 6 | 3 | 0 | 2 | 4 | 2 | 12 | 28 | 4 | 21 | 15 | 18 | 3 | 20 | 15 | 17 | 2 | 1 | 1 | 3 |
5,022 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrConvEncoder | import torch
from ...utils.backbone_utils import load_backbone
import torch.nn.functional as F
from torch import Tensor, nn
class RTDetrConvEncoder(nn.Module):
"""
Convolutional backbone using the modeling_rt_detr_resnet.py.
nn.BatchNorm2d layers are replaced by RTDetrFrozenBatchNorm2d as defined above.
... |
class RTDetrConvEncoder(nn.Module):
'''
Convolutional backbone using the modeling_rt_detr_resnet.py.
nn.BatchNorm2d layers are replaced by RTDetrFrozenBatchNorm2d as defined above.
https://github.com/lyuwenyu/RT-DETR/blob/main/rtdetr_pytorch/src/nn/backbone/presnet.py#L142
'''
def __init__(sel... | 3 | 1 | 11 | 2 | 8 | 2 | 2 | 0.5 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 30 | 6 | 16 | 10 | 13 | 8 | 16 | 10 | 13 | 2 | 1 | 2 | 4 |
5,023 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrConvNormLayer | from ...activations import ACT2CLS, ACT2FN
from torch import Tensor, nn
class RTDetrConvNormLayer(nn.Module):
def __init__(self, config, in_channels, out_channels, kernel_size, stride, padding=None, activation=None):
super().__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size, ... |
class RTDetrConvNormLayer(nn.Module):
def __init__(self, config, in_channels, out_channels, kernel_size, stride, padding=None, activation=None):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 9 | 0 | 9 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 19 | 1 | 18 | 6 | 15 | 0 | 11 | 6 | 8 | 3 | 1 | 0 | 4 |
5,024 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrDecoder | from torch import Tensor, nn
import torch
import torch.nn.functional as F
from .configuration_rt_detr import RTDetrConfig
class RTDetrDecoder(RTDetrPreTrainedModel):
def __init__(self, config: RTDetrConfig):
super().__init__(config)
self.dropout = config.dropout
self.layers = nn.ModuleList... |
class RTDetrDecoder(RTDetrPreTrainedModel):
def __init__(self, config: RTDetrConfig):
pass
def forward(self, inputs_embeds=None, encoder_hidden_states=None, encoder_attention_mask=None, position_embeddings=None, reference_points=None, spatial_shapes=None, spatial_shapes_list=None, level_start_index=N... | 3 | 1 | 78 | 10 | 49 | 19 | 10 | 0.38 | 1 | 8 | 4 | 1 | 2 | 5 | 2 | 3 | 157 | 20 | 99 | 35 | 82 | 38 | 51 | 21 | 48 | 18 | 2 | 3 | 19 |
5,025 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrDecoderLayer | from .configuration_rt_detr import RTDetrConfig
import torch.nn.functional as F
from ...activations import ACT2CLS, ACT2FN
from typing import Optional, Union
import torch
from torch import Tensor, nn
class RTDetrDecoderLayer(nn.Module):
def __init__(self, config: RTDetrConfig):
super().__init__()
... |
class RTDetrDecoderLayer(nn.Module):
def __init__(self, config: RTDetrConfig):
pass
def forward(self, hidden_states: torch.Tensor, position_embeddings: Optional[torch.Tensor]=None, reference_points=None, spatial_shapes=None, spatial_shapes_list=None, level_start_index=None, encoder_hidden_states: Opt... | 3 | 1 | 53 | 6 | 34 | 14 | 2 | 0.39 | 1 | 6 | 3 | 1 | 2 | 10 | 2 | 12 | 108 | 12 | 69 | 29 | 55 | 27 | 36 | 18 | 33 | 2 | 1 | 1 | 3 |
5,026 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrDecoderOutput | from typing import Optional, Union
from dataclasses import dataclass
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, logging, torch_int
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of the RTDetrDecoder. This class adds two attributes to\n BaseM... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of the RTDetrDecoder. This class adds two attributes to\n BaseModelOutputWithCrossAttentions, namely:\n - a stacked tensor of intermediate decoder hidden states (i.e. the output of each decoder layer)\n - a stacked tensor of intermediate ref... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.38 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 37 | 2 | 8 | 8 | 7 | 27 | 8 | 8 | 7 | 0 | 1 | 0 | 0 |
5,027 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrEncoder | from torch import Tensor, nn
import torch
import torch.nn.functional as F
from .configuration_rt_detr import RTDetrConfig
class RTDetrEncoder(nn.Module):
def __init__(self, config: RTDetrConfig):
super().__init__()
self.layers = nn.ModuleList([RTDetrEncoderLayer(config) for _ in range(config.encod... |
class RTDetrEncoder(nn.Module):
def __init__(self, config: RTDetrConfig):
pass
def forward(self, src, src_mask=None, pos_embed=None, output_attentions: bool=False) -> torch.Tensor:
pass | 3 | 0 | 7 | 1 | 7 | 0 | 2 | 0 | 1 | 6 | 2 | 0 | 2 | 1 | 2 | 12 | 16 | 2 | 14 | 6 | 11 | 0 | 9 | 6 | 6 | 2 | 1 | 1 | 3 |
5,028 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrEncoderLayer | from .configuration_rt_detr import RTDetrConfig
import torch.nn.functional as F
from ...activations import ACT2CLS, ACT2FN
from typing import Optional, Union
import torch
from torch import Tensor, nn
class RTDetrEncoderLayer(nn.Module):
def __init__(self, config: RTDetrConfig):
super().__init__()
... |
class RTDetrEncoderLayer(nn.Module):
def __init__(self, config: RTDetrConfig):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_embeddings: Optional[torch.Tensor]=None, output_attentions: bool=False, **kwargs):
'''
Args:
hidden_sta... | 3 | 1 | 40 | 6 | 27 | 7 | 5 | 0.24 | 1 | 5 | 2 | 0 | 2 | 9 | 2 | 12 | 81 | 13 | 55 | 23 | 45 | 13 | 39 | 16 | 36 | 8 | 1 | 2 | 9 |
5,029 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrForObjectDetection | from typing import Optional, Union
from .configuration_rt_detr import RTDetrConfig
from functools import partial
from torch import Tensor, nn
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, logging, torch_int
@auto_docstring(custom_intro='\n RT-DETR Model (consisting o... | null | 7 | 1 | 58 | 8 | 33 | 17 | 6 | 0.51 | 1 | 10 | 4 | 1 | 3 | 5 | 3 | 4 | 186 | 27 | 105 | 35 | 86 | 54 | 40 | 18 | 36 | 14 | 2 | 2 | 17 |
5,030 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrFrozenBatchNorm2d | import torch
import torch.nn.functional as F
from torch import Tensor, nn
class RTDetrFrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
torc... |
class RTDetrFrozenBatchNorm2d(nn.Module):
'''
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
torchvision.models.resnet[18,34,50,101] produce nans.
'''
def __init__... | 4 | 1 | 9 | 0 | 8 | 1 | 1 | 0.28 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 13 | 37 | 5 | 25 | 13 | 19 | 7 | 21 | 11 | 17 | 2 | 1 | 1 | 4 |
5,031 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrHybridEncoder | from .configuration_rt_detr import RTDetrConfig
from ...modeling_outputs import BaseModelOutput
from torch import Tensor, nn
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, logging, torch_int
class RTDetrHybridEncoder(nn.Module):
"""
Decoder consisting of a projec... |
class RTDetrHybridEncoder(nn.Module):
'''
Decoder consisting of a projection layer, a set of `RTDetrEncoder`, a top-down Feature Pyramid Network
(FPN) and a bottom-up Path Aggregation Network (PAN). More details on the paper: https://huggingface.co/papers/2304.08069
Args:
config: RTDetrConfig
... | 5 | 2 | 53 | 4 | 38 | 11 | 7 | 0.32 | 1 | 11 | 5 | 0 | 2 | 14 | 3 | 13 | 171 | 16 | 117 | 55 | 99 | 38 | 77 | 41 | 73 | 15 | 1 | 3 | 20 |
5,032 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrMLPPredictionHead | from torch import Tensor, nn
class RTDetrMLPPredictionHead(nn.Module):
"""
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/master/... |
class RTDetrMLPPredictionHead(nn.Module):
'''
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/master/models/detr.py
Origin from... | 3 | 1 | 5 | 0 | 5 | 0 | 2 | 0.6 | 1 | 3 | 0 | 1 | 2 | 2 | 2 | 12 | 20 | 4 | 10 | 7 | 7 | 6 | 10 | 7 | 7 | 3 | 1 | 1 | 4 |
5,033 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrModel | from ...pytorch_utils import compile_compatible_method_lru_cache
from typing import Optional, Union
from .configuration_rt_detr import RTDetrConfig
from ...modeling_outputs import BaseModelOutput
from torch import Tensor, nn
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, ... | null | 10 | 1 | 45 | 6 | 33 | 6 | 5 | 0.17 | 1 | 14 | 7 | 1 | 7 | 12 | 7 | 8 | 326 | 50 | 235 | 81 | 213 | 41 | 126 | 65 | 118 | 21 | 2 | 2 | 37 |
5,034 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrMultiheadAttention | import torch
from typing import Optional, Union
import torch.nn.functional as F
from torch import Tensor, nn
class RTDetrMultiheadAttention(nn.Module):
"""
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the Deformabl... |
class RTDetrMultiheadAttention(nn.Module):
'''
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the Deformable DETR paper).
'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, bias: bool=... | 5 | 2 | 26 | 4 | 20 | 2 | 3 | 0.16 | 1 | 6 | 0 | 0 | 4 | 9 | 4 | 14 | 115 | 22 | 80 | 37 | 63 | 13 | 55 | 25 | 50 | 8 | 1 | 2 | 13 |
5,035 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrMultiscaleDeformableAttention | from torch import Tensor, nn
import torch.nn.functional as F
import warnings
import torch
from typing import Optional, Union
from .configuration_rt_detr import RTDetrConfig
class RTDetrMultiscaleDeformableAttention(nn.Module):
"""
Multiscale deformable attention as proposed in Deformable DETR.
"""
def... |
class RTDetrMultiscaleDeformableAttention(nn.Module):
'''
Multiscale deformable attention as proposed in Deformable DETR.
'''
def __init__(self, config: RTDetrConfig, num_heads: int, n_points: int):
pass
def with_pos_embed(self, tensor: torch.Tensor, position_embeddings: Optional[Tens... | 4 | 1 | 39 | 3 | 33 | 2 | 5 | 0.1 | 1 | 9 | 2 | 1 | 3 | 10 | 3 | 13 | 124 | 13 | 101 | 39 | 85 | 10 | 55 | 26 | 51 | 8 | 1 | 2 | 15 |
5,036 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrObjectDetectionOutput | from typing import Optional, Union
from dataclasses import dataclass
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, logging, torch_int
@dataclass
@auto_docstring(custom_intro='\n Output type of [`RTDetrForObjectDetection`].\n ')
class RTDetrObjectDetectionOutput(Mo... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`RTDetrForObjectDetection`].\n ')
class RTDetrObjectDetectionOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` are provided)):
Total loss as a linear combination of a negative log-likeh... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2.95 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 89 | 2 | 22 | 22 | 21 | 65 | 22 | 22 | 21 | 0 | 1 | 0 | 0 |
5,037 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrPreTrainedModel | from .configuration_rt_detr import RTDetrConfig
from ...modeling_utils import PreTrainedModel
from torch import Tensor, nn
import torch.nn.functional as F
from ...utils import ModelOutput, auto_docstring, logging, torch_int
import torch
import math
@auto_docstring
class RTDetrPreTrainedModel(PreTrainedModel):
conf... | @auto_docstring
class RTDetrPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 55 | 6 | 47 | 2 | 13 | 0.04 | 1 | 6 | 4 | 4 | 1 | 0 | 1 | 1 | 61 | 7 | 52 | 13 | 50 | 2 | 46 | 13 | 44 | 13 | 1 | 3 | 13 |
5,038 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr.py | transformers.models.rt_detr.modeling_rt_detr.RTDetrRepVggBlock | from torch import Tensor, nn
from .configuration_rt_detr import RTDetrConfig
from ...activations import ACT2CLS, ACT2FN
class RTDetrRepVggBlock(nn.Module):
"""
RepVGG architecture block introduced by the work "RepVGG: Making VGG-style ConvNets Great Again".
"""
def __init__(self, config: RTDetrConfig)... |
class RTDetrRepVggBlock(nn.Module):
'''
RepVGG architecture block introduced by the work "RepVGG: Making VGG-style ConvNets Great Again".
'''
def __init__(self, config: RTDetrConfig):
pass
def forward(self, x):
pass | 3 | 1 | 6 | 1 | 5 | 0 | 2 | 0.27 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 12 | 17 | 3 | 11 | 9 | 8 | 3 | 11 | 9 | 8 | 2 | 1 | 0 | 3 |
5,039 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetBackbone | from torch import Tensor, nn
from ...modeling_outputs import BackboneOutput, BaseModelOutputWithNoAttention
from ...utils import auto_docstring, logging
from ...utils.backbone_utils import BackboneMixin
from typing import Optional
@auto_docstring(custom_intro='\n ResNet backbone, to be used with frameworks like RTD... | @auto_docstring(custom_intro='\n ResNet backbone, to be used with frameworks like RTDETR.\n ')
class RTDetrResNetBackbone(RTDetrResNetPreTrainedModel, BackboneMixin):
def __init__(self, config):
pass
@auto_docstring
def forward(self, pixel_values: Tensor, output_hidden_states: Optional[bool]=... | 5 | 1 | 31 | 7 | 16 | 8 | 5 | 0.47 | 2 | 7 | 3 | 0 | 2 | 3 | 2 | 15 | 65 | 15 | 34 | 15 | 27 | 16 | 24 | 12 | 21 | 8 | 2 | 2 | 9 |
5,040 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetBasicLayer | from .configuration_rt_detr_resnet import RTDetrResNetConfig
from ...activations import ACT2FN
from torch import Tensor, nn
class RTDetrResNetBasicLayer(nn.Module):
"""
A classic ResNet's residual layer composed by two `3x3` convolutions.
See https://github.com/lyuwenyu/RT-DETR/blob/5b628eaa0a2fc25bdafec7e... |
class RTDetrResNetBasicLayer(nn.Module):
'''
A classic ResNet's residual layer composed by two `3x3` convolutions.
See https://github.com/lyuwenyu/RT-DETR/blob/5b628eaa0a2fc25bdafec7e6148d5296b144af85/rtdetr_pytorch/src/nn/backbone/presnet.py#L34.
'''
def __init__(self, config: RTDetrResNetConfig,... | 3 | 1 | 18 | 0 | 18 | 0 | 3 | 0.11 | 1 | 6 | 3 | 0 | 2 | 3 | 2 | 12 | 42 | 2 | 36 | 14 | 26 | 4 | 15 | 7 | 12 | 4 | 1 | 1 | 5 |
5,041 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetBottleNeckLayer | from .configuration_rt_detr_resnet import RTDetrResNetConfig
from torch import Tensor, nn
from ...activations import ACT2FN
class RTDetrResNetBottleNeckLayer(nn.Module):
"""
A classic RTDetrResNet's bottleneck layer composed by three `3x3` convolutions.
The first `1x1` convolution reduces the input by a f... |
class RTDetrResNetBottleNeckLayer(nn.Module):
'''
A classic RTDetrResNet's bottleneck layer composed by three `3x3` convolutions.
The first `1x1` convolution reduces the input by a factor of `reduction` in order to make the second `3x3`
convolution faster. The last `1x1` convolution remaps the reduced ... | 3 | 1 | 22 | 0 | 22 | 0 | 4 | 0.14 | 1 | 5 | 3 | 0 | 2 | 3 | 2 | 12 | 53 | 3 | 44 | 16 | 35 | 6 | 18 | 10 | 15 | 6 | 1 | 1 | 7 |
5,042 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetConvLayer | from torch import Tensor, nn
from ...activations import ACT2FN
class RTDetrResNetConvLayer(nn.Module):
def __init__(self, in_channels: int, out_channels: int, kernel_size: int=3, stride: int=1, activation: str='relu'):
super().__init__()
self.convolution = nn.Conv2d(in_channels, out_channels, kern... |
class RTDetrResNetConvLayer(nn.Module):
def __init__(self, in_channels: int, out_channels: int, kernel_size: int=3, stride: int=1, activation: str='relu'):
pass
def forward(self, input: Tensor) -> Tensor:
pass | 3 | 0 | 7 | 0 | 7 | 0 | 2 | 0 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 12 | 16 | 1 | 15 | 9 | 10 | 0 | 11 | 7 | 8 | 2 | 1 | 0 | 3 |
5,043 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetEmbeddings | from .configuration_rt_detr_resnet import RTDetrResNetConfig
from torch import Tensor, nn
class RTDetrResNetEmbeddings(nn.Module):
"""
ResNet Embeddings (stem) composed of a deep aggressive convolution.
"""
def __init__(self, config: RTDetrResNetConfig):
super().__init__()
self.embedde... |
class RTDetrResNetEmbeddings(nn.Module):
'''
ResNet Embeddings (stem) composed of a deep aggressive convolution.
'''
def __init__(self, config: RTDetrResNetConfig):
pass
def forward(self, pixel_values: Tensor) -> Tensor:
pass | 3 | 1 | 19 | 0 | 19 | 0 | 2 | 0.08 | 1 | 5 | 2 | 0 | 2 | 3 | 2 | 12 | 44 | 2 | 39 | 8 | 36 | 3 | 13 | 8 | 10 | 2 | 1 | 1 | 3 |
5,044 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetEncoder | from .configuration_rt_detr_resnet import RTDetrResNetConfig
from ...modeling_outputs import BackboneOutput, BaseModelOutputWithNoAttention
from torch import Tensor, nn
class RTDetrResNetEncoder(nn.Module):
def __init__(self, config: RTDetrResNetConfig):
super().__init__()
self.stages = nn.ModuleL... |
class RTDetrResNetEncoder(nn.Module):
def __init__(self, config: RTDetrResNetConfig):
pass
def forward(self, hidden_state: Tensor, output_hidden_states: bool=False, return_dict: bool=True) -> BaseModelOutputWithNoAttention:
pass | 3 | 0 | 19 | 3 | 16 | 1 | 5 | 0.03 | 1 | 8 | 3 | 0 | 2 | 1 | 2 | 12 | 39 | 6 | 32 | 10 | 27 | 1 | 19 | 8 | 16 | 6 | 1 | 2 | 9 |
5,045 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetPreTrainedModel | from torch import Tensor, nn
import math
from ...modeling_utils import PreTrainedModel
from ...utils import auto_docstring, logging
from .configuration_rt_detr_resnet import RTDetrResNetConfig
@auto_docstring
class RTDetrResNetPreTrainedModel(PreTrainedModel):
config: RTDetrResNetConfig
base_model_prefix = 're... | @auto_docstring
class RTDetrResNetPreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
pass | 3 | 0 | 13 | 0 | 12 | 1 | 6 | 0.29 | 1 | 0 | 0 | 1 | 1 | 0 | 1 | 1 | 24 | 2 | 17 | 8 | 15 | 5 | 15 | 8 | 13 | 6 | 1 | 2 | 6 |
5,046 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetShortCut | from torch import Tensor, nn
class RTDetrResNetShortCut(nn.Module):
"""
ResNet shortcut, used to project the residual features to the correct size. If needed, it is also used to
downsample the input using `stride=2`.
"""
def __init__(self, in_channels: int, out_channels: int, stride: int=2):
... |
class RTDetrResNetShortCut(nn.Module):
'''
ResNet shortcut, used to project the residual features to the correct size. If needed, it is also used to
downsample the input using `stride=2`.
'''
def __init__(self, in_channels: int, out_channels: int, stride: int=2):
pass
def forward(self... | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.44 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 15 | 2 | 9 | 6 | 6 | 4 | 9 | 6 | 6 | 1 | 1 | 0 | 2 |
5,047 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modeling_rt_detr_resnet.py | transformers.models.rt_detr.modeling_rt_detr_resnet.RTDetrResNetStage | from torch import Tensor, nn
from .configuration_rt_detr_resnet import RTDetrResNetConfig
class RTDetrResNetStage(nn.Module):
"""
A RTDetrResNet stage composed by stacked layers.
"""
def __init__(self, config: RTDetrResNetConfig, in_channels: int, out_channels: int, stride: int=2, depth: int=2):
... |
class RTDetrResNetStage(nn.Module):
'''
A RTDetrResNet stage composed by stacked layers.
'''
def __init__(self, config: RTDetrResNetConfig, in_channels: int, out_channels: int, stride: int=2, depth: int=2):
pass
def forward(self, input: Tensor) -> Tensor:
pass | 3 | 1 | 15 | 1 | 14 | 0 | 3 | 0.11 | 1 | 7 | 3 | 0 | 2 | 1 | 2 | 12 | 35 | 4 | 28 | 16 | 18 | 3 | 13 | 8 | 10 | 3 | 1 | 1 | 5 |
5,048 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr/modular_rt_detr.py | transformers.models.rt_detr.modular_rt_detr.RTDetrImageProcessorFast | from typing import Optional, Union
from transformers.models.detr.image_processing_detr_fast import DetrFastImageProcessorKwargs, DetrImageProcessorFast
from ...image_transforms import center_to_corners_format
from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, AnnotationFormat, AnnotationType, Chann... |
class RTDetrImageProcessorFast(DetrImageProcessorFast):
def __init__(self, **kwargs: Unpack[RTDetrFastImageProcessorKwargs]) -> None:
pass
def preprocess(self, images: ImageInput, annotations: Optional[Union[AnnotationType, list[AnnotationType]]]=None, masks_path: Optional[Union[str, pathlib.Path]]=N... | 14 | 2 | 18 | 1 | 14 | 2 | 3 | 0.12 | 2 | 17 | 7 | 0 | 13 | 0 | 13 | 89 | 294 | 32 | 235 | 123 | 149 | 28 | 130 | 51 | 116 | 21 | 5 | 3 | 44 |
5,049 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/configuration_rt_detr_v2.py | transformers.models.rt_detr_v2.configuration_rt_detr_v2.RTDetrV2Config | from ...utils.backbone_utils import verify_backbone_config_arguments
from ..auto import CONFIG_MAPPING
from ...configuration_utils import PretrainedConfig
class RTDetrV2Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`RTDetrV2Model`]. It is used to instantiate a
... |
class RTDetrV2Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`RTDetrV2Model`]. It is used to instantiate a
RT-DETR model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a si... | 6 | 2 | 92 | 3 | 79 | 11 | 3 | 1.02 | 1 | 2 | 0 | 0 | 1 | 58 | 2 | 2 | 350 | 17 | 166 | 129 | 100 | 169 | 77 | 66 | 74 | 5 | 1 | 1 | 6 |
5,050 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2CSPRepLayer | from torch import Tensor, nn
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2CSPRepLayer(nn.Module):
"""
Cross Stage Partial (CSP) network layer with RepVGG blocks.
"""
def __init__(self, config: RTDetrV2Config):
super().__init__()
in_channels = config.encoder_hidden... |
class RTDetrV2CSPRepLayer(nn.Module):
'''
Cross Stage Partial (CSP) network layer with RepVGG blocks.
'''
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, hidden_state):
pass | 3 | 1 | 11 | 1 | 10 | 0 | 2 | 0.14 | 1 | 6 | 3 | 0 | 2 | 4 | 2 | 12 | 28 | 4 | 21 | 15 | 18 | 3 | 20 | 15 | 17 | 2 | 1 | 1 | 3 |
5,051 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2ConvEncoder | from ...utils.backbone_utils import load_backbone
from torch import Tensor, nn
import torch
import torch.nn.functional as F
class RTDetrV2ConvEncoder(nn.Module):
"""
Convolutional backbone using the modeling_rt_detr_v2_resnet.py.
nn.BatchNorm2d layers are replaced by RTDetrV2FrozenBatchNorm2d as defined a... |
class RTDetrV2ConvEncoder(nn.Module):
'''
Convolutional backbone using the modeling_rt_detr_v2_resnet.py.
nn.BatchNorm2d layers are replaced by RTDetrV2FrozenBatchNorm2d as defined above.
https://github.com/lyuwenyu/RT-DETR/blob/main/RTDetrV2_pytorch/src/nn/backbone/presnet.py#L142
'''
def __i... | 3 | 1 | 11 | 2 | 8 | 2 | 2 | 0.5 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 30 | 6 | 16 | 10 | 13 | 8 | 16 | 10 | 13 | 2 | 1 | 2 | 4 |
5,052 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2ConvNormLayer | from ...activations import ACT2CLS, ACT2FN
from torch import Tensor, nn
class RTDetrV2ConvNormLayer(nn.Module):
def __init__(self, config, in_channels, out_channels, kernel_size, stride, padding=None, activation=None):
super().__init__()
self.conv = nn.Conv2d(in_channels, out_channels, kernel_size... |
class RTDetrV2ConvNormLayer(nn.Module):
def __init__(self, config, in_channels, out_channels, kernel_size, stride, padding=None, activation=None):
pass
def forward(self, hidden_state):
pass | 3 | 0 | 9 | 0 | 9 | 0 | 2 | 0 | 1 | 1 | 0 | 0 | 2 | 3 | 2 | 12 | 19 | 1 | 18 | 6 | 15 | 0 | 11 | 6 | 8 | 3 | 1 | 0 | 4 |
5,053 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2Decoder | import torch
import torch.nn.functional as F
from torch import Tensor, nn
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2Decoder(RTDetrV2PreTrainedModel):
def __init__(self, config: RTDetrV2Config):
super().__init__(config)
self.dropout = config.dropout
self.layers = nn... |
class RTDetrV2Decoder(RTDetrV2PreTrainedModel):
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, inputs_embeds=None, encoder_hidden_states=None, encoder_attention_mask=None, position_embeddings=None, reference_points=None, spatial_shapes=None, spatial_shapes_list=None, level_start_i... | 3 | 1 | 78 | 10 | 49 | 19 | 10 | 0.38 | 1 | 8 | 4 | 0 | 2 | 5 | 2 | 3 | 157 | 20 | 99 | 35 | 82 | 38 | 51 | 21 | 48 | 18 | 2 | 3 | 19 |
5,054 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2DecoderLayer | from torch import Tensor, nn
import torch.nn.functional as F
import torch
from typing import Optional, Union
from ...activations import ACT2CLS, ACT2FN
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2DecoderLayer(nn.Module):
def __init__(self, config: RTDetrV2Config):
super().__init__()... |
class RTDetrV2DecoderLayer(nn.Module):
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, hidden_states: torch.Tensor, position_embeddings: Optional[torch.Tensor]=None, reference_points=None, spatial_shapes=None, spatial_shapes_list=None, level_start_index=None, encoder_hidden_states:... | 3 | 1 | 51 | 6 | 32 | 14 | 2 | 0.42 | 1 | 6 | 3 | 0 | 2 | 10 | 2 | 12 | 104 | 12 | 65 | 29 | 51 | 27 | 36 | 18 | 33 | 2 | 1 | 1 | 3 |
5,055 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2DecoderOutput | from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from typing import Optional, Union
from dataclasses import dataclass
import torch.nn.functional as F
import torch
@dataclass
@auto_docstring(custom_intro='\n Base class for outputs of the RTDetrV2Decoder. This class adds two attri... | @dataclass
@auto_docstring(custom_intro='\n Base class for outputs of the RTDetrV2Decoder. This class adds two attributes to\n BaseModelOutputWithCrossAttentions, namely:\n - a stacked tensor of intermediate decoder hidden states (i.e. the output of each decoder layer)\n - a stacked tensor of intermediate r... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.38 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 37 | 2 | 8 | 8 | 7 | 27 | 8 | 8 | 7 | 0 | 1 | 0 | 0 |
5,056 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2Encoder | from .configuration_rt_detr_v2 import RTDetrV2Config
from torch import Tensor, nn
import torch
import torch.nn.functional as F
class RTDetrV2Encoder(nn.Module):
def __init__(self, config: RTDetrV2Config):
super().__init__()
self.layers = nn.ModuleList([RTDetrV2EncoderLayer(config) for _ in range(c... |
class RTDetrV2Encoder(nn.Module):
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, src, src_mask=None, pos_embed=None, output_attentions: bool=False) -> torch.Tensor:
pass | 3 | 0 | 7 | 1 | 7 | 0 | 2 | 0 | 1 | 6 | 2 | 0 | 2 | 1 | 2 | 12 | 16 | 2 | 14 | 6 | 11 | 0 | 9 | 6 | 6 | 2 | 1 | 1 | 3 |
5,057 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2EncoderLayer | from torch import Tensor, nn
import torch.nn.functional as F
import torch
from typing import Optional, Union
from ...activations import ACT2CLS, ACT2FN
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2EncoderLayer(nn.Module):
def __init__(self, config: RTDetrV2Config):
super().__init__()... |
class RTDetrV2EncoderLayer(nn.Module):
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_embeddings: Optional[torch.Tensor]=None, output_attentions: bool=False, **kwargs):
'''
Args:
hidden... | 3 | 1 | 40 | 6 | 27 | 7 | 5 | 0.24 | 1 | 5 | 2 | 0 | 2 | 9 | 2 | 12 | 81 | 13 | 55 | 23 | 45 | 13 | 39 | 16 | 36 | 8 | 1 | 2 | 9 |
5,058 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2ForObjectDetection | from torch import Tensor, nn
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from typing import Optional, Union
from functools import partial
from .configuration_rt_detr_v2 import RTDetrV2Config
@auto_docstring(custom_intro='\n RT-DE... | null | 7 | 1 | 56 | 8 | 31 | 17 | 5 | 0.52 | 1 | 10 | 4 | 0 | 3 | 5 | 3 | 4 | 178 | 26 | 100 | 35 | 81 | 52 | 36 | 19 | 32 | 14 | 2 | 2 | 16 |
5,059 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2FrozenBatchNorm2d | from torch import Tensor, nn
import torch
import torch.nn.functional as F
class RTDetrV2FrozenBatchNorm2d(nn.Module):
"""
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
to... |
class RTDetrV2FrozenBatchNorm2d(nn.Module):
'''
BatchNorm2d where the batch statistics and the affine parameters are fixed.
Copy-paste from torchvision.misc.ops with added eps before rqsrt, without which any other models than
torchvision.models.resnet[18,34,50,101] produce nans.
'''
def __init... | 4 | 1 | 9 | 0 | 8 | 1 | 1 | 0.28 | 1 | 1 | 0 | 0 | 3 | 0 | 3 | 13 | 37 | 5 | 25 | 13 | 19 | 7 | 21 | 11 | 17 | 2 | 1 | 1 | 4 |
5,060 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2HybridEncoder | from torch import Tensor, nn
from ...modeling_outputs import BaseModelOutput
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2HybridEncoder(nn.Module):
"""
Decode... |
class RTDetrV2HybridEncoder(nn.Module):
'''
Decoder consisting of a projection layer, a set of `RTDetrV2Encoder`, a top-down Feature Pyramid Network
(FPN) and a bottom-up Path Aggregation Network (PAN). More details on the paper: https://huggingface.co/papers/2304.08069
Args:
config: RTDetrV2Co... | 5 | 2 | 53 | 4 | 38 | 11 | 7 | 0.32 | 1 | 11 | 5 | 0 | 2 | 14 | 3 | 13 | 171 | 16 | 117 | 55 | 99 | 38 | 77 | 41 | 73 | 15 | 1 | 3 | 20 |
5,061 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2MLPPredictionHead | from torch import Tensor, nn
class RTDetrV2MLPPredictionHead(nn.Module):
"""
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/maste... |
class RTDetrV2MLPPredictionHead(nn.Module):
'''
Very simple multi-layer perceptron (MLP, also called FFN), used to predict the normalized center coordinates,
height and width of a bounding box w.r.t. an image.
Copied from https://github.com/facebookresearch/detr/blob/master/models/detr.py
Origin fr... | 3 | 1 | 5 | 0 | 5 | 0 | 2 | 0.6 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 12 | 20 | 4 | 10 | 7 | 7 | 6 | 10 | 7 | 7 | 3 | 1 | 1 | 4 |
5,062 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2Model | from torch import Tensor, nn
from ...modeling_outputs import BaseModelOutput
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from typing import Optional, Union
from ...pytorch_utils import compile_compatible_method_lru_cache
from .config... | null | 10 | 1 | 45 | 6 | 33 | 6 | 5 | 0.17 | 1 | 14 | 7 | 0 | 7 | 12 | 7 | 8 | 325 | 49 | 235 | 81 | 213 | 41 | 126 | 65 | 118 | 21 | 2 | 2 | 37 |
5,063 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2MultiheadAttention | from torch import Tensor, nn
import torch
from typing import Optional, Union
import torch.nn.functional as F
class RTDetrV2MultiheadAttention(nn.Module):
"""
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the Deforma... |
class RTDetrV2MultiheadAttention(nn.Module):
'''
Multi-headed attention from 'Attention Is All You Need' paper.
Here, we add position embeddings to the queries and keys (as explained in the Deformable DETR paper).
'''
def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, bias: boo... | 5 | 2 | 26 | 4 | 20 | 2 | 3 | 0.16 | 1 | 6 | 0 | 0 | 4 | 9 | 4 | 14 | 115 | 22 | 80 | 37 | 63 | 13 | 55 | 25 | 50 | 8 | 1 | 2 | 13 |
5,064 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2MultiscaleDeformableAttention | from torch import Tensor, nn
import torch.nn.functional as F
import warnings
import torch
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from typing import Optional, Union
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2MultiscaleDeformableAttention(nn.Module):... |
class RTDetrV2MultiscaleDeformableAttention(nn.Module):
'''
RTDetrV2 version of multiscale deformable attention, extending the base implementation
with improved offset handling and initialization.
'''
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, hidden_states: to... | 3 | 1 | 36 | 5 | 29 | 2 | 4 | 0.13 | 1 | 8 | 1 | 0 | 3 | 13 | 3 | 13 | 119 | 18 | 89 | 46 | 73 | 12 | 58 | 33 | 54 | 6 | 1 | 2 | 13 |
5,065 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2ObjectDetectionOutput | from dataclasses import dataclass
import torch.nn.functional as F
import torch
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Output type of [`RTDetrV2ForObjectDetection`].\n ')
class RTDetrV2Obj... | @dataclass
@auto_docstring(custom_intro='\n Output type of [`RTDetrV2ForObjectDetection`].\n ')
class RTDetrV2ObjectDetectionOutput(ModelOutput):
'''
loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` are provided)):
Total loss as a linear combination of a negative log-l... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 2.95 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 89 | 2 | 22 | 22 | 21 | 65 | 22 | 22 | 21 | 0 | 1 | 0 | 0 |
5,066 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2PreTrainedModel | from ...modeling_utils import PreTrainedModel
from torch import Tensor, nn
import torch.nn.functional as F
import torch
import math
from ...utils import ModelOutput, auto_docstring, is_torchdynamo_compiling, torch_int
from .configuration_rt_detr_v2 import RTDetrV2Config
@auto_docstring
class RTDetrV2PreTrainedModel(Pr... | @auto_docstring
class RTDetrV2PreTrainedModel(PreTrainedModel):
def _init_weights(self, module):
'''Initialize the weights'''
pass | 3 | 1 | 55 | 6 | 47 | 2 | 13 | 0.04 | 1 | 6 | 4 | 3 | 1 | 0 | 1 | 1 | 61 | 7 | 52 | 13 | 50 | 2 | 46 | 13 | 44 | 13 | 1 | 3 | 13 |
5,067 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modeling_rt_detr_v2.py | transformers.models.rt_detr_v2.modeling_rt_detr_v2.RTDetrV2RepVggBlock | from ...activations import ACT2CLS, ACT2FN
from torch import Tensor, nn
from .configuration_rt_detr_v2 import RTDetrV2Config
class RTDetrV2RepVggBlock(nn.Module):
"""
RepVGG architecture block introduced by the work "RepVGG: Making VGG-style ConvNets Great Again".
"""
def __init__(self, config: RTDetr... |
class RTDetrV2RepVggBlock(nn.Module):
'''
RepVGG architecture block introduced by the work "RepVGG: Making VGG-style ConvNets Great Again".
'''
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, x):
pass | 3 | 1 | 6 | 1 | 5 | 0 | 2 | 0.27 | 1 | 4 | 2 | 0 | 2 | 3 | 2 | 12 | 17 | 3 | 11 | 9 | 8 | 3 | 11 | 9 | 8 | 2 | 1 | 0 | 3 |
5,068 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2Config | from ...configuration_utils import PretrainedConfig
from ...utils.backbone_utils import verify_backbone_config_arguments
from ..auto import CONFIG_MAPPING
class RTDetrV2Config(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`RTDetrV2Model`]. It is used to instantiate a
... |
class RTDetrV2Config(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`RTDetrV2Model`]. It is used to instantiate a
RT-DETR model according to the specified arguments, defining the model architecture. Instantiating a configuration
with the defaults will yield a si... | 6 | 2 | 92 | 3 | 79 | 11 | 3 | 1.02 | 1 | 2 | 0 | 0 | 1 | 58 | 2 | 34 | 350 | 17 | 166 | 129 | 100 | 169 | 77 | 66 | 74 | 5 | 2 | 1 | 6 |
5,069 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2Decoder | from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
from torch import Tensor, nn
class RTDetrV2Decoder(RTDetrDecoder):
def __init__(self, config: RTDetrV2Config):
super().__init__(config)
se... |
class RTDetrV2Decoder(RTDetrDecoder):
def __init__(self, config: RTDetrV2Config):
pass | 2 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 1 | 4 | 2 | 0 | 1 | 1 | 1 | 4 | 4 | 0 | 4 | 3 | 2 | 0 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
5,070 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2DecoderLayer | from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
class RTDetrV2DecoderLayer(RTDetrDecoderLayer):
def __init__(self, config: RTDetrV2Config):
super().__init__(config)
self.encoder_attn = R... |
class RTDetrV2DecoderLayer(RTDetrDecoderLayer):
def __init__(self, config: RTDetrV2Config):
pass | 2 | 0 | 5 | 0 | 3 | 2 | 1 | 0.5 | 1 | 3 | 2 | 0 | 1 | 1 | 1 | 13 | 6 | 0 | 4 | 3 | 2 | 2 | 4 | 3 | 2 | 1 | 2 | 0 | 1 |
5,071 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2ForObjectDetection | from torch import Tensor, nn
from functools import partial
from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
class RTDetrV2ForObjectDetection(RTDetrForObjectDetection, RTDetrV2PreTrainedModel):
def __init... |
class RTDetrV2ForObjectDetection(RTDetrForObjectDetection, RTDetrV2PreTrainedModel):
def __init__(self, config: RTDetrV2Config):
pass | 2 | 0 | 17 | 4 | 10 | 3 | 1 | 0.27 | 2 | 5 | 3 | 0 | 1 | 3 | 1 | 5 | 18 | 4 | 11 | 7 | 9 | 3 | 11 | 7 | 9 | 1 | 3 | 0 | 1 |
5,072 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2MLPPredictionHead | from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
class RTDetrV2MLPPredictionHead(RTDetrMLPPredictionHead):
pass |
class RTDetrV2MLPPredictionHead(RTDetrMLPPredictionHead):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 12 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
5,073 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2Model | from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
class RTDetrV2Model(RTDetrModel):
def __init__(self, config: RTDetrV2Config):
super().__init__(config)
self.decoder = RTDetrV2Decoder(conf... |
class RTDetrV2Model(RTDetrModel):
def __init__(self, config: RTDetrV2Config):
pass | 2 | 0 | 4 | 0 | 3 | 1 | 1 | 0.25 | 1 | 3 | 2 | 0 | 1 | 1 | 1 | 9 | 5 | 0 | 4 | 3 | 2 | 1 | 4 | 3 | 2 | 1 | 3 | 0 | 1 |
5,074 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2MultiscaleDeformableAttention | import torch.nn.functional as F
import warnings
from ...utils import is_torchdynamo_compiling, logging
from torch import Tensor, nn
import torch
from typing import Optional
class RTDetrV2MultiscaleDeformableAttention(nn.Module):
"""
RTDetrV2 version of multiscale deformable attention, extending the base implem... |
class RTDetrV2MultiscaleDeformableAttention(nn.Module):
'''
RTDetrV2 version of multiscale deformable attention, extending the base implementation
with improved offset handling and initialization.
'''
def __init__(self, config: RTDetrV2Config):
pass
def forward(self, hidden_states: to... | 3 | 1 | 38 | 4 | 30 | 4 | 4 | 0.18 | 1 | 7 | 1 | 0 | 2 | 4 | 2 | 15 | 82 | 10 | 61 | 33 | 46 | 11 | 36 | 21 | 33 | 6 | 2 | 1 | 7 |
5,075 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rt_detr_v2/modular_rt_detr_v2.py | transformers.models.rt_detr_v2.modular_rt_detr_v2.RTDetrV2PreTrainedModel | from ..rt_detr.modeling_rt_detr import RTDetrDecoder, RTDetrDecoderLayer, RTDetrForObjectDetection, RTDetrMLPPredictionHead, RTDetrModel, RTDetrPreTrainedModel
class RTDetrV2PreTrainedModel(RTDetrPreTrainedModel):
pass |
class RTDetrV2PreTrainedModel(RTDetrPreTrainedModel):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 1 | 2 | 0 | 2 | 1 | 1 | 0 | 2 | 1 | 1 | 0 | 2 | 0 | 0 |
5,076 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/configuration_rwkv.py | transformers.models.rwkv.configuration_rwkv.RwkvConfig | from ...configuration_utils import PretrainedConfig
class RwkvConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`RwkvModel`]. It is used to instantiate a RWKV
model according to the specified arguments, defining the model architecture. Instantiating a configurat... |
class RwkvConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`RwkvModel`]. It is used to instantiate a RWKV
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
defaults will yield a similar confi... | 2 | 1 | 32 | 2 | 30 | 0 | 3 | 1.42 | 1 | 1 | 0 | 0 | 1 | 11 | 1 | 1 | 93 | 13 | 33 | 30 | 16 | 47 | 16 | 15 | 14 | 3 | 1 | 0 | 3 |
5,077 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvBlock | from torch import nn
from ...modeling_layers import GradientCheckpointingLayer
class RwkvBlock(GradientCheckpointingLayer):
def __init__(self, config, layer_id):
super().__init__()
self.config = config
self.layer_id = layer_id
if layer_id == 0:
self.pre_ln = nn.LayerNor... |
class RwkvBlock(GradientCheckpointingLayer):
def __init__(self, config, layer_id):
pass
def forward(self, hidden, state=None, use_cache=False, output_attentions=False):
pass | 3 | 0 | 15 | 4 | 12 | 0 | 3 | 0 | 1 | 3 | 2 | 0 | 2 | 7 | 2 | 12 | 32 | 8 | 24 | 13 | 21 | 0 | 23 | 13 | 20 | 3 | 1 | 1 | 5 |
5,078 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvFeedForward | import torch
from torch import nn
class RwkvFeedForward(nn.Module):
def __init__(self, config, layer_id=0):
super().__init__()
self.config = config
self.layer_id = layer_id
hidden_size = config.hidden_size
intermediate_size = config.intermediate_size if config.intermediate_... |
class RwkvFeedForward(nn.Module):
def __init__(self, config, layer_id=0):
pass
def forward(self, hidden, state=None):
pass | 3 | 0 | 17 | 3 | 15 | 0 | 3 | 0 | 1 | 1 | 0 | 0 | 2 | 8 | 2 | 12 | 36 | 6 | 30 | 17 | 27 | 0 | 27 | 17 | 24 | 4 | 1 | 2 | 6 |
5,079 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvForCausalLM | import torch
from torch import nn
from ...generation import GenerationMixin
from typing import Optional, Union
from ...utils import ModelOutput, auto_docstring, is_bitsandbytes_available, is_ninja_available, is_torch_cuda_available, logging
@auto_docstring(custom_intro='\n The RWKV Model transformer with a language... | @auto_docstring(custom_intro='\n The RWKV Model transformer with a language modeling head on top (linear layer with weights tied to the input\n embeddings).\n ')
class RwkvForCausalLM(RwkvPreTrainedModel, GenerationMixin):
def __init__(self, config):
pass
def get_output_embeddings(self):
... | 8 | 1 | 16 | 2 | 12 | 2 | 2 | 0.16 | 2 | 4 | 2 | 0 | 5 | 2 | 5 | 6 | 94 | 14 | 70 | 28 | 46 | 11 | 32 | 15 | 26 | 5 | 2 | 1 | 11 |
5,080 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvLinearAttention | import torch
class RwkvLinearAttention(torch.autograd.Function):
@staticmethod
def forward(ctx, time_decay, time_first, key, value, state=None, return_state=False):
batch_size, seq_len, hidden_size = key.size()
if seq_len > rwkv_cuda_kernel.max_seq_length:
raise ValueError(f'Cannot... |
class RwkvLinearAttention(torch.autograd.Function):
@staticmethod
def forward(ctx, time_decay, time_first, key, value, state=None, return_state=False):
pass
@staticmethod
def backward(ctx, g_output, g_state=None):
pass | 5 | 0 | 50 | 5 | 44 | 1 | 7 | 0.03 | 1 | 1 | 0 | 0 | 0 | 0 | 2 | 32 | 104 | 10 | 91 | 15 | 86 | 3 | 46 | 13 | 43 | 10 | 5 | 2 | 14 |
5,081 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvModel | import torch
from ...utils import ModelOutput, auto_docstring, is_bitsandbytes_available, is_ninja_available, is_torch_cuda_available, logging
from typing import Optional, Union
from torch import nn
@auto_docstring
class RwkvModel(RwkvPreTrainedModel):
def __init__(self, config):
super().__init__(config)
... | @auto_docstring
class RwkvModel(RwkvPreTrainedModel):
def __init__(self, config):
pass
def get_input_embeddings(self):
pass
def set_input_embeddings(self, new_embeddings):
pass
@auto_docstring
def forward(self, input_ids: Optional[torch.LongTensor]=None, attention_mask: Op... | 9 | 2 | 25 | 4 | 19 | 2 | 6 | 0.11 | 1 | 10 | 2 | 0 | 6 | 5 | 6 | 7 | 162 | 28 | 122 | 33 | 98 | 13 | 79 | 22 | 71 | 24 | 2 | 5 | 36 |
5,082 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvOutput | from ...utils import ModelOutput, auto_docstring, is_bitsandbytes_available, is_ninja_available, is_torch_cuda_available, logging
import torch
from dataclasses import dataclass
from typing import Optional, Union
@dataclass
@auto_docstring(custom_intro='\n Class for the RWKV model outputs.\n ')
class RwkvOutput(M... | @dataclass
@auto_docstring(custom_intro='\n Class for the RWKV model outputs.\n ')
class RwkvOutput(ModelOutput):
'''
state (list of five `torch.FloatTensor` of shape `(batch_size, hidden_size, num_hidden_layers)`):
The state of the model at the last time step. Can be used in a forward method with... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 27 | 4 | 5 | 5 | 4 | 18 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
5,083 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvPreTrainedModel | from ...utils import ModelOutput, auto_docstring, is_bitsandbytes_available, is_ninja_available, is_torch_cuda_available, logging
from torch import nn
import math
from ...modeling_utils import PreTrainedModel
import torch
from .configuration_rwkv import RwkvConfig
@auto_docstring
class RwkvPreTrainedModel(PreTrainedMo... | @auto_docstring
class RwkvPreTrainedModel(PreTrainedModel):
def _init_weights(self, module: nn.Module):
'''Initialize the weights.'''
pass | 3 | 1 | 56 | 8 | 47 | 4 | 3 | 0.15 | 1 | 3 | 2 | 2 | 1 | 0 | 1 | 1 | 69 | 10 | 54 | 17 | 52 | 8 | 35 | 17 | 33 | 3 | 1 | 2 | 3 |
5,084 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/rwkv/modeling_rwkv.py | transformers.models.rwkv.modeling_rwkv.RwkvSelfAttention | import torch
from ...utils import ModelOutput, auto_docstring, is_bitsandbytes_available, is_ninja_available, is_torch_cuda_available, logging
from torch import nn
class RwkvSelfAttention(nn.Module):
def __init__(self, config, layer_id=0):
super().__init__()
self.config = config
kernel_loa... |
class RwkvSelfAttention(nn.Module):
def __init__(self, config, layer_id=0):
pass
def extract_key_value(self, hidden, state=None):
pass
def forward(self, hidden, state=None, use_cache=False):
pass | 4 | 0 | 21 | 2 | 19 | 0 | 4 | 0.03 | 1 | 3 | 0 | 0 | 3 | 13 | 3 | 13 | 68 | 8 | 58 | 27 | 54 | 2 | 48 | 27 | 44 | 4 | 1 | 2 | 11 |
5,085 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/configuration_sam.py | transformers.models.sam.configuration_sam.SamConfig | from ...configuration_utils import PretrainedConfig
class SamConfig(PretrainedConfig):
"""
[`SamConfig`] is the configuration class to store the configuration of a [`SamModel`]. It is used to instantiate a
SAM model according to the specified arguments, defining the vision model, prompt-encoder model and m... |
class SamConfig(PretrainedConfig):
'''
[`SamConfig`] is the configuration class to store the configuration of a [`SamModel`]. It is used to instantiate a
SAM model according to the specified arguments, defining the vision model, prompt-encoder model and mask decoder
configs. Instantiating a configurati... | 2 | 1 | 24 | 2 | 22 | 0 | 7 | 1.28 | 1 | 4 | 3 | 0 | 1 | 4 | 1 | 1 | 81 | 15 | 29 | 15 | 20 | 37 | 18 | 8 | 16 | 7 | 1 | 1 | 7 |
5,086 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/configuration_sam.py | transformers.models.sam.configuration_sam.SamMaskDecoderConfig | from ...configuration_utils import PretrainedConfig
class SamMaskDecoderConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`SamMaskDecoder`]. It is used to instantiate a SAM
mask decoder to the specified arguments, defining the model architecture. Instantiating a... |
class SamMaskDecoderConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`SamMaskDecoder`]. It is used to instantiate a SAM
mask decoder to the specified arguments, defining the model architecture. Instantiating a configuration defaults
will yield a similar con... | 2 | 1 | 25 | 0 | 25 | 0 | 1 | 1.07 | 1 | 1 | 0 | 0 | 1 | 10 | 1 | 1 | 61 | 5 | 27 | 26 | 12 | 29 | 14 | 13 | 12 | 1 | 1 | 0 | 1 |
5,087 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/configuration_sam.py | transformers.models.sam.configuration_sam.SamPromptEncoderConfig | from ...configuration_utils import PretrainedConfig
class SamPromptEncoderConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`SamPromptEncoder`]. The [`SamPromptEncoder`]
module is used to encode the input 2D points and bounding boxes. Instantiating a configurati... |
class SamPromptEncoderConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`SamPromptEncoder`]. The [`SamPromptEncoder`]
module is used to encode the input 2D points and bounding boxes. Instantiating a configuration defaults will yield
a similar configuration t... | 2 | 1 | 20 | 0 | 20 | 0 | 1 | 0.95 | 1 | 1 | 0 | 0 | 1 | 8 | 1 | 1 | 47 | 4 | 22 | 21 | 10 | 21 | 12 | 11 | 10 | 1 | 1 | 0 | 1 |
5,088 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/configuration_sam.py | transformers.models.sam.configuration_sam.SamVisionConfig | from ...configuration_utils import PretrainedConfig
class SamVisionConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`SamVisionModel`]. It is used to instantiate a SAM
vision encoder according to the specified arguments, defining the model architecture. Instanti... |
class SamVisionConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`SamVisionModel`]. It is used to instantiate a SAM
vision encoder according to the specified arguments, defining the model architecture. Instantiating a configuration
defaults will yield a simi... | 2 | 1 | 44 | 1 | 43 | 0 | 2 | 1.07 | 1 | 2 | 0 | 0 | 1 | 19 | 1 | 1 | 98 | 5 | 45 | 44 | 21 | 48 | 23 | 22 | 21 | 2 | 1 | 0 | 2 |
5,089 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/image_processing_sam.py | transformers.models.sam.image_processing_sam.SamImageProcessor | import numpy as np
from ...image_transforms import convert_to_rgb, pad, resize, to_channel_dimension_format
from ...utils import TensorType, filter_out_non_signature_kwargs, is_torch_available, is_torchvision_available, logging, requires_backends
from ...image_utils import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD, C... |
class SamImageProcessor(BaseImageProcessor):
'''
Constructs a SAM image processor.
Args:
do_resize (`bool`, *optional*, defaults to `True`):
Whether to resize the image's (height, width) dimensions to the specified `size`. Can be overridden by the
`do_resize` parameter in th... | 17 | 11 | 56 | 5 | 33 | 18 | 5 | 0.62 | 1 | 12 | 2 | 0 | 16 | 13 | 16 | 36 | 958 | 92 | 535 | 219 | 371 | 332 | 233 | 72 | 216 | 20 | 3 | 2 | 82 |
5,090 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamAttention | from typing import Callable, Optional, Union
from ...processing_utils import Unpack
from torch import Tensor, nn
from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from transformers.utils.generic import OutputRecorder, TransformersKwargs, check_model_inputs
class SamAttention(nn.Module):
"""
... |
class SamAttention(nn.Module):
'''
SAM's attention layer that allows for downscaling the size of the embedding after projection to queries, keys, and
values.
'''
def __init__(self, config, downsample_rate=None):
pass
def _separate_heads(self, hidden_states: Tensor, num_attention_heads... | 5 | 1 | 13 | 2 | 10 | 1 | 2 | 0.22 | 1 | 4 | 0 | 1 | 4 | 7 | 4 | 14 | 61 | 12 | 41 | 19 | 36 | 9 | 41 | 19 | 36 | 3 | 1 | 1 | 7 |
5,091 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamFeedForward | from torch import Tensor, nn
import torch.nn.functional as F
class SamFeedForward(nn.Module):
def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int, sigmoid_output: bool=False):
super().__init__()
self.num_layers = num_layers
self.activation = nn.ReLU()
... |
class SamFeedForward(nn.Module):
def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int, sigmoid_output: bool=False):
pass
def forward(self, hidden_states):
pass | 3 | 0 | 10 | 1 | 10 | 0 | 2 | 0 | 1 | 4 | 0 | 0 | 2 | 6 | 2 | 12 | 22 | 2 | 20 | 12 | 15 | 0 | 18 | 10 | 15 | 3 | 1 | 1 | 4 |
5,092 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamImageSegmentationOutput | import torch
import torch.nn.functional as F
from typing import Callable, Optional, Union
from ...utils import ModelOutput, auto_docstring, logging
from dataclasses import dataclass
@dataclass
@auto_docstring(custom_intro="\n Base class for Segment-Anything model's output\n ")
class SamImageSegmentationOutput(Mo... | @dataclass
@auto_docstring(custom_intro="\n Base class for Segment-Anything model's output\n ")
class SamImageSegmentationOutput(ModelOutput):
'''
iou_scores (`torch.FloatTensor` of shape `(batch_size, num_masks)`):
The iou scores of the predicted masks.
pred_masks (`torch.FloatTensor` of shap... | 3 | 1 | 0 | 0 | 0 | 0 | 0 | 3.67 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 33 | 5 | 6 | 6 | 5 | 22 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
5,093 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamLayerNorm | from torch import Tensor, nn
import torch.nn.functional as F
import torch
class SamLayerNorm(nn.LayerNorm):
"""LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height,
... |
class SamLayerNorm(nn.LayerNorm):
'''LayerNorm that supports two data formats: channels_last (default) or channels_first.
The ordering of the dimensions in the inputs. channels_last corresponds to inputs with shape (batch_size, height,
width, channels) while channels_first corresponds to inputs with shape ... | 3 | 2 | 11 | 0 | 11 | 0 | 3 | 0.18 | 1 | 3 | 0 | 0 | 2 | 5 | 2 | 12 | 28 | 2 | 22 | 11 | 19 | 4 | 21 | 11 | 18 | 3 | 1 | 1 | 5 |
5,094 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamMLPBlock | import torch.nn.functional as F
from ...activations import ACT2FN
import torch
from torch import Tensor, nn
class SamMLPBlock(nn.Module):
def __init__(self, config):
super().__init__()
self.lin1 = nn.Linear(config.hidden_size, config.mlp_dim)
self.lin2 = nn.Linear(config.mlp_dim, config.hi... |
class SamMLPBlock(nn.Module):
def __init__(self, config):
pass
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
pass | 3 | 0 | 5 | 0 | 5 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 3 | 2 | 12 | 12 | 1 | 11 | 6 | 8 | 0 | 11 | 6 | 8 | 1 | 1 | 0 | 2 |
5,095 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamMaskDecoder | from torch import Tensor, nn
from typing import Callable, Optional, Union
from .configuration_sam import SamConfig, SamMaskDecoderConfig, SamPromptEncoderConfig, SamVisionConfig
import torch.nn.functional as F
import torch
class SamMaskDecoder(nn.Module):
def __init__(self, config: SamMaskDecoderConfig):
... |
class SamMaskDecoder(nn.Module):
def __init__(self, config: SamMaskDecoderConfig):
pass
def forward(self, image_embeddings: torch.Tensor, image_positional_embeddings: torch.Tensor, sparse_prompt_embeddings: torch.Tensor, dense_prompt_embeddings: torch.Tensor, multimask_output: bool, attention_similar... | 3 | 1 | 61 | 10 | 40 | 12 | 4 | 0.28 | 1 | 9 | 4 | 0 | 2 | 13 | 2 | 12 | 124 | 20 | 81 | 46 | 68 | 23 | 57 | 36 | 54 | 5 | 1 | 1 | 7 |
5,096 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamMaskEmbedding | from .configuration_sam import SamConfig, SamMaskDecoderConfig, SamPromptEncoderConfig, SamVisionConfig
from torch import Tensor, nn
from ...activations import ACT2FN
class SamMaskEmbedding(nn.Module):
def __init__(self, config: SamPromptEncoderConfig):
super().__init__()
self.mask_input_channels ... |
class SamMaskEmbedding(nn.Module):
def __init__(self, config: SamPromptEncoderConfig):
pass
def forward(self, masks):
pass | 3 | 0 | 12 | 1 | 11 | 0 | 1 | 0 | 1 | 3 | 2 | 0 | 2 | 7 | 2 | 12 | 25 | 2 | 23 | 12 | 20 | 0 | 19 | 12 | 16 | 1 | 1 | 0 | 2 |
5,097 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamModel | import torch.nn.functional as F
from typing import Callable, Optional, Union
import torch
from transformers.utils.generic import OutputRecorder, TransformersKwargs, check_model_inputs
from ...utils import ModelOutput, auto_docstring, logging
from ...processing_utils import Unpack
from .configuration_sam import SamConfi... | @auto_docstring(custom_intro='\n Segment Anything Model (SAM) for generating segmentation masks, given an input image and\n input points and labels, boxes, or masks.\n ')
class SamModel(SamPreTrainedModel):
def __init__(self, config: SamConfig):
pass
def _tie_weights(self):
pass
... | 13 | 3 | 37 | 4 | 25 | 8 | 4 | 0.32 | 1 | 11 | 5 | 0 | 6 | 4 | 6 | 7 | 235 | 31 | 155 | 62 | 118 | 50 | 72 | 32 | 65 | 19 | 2 | 2 | 24 |
5,098 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamPatchEmbeddings | import collections
from torch import Tensor, nn
class SamPatchEmbeddings(nn.Module):
"""
This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial
`hidden_states` (patch embeddings) of shape `(batch_size, seq_length, hidden_size)` to be consumed by a
Transfor... |
class SamPatchEmbeddings(nn.Module):
'''
This class turns `pixel_values` of shape `(batch_size, num_channels, height, width)` into the initial
`hidden_states` (patch embeddings) of shape `(batch_size, seq_length, hidden_size)` to be consumed by a
Transformer.
'''
def __init__(self, config):
... | 3 | 1 | 13 | 1 | 12 | 0 | 3 | 0.2 | 1 | 2 | 0 | 0 | 2 | 5 | 2 | 12 | 33 | 3 | 25 | 13 | 22 | 5 | 21 | 13 | 18 | 3 | 1 | 1 | 6 |
5,099 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/models/sam/modeling_sam.py | transformers.models.sam.modeling_sam.SamPositionalEmbedding | import numpy as np
import torch
from torch import Tensor, nn
import torch.nn.functional as F
class SamPositionalEmbedding(nn.Module):
def __init__(self, config):
super().__init__()
self.scale = config.hidden_size // 2
self.register_buffer('positional_embedding', self.scale * torch.randn((2... |
class SamPositionalEmbedding(nn.Module):
def __init__(self, config):
pass
def forward(self, input_coords, input_shape=None):
'''Positionally encode points that are normalized to [0,1].'''
pass | 3 | 1 | 10 | 1 | 7 | 2 | 2 | 0.2 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 12 | 21 | 3 | 15 | 5 | 12 | 3 | 15 | 5 | 12 | 2 | 1 | 1 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.