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
3,600
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/marian/tokenization_marian.py
transformers.models.marian.tokenization_marian.MarianTokenizer
import os import warnings from ...utils.import_utils import requires from ...tokenization_utils import PreTrainedTokenizer from shutil import copyfile from pathlib import Path from typing import Any, Optional, Union @requires(backends=('sentencepiece',)) class MarianTokenizer(PreTrainedTokenizer): """ Construc...
@requires(backends=('sentencepiece',)) class MarianTokenizer(PreTrainedTokenizer): ''' Construct a Marian tokenizer. Based on [SentencePiece](https://github.com/google/sentencepiece). This tokenizer inherits from [`PreTrainedTokenizer`] which contains most of the main methods. Users should refer to this...
26
10
11
1
8
2
2
0.56
1
14
0
0
23
15
23
112
332
52
181
79
138
102
130
60
105
10
3
3
47
3,601
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/configuration_markuplm.py
transformers.models.markuplm.configuration_markuplm.MarkupLMConfig
from ...configuration_utils import PretrainedConfig class MarkupLMConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`MarkupLMModel`]. It is used to instantiate a MarkupLM model according to the specified arguments, defining the model architecture. Instantiating ...
class MarkupLMConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`MarkupLMModel`]. It is used to instantiate a MarkupLM model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a s...
2
1
56
0
55
1
1
1.12
1
1
0
0
1
21
1
1
130
9
57
51
28
64
25
24
23
1
1
0
1
3,602
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/feature_extraction_markuplm.py
transformers.models.markuplm.feature_extraction_markuplm.MarkupLMFeatureExtractor
from ...feature_extraction_utils import BatchFeature, FeatureExtractionMixin from ...utils import is_bs4_available, logging, requires_backends import html class MarkupLMFeatureExtractor(FeatureExtractionMixin): """ Constructs a MarkupLM feature extractor. This can be used to get a list of nodes and correspondi...
class MarkupLMFeatureExtractor(FeatureExtractionMixin): ''' Constructs a MarkupLM feature extractor. This can be used to get a list of nodes and corresponding xpaths from HTML strings. This feature extractor inherits from [`~feature_extraction_utils.PreTrainedFeatureExtractor`] which contains most ...
6
2
27
6
15
7
5
0.58
1
11
1
0
5
0
5
17
151
35
74
32
68
43
68
31
62
8
2
3
23
3,603
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMAttention
from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer from typing import Callable, Optional, Union import torch from torch import nn class MarkupLMAttention(nn.Module): def __init__(self, config): super().__init__() self.self = MarkupLMSelfAtt...
class MarkupLMAttention(nn.Module): def __init__(self, config): pass def prune_heads(self, heads): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, *...
4
0
15
1
14
1
1
0.07
1
5
1
0
3
3
3
13
49
4
43
20
30
3
22
11
18
2
1
1
4
3,604
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMEmbeddings
from torch import nn import torch class MarkupLMEmbeddings(nn.Module): """Construct the embeddings from word, position and token_type embeddings.""" def __init__(self, config): super().__init__() self.config = config self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_...
class MarkupLMEmbeddings(nn.Module): '''Construct the embeddings from word, position and token_type embeddings.''' def __init__(self, config): pass @staticmethod def create_position_ids_from_inputs_embeds(inputs_embeds, padding_idx): ''' We are provided embeddings directly. We ...
7
3
30
6
21
3
4
0.15
1
4
1
0
3
9
3
13
96
21
65
32
52
10
44
23
40
9
1
2
11
3,605
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMEncoder
from ...utils import auto_docstring, can_return_tuple, logging from typing import Callable, Optional, Union from torch import nn from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput import torch class ...
class MarkupLMEncoder(nn.Module): def __init__(self, config): pass @can_return_tuple def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, output_hidden_states: Optional...
4
0
45
4
41
0
9
0
1
8
2
0
2
3
2
12
91
8
83
26
68
0
35
14
32
17
1
3
18
3,606
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMForQuestionAnswering
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from torch import nn from ...utils import auto_docstring, can_return_tuple, logging import torch from torch.nn import BCEWithLogitsLoss, CrossEntropy...
@auto_docstring class MarkupLMForQuestionAnswering(MarkupLMPreTrainedModel): def __init__(self, config): pass @can_return_tuple @auto_docstring def forward(self, input_ids: Optional[torch.Tensor]=None, xpath_tags_seq: Optional[torch.Tensor]=None, xpath_subs_seq: Optional[torch.Tensor]=None, att...
6
1
56
9
32
15
4
0.46
1
5
2
0
2
3
2
4
117
19
67
32
47
31
32
16
29
7
2
2
8
3,607
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMForSequenceClassification
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from torch import nn from typing import Callable, Optional, Union from ...utils imp...
@auto_docstring(custom_intro='\n MarkupLM 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 MarkupLMForSequenceClassification(MarkupLMPreTrainedModel): def __init__(self, config): pass @can_ret...
6
1
54
8
37
10
7
0.28
1
6
2
0
2
5
2
4
113
16
76
30
57
21
36
15
33
12
2
3
14
3,608
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMForTokenClassification
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ...utils import auto_docstring, can_return_tuple, logging from torch import nn from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss...
@auto_docstring(custom_intro='\n MarkupLM Model with a `token_classification` head on top.\n ') class MarkupLMForTokenClassification(MarkupLMPreTrainedModel): def __init__(self, config): pass @can_return_tuple @auto_docstring def forward(self, input_ids: Optional[torch.Tensor]=None, xpath...
6
1
46
7
29
11
4
0.38
1
6
3
0
2
4
2
4
97
15
60
29
41
23
22
14
19
5
2
1
7
3,609
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMIntermediate
from ...activations import ACT2FN from torch import nn import torch class MarkupLMIntermediate(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.intermediate_size) if isinstance(config.hidden_act, str): self.intermediat...
class MarkupLMIntermediate(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
3,610
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMLMPredictionHead
import torch from torch import nn class MarkupLMLMPredictionHead(nn.Module): def __init__(self, config): super().__init__() self.transform = MarkupLMPredictionHeadTransform(config) self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False) self.bias = nn.Parameter(...
class MarkupLMLMPredictionHead(nn.Module): def __init__(self, config): pass def _tie_weights(self): 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
3,611
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMLayer
from typing import Callable, Optional, Union from ...pytorch_utils import apply_chunking_to_forward, find_pruneable_heads_and_indices, prune_linear_layer import torch from ...modeling_layers import GradientCheckpointingLayer class MarkupLMLayer(GradientCheckpointingLayer): def __init__(self, config): supe...
class MarkupLMLayer(GradientCheckpointingLayer): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, **kwargs) -> tuple[torch.Tensor]: ...
4
0
27
2
23
2
4
0.1
1
7
3
0
3
8
3
13
84
9
70
32
57
7
41
23
37
7
1
2
11
3,612
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMModel
import torch from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPooling, MaskedLMOutput, QuestionAnsweringModelOutput, SequenceClassifierOutput, TokenClassifierOutput from ...utils import auto_docstring, can_return_tuple, logging from typing import Callable, Optional, Union @auto_docstring class Marku...
@auto_docstring class MarkupLMModel(MarkupLMPreTrainedModel): def __init__(self, config, add_pooling_layer=True): ''' add_pooling_layer (bool, *optional*, defaults to `True`): Whether to add a pooling layer ''' pass def get_input_embeddings(self): pass ...
9
3
22
3
16
3
4
0.22
1
8
4
0
6
4
6
8
141
24
96
35
74
21
52
21
45
15
2
2
23
3,613
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMOnlyMLMHead
import torch from torch import nn class MarkupLMOnlyMLMHead(nn.Module): def __init__(self, config): super().__init__() self.predictions = MarkupLMLMPredictionHead(config) def forward(self, sequence_output: torch.Tensor) -> torch.Tensor: prediction_scores = self.predictions(sequence_ou...
class MarkupLMOnlyMLMHead(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
3,614
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMOutput
from torch import nn import torch class MarkupLMOutput(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 MarkupLMOutput(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
3,615
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMPooler
from torch import nn import torch class MarkupLMPooler(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) self.activation = nn.Tanh() def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: first_to...
class MarkupLMPooler(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
6
0
5
1
1
0.2
1
2
0
0
2
2
2
12
13
1
10
7
7
2
10
7
7
1
1
0
2
3,616
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMPreTrainedModel
from torch import nn from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel import os from ...utils import auto_docstring, can_return_tuple, logging from typing import Callable, Optional, Union from .configuration_markuplm import MarkupLMConfig @auto_docstring class MarkupLMPreTrainedModel(PreTrainedMo...
@auto_docstring class MarkupLMPreTrainedModel(PreTrainedModel): def _init_weights(self, module): '''Initialize the weights''' pass @classmethod def from_pretrained(cls, pretrained_model_name_or_path: Optional[Union[str, os.PathLike]], *model_args, **kwargs): pass
5
1
10
0
8
2
4
0.4
1
3
0
4
1
0
2
2
31
3
20
6
16
8
15
5
12
6
1
2
7
3,617
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMPredictionHeadTransform
from torch import nn from ...activations import ACT2FN import torch class MarkupLMPredictionHeadTransform(nn.Module): def __init__(self, config): super().__init__() self.dense = nn.Linear(config.hidden_size, config.hidden_size) if isinstance(config.hidden_act, str): self.transf...
class MarkupLMPredictionHeadTransform(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
7
0
7
0
2
0
1
3
0
0
2
3
2
12
15
1
14
6
11
0
13
6
10
2
1
1
3
3,618
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMSelfAttention
from typing import Callable, Optional, Union from torch import nn from ...modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel import torch class MarkupLMSelfAttention(nn.Module): def __init__(self, config): super().__init__() if config.hidden_size % config.num_attention_heads != 0 and (...
class MarkupLMSelfAttention(nn.Module): def __init__(self, config): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False, **kwargs) -> tuple[torch.Tensor]: pas...
3
0
43
7
31
6
6
0.19
1
5
0
0
3
11
3
13
132
22
93
44
80
18
72
35
68
13
1
2
17
3,619
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.MarkupLMSelfOutput
from torch import nn import torch class MarkupLMSelfOutput(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 MarkupLMSelfOutput(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
3,620
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/modeling_markuplm.py
transformers.models.markuplm.modeling_markuplm.XPathEmbeddings
import torch from torch import nn class XPathEmbeddings(nn.Module): """Construct the embeddings from xpath tags and subscripts. We drop tree-id in this version, as its info can be covered by xpath. """ def __init__(self, config): super().__init__() self.max_depth = config.max_depth ...
class XPathEmbeddings(nn.Module): '''Construct the embeddings from xpath tags and subscripts. We drop tree-id in this version, as its info can be covered by xpath. ''' def __init__(self, config): pass def forward(self, xpath_tags_seq=None, xpath_subs_seq=None): pass
3
1
21
5
16
0
2
0.09
1
2
0
0
2
8
2
12
48
13
32
16
29
3
22
15
19
2
1
1
3
3,621
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/processing_markuplm.py
transformers.models.markuplm.processing_markuplm.MarkupLMProcessor
from ...processing_utils import ProcessorMixin from typing import Optional, Union from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, TruncationStrategy from ...file_utils import TensorType class MarkupLMProcessor(ProcessorMixin): """ Constructs a MarkupLM processor which combines a MarkupLM...
class MarkupLMProcessor(ProcessorMixin): ''' Constructs a MarkupLM processor which combines a MarkupLM feature extractor and a MarkupLM tokenizer into a single processor. [`MarkupLMProcessor`] offers all the functionalities you need to prepare data for the model. It first uses [`MarkupLMFeatureExtr...
2
2
24
2
18
5
3
0.44
1
6
2
0
4
0
4
21
122
15
75
34
47
33
29
11
24
10
2
2
13
3,622
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/tokenization_markuplm.py
transformers.models.markuplm.tokenization_markuplm.MarkupLMTokenizer
import regex as re from ...file_utils import PaddingStrategy, TensorType, add_end_docstrings import os from ...tokenization_utils_base import ENCODE_KWARGS_DOCSTRING, BatchEncoding, EncodedInput, PreTokenizedInput, TextInput, TextInputPair, TruncationStrategy import json from typing import Optional, Union from ...token...
class MarkupLMTokenizer(PreTrainedTokenizer): ''' Construct a MarkupLM tokenizer. Based on byte-level Byte-Pair-Encoding (BPE). [`MarkupLMTokenizer`] can be used to turn HTML strings into to token-level `input_ids`, `attention_mask`, `token_type_ids`, `xpath_tags_seq` and `xpath_tags_seq`. This tokeniz...
35
15
47
3
37
8
5
0.25
1
16
2
0
26
19
26
115
1,341
108
998
375
730
246
406
130
378
31
3
4
142
3,623
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/markuplm/tokenization_markuplm_fast.py
transformers.models.markuplm.tokenization_markuplm_fast.MarkupLMTokenizerFast
from tokenizers import processors from .tokenization_markuplm import MARKUPLM_ENCODE_PLUS_ADDITIONAL_KWARGS_DOCSTRING, MarkupLMTokenizer from typing import Optional, Union from ...tokenization_utils_fast import PreTrainedTokenizerFast import json from ...file_utils import PaddingStrategy, TensorType, add_end_docstrings...
class MarkupLMTokenizerFast(PreTrainedTokenizerFast): ''' Construct a MarkupLM tokenizer. Based on byte-level Byte-Pair-Encoding (BPE). [`MarkupLMTokenizerFast`] can be used to turn HTML strings into to token-level `input_ids`, `attention_mask`, `token_type_ids`, `xpath_tags_seq` and `xpath_tags_seq`. ...
17
7
61
4
47
10
7
0.27
1
16
2
0
12
10
12
100
844
72
609
234
441
165
232
80
218
22
3
6
93
3,624
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/configuration_mask2former.py
transformers.models.mask2former.configuration_mask2former.Mask2FormerConfig
from typing import Optional from ..auto import CONFIG_MAPPING from ...configuration_utils import PretrainedConfig from ...utils.backbone_utils import verify_backbone_config_arguments class Mask2FormerConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`Mask2FormerMode...
class Mask2FormerConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`Mask2FormerModel`]. It is used to instantiate a Mask2Former model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will ...
6
2
59
3
53
4
3
0.9
1
6
0
0
1
33
2
2
226
17
110
77
71
99
50
41
47
4
1
1
5
3,625
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/convert_mask2former_original_pytorch_checkpoint_to_pytorch.py
transformers.models.mask2former.convert_mask2former_original_pytorch_checkpoint_to_pytorch.Args
from dataclasses import dataclass @dataclass class Args: """Fake command line arguments needed by mask2former/detectron implementation""" config_file: str
@dataclass class Args: '''Fake command line arguments needed by mask2former/detectron implementation''' pass
2
1
0
0
0
0
0
0.5
0
0
0
0
0
0
0
0
4
1
2
1
1
1
2
1
1
0
0
0
0
3,626
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/convert_mask2former_original_pytorch_checkpoint_to_pytorch.py
transformers.models.mask2former.convert_mask2former_original_pytorch_checkpoint_to_pytorch.OriginalMask2FormerCheckpointToOursConverter
from torch import Tensor, nn from collections.abc import Iterator from pprint import pformat from transformers import Mask2FormerConfig, Mask2FormerForUniversalSegmentation, Mask2FormerImageProcessor, Mask2FormerModel, SwinConfig from pathlib import Path class OriginalMask2FormerCheckpointToOursConverter: def __i...
class OriginalMask2FormerCheckpointToOursConverter: def __init__(self, original_model: nn.Module, config: Mask2FormerConfig): pass def pop_all(self, renamed_keys: list[tuple[str, str]], dst_state_dict: StateDict, src_state_dict: StateDict): pass def replace_maskformer_swin_backbone(self,...
18
0
40
4
35
2
2
0.06
0
8
1
0
12
2
13
13
633
73
531
84
509
31
178
79
161
4
0
2
31
3,627
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/convert_mask2former_original_pytorch_checkpoint_to_pytorch.py
transformers.models.mask2former.convert_mask2former_original_pytorch_checkpoint_to_pytorch.OriginalMask2FormerConfigToImageProcessorConverter
from transformers import Mask2FormerConfig, Mask2FormerForUniversalSegmentation, Mask2FormerImageProcessor, Mask2FormerModel, SwinConfig import torch class OriginalMask2FormerConfigToImageProcessorConverter: def __call__(self, original_config: object) -> Mask2FormerImageProcessor: model = original_config....
class OriginalMask2FormerConfigToImageProcessorConverter: def __call__(self, original_config: object) -> Mask2FormerImageProcessor: pass
2
0
13
1
12
0
1
0
0
2
0
0
1
0
1
1
14
1
13
4
11
0
5
4
3
1
0
0
1
3,628
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/convert_mask2former_original_pytorch_checkpoint_to_pytorch.py
transformers.models.mask2former.convert_mask2former_original_pytorch_checkpoint_to_pytorch.OriginalMask2FormerConfigToOursConverter
import json from huggingface_hub import hf_hub_download from transformers import Mask2FormerConfig, Mask2FormerForUniversalSegmentation, Mask2FormerImageProcessor, Mask2FormerModel, SwinConfig class OriginalMask2FormerConfigToOursConverter: def __call__(self, original_config: object) -> Mask2FormerConfig: ...
class OriginalMask2FormerConfigToOursConverter: def __call__(self, original_config: object) -> Mask2FormerConfig: pass
2
0
81
6
75
0
12
0
0
5
0
0
1
0
1
1
82
6
76
9
74
0
26
9
24
12
0
1
12
3,629
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/image_processing_mask2former.py
transformers.models.mask2former.image_processing_mask2former.Mask2FormerImageProcessor
from ...image_transforms import PaddingMode, get_resize_output_image_size, pad, rescale, resize, to_channel_dimension_format from ...image_utils import ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_flat_list_of_images, to_numpy_array, valid_image...
class Mask2FormerImageProcessor(BaseImageProcessor): ''' Constructs a Mask2Former image processor. The image processor can be used to prepare image(s) and optional targets for the model. This image processor inherits from [`BaseImageProcessor`] which contains most of the main methods. Users should ...
19
12
48
4
30
13
4
0.52
1
14
3
0
16
13
17
37
888
92
527
234
369
275
237
98
219
18
3
3
76
3,630
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerAttention
from torch import Tensor, nn from typing import Optional, Union import torch class Mask2FormerAttention(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 DETR paper). """ def __init__(self, e...
class Mask2FormerAttention(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 DETR paper). ''' def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, is_decoder: bool=False, bi...
5
2
31
5
23
3
5
0.18
1
6
0
0
4
9
4
14
134
23
94
42
74
17
63
27
58
13
1
2
18
3,631
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerForUniversalSegmentation
from ...utils import auto_docstring, is_accelerate_available, logging from typing import Optional, Union from .configuration_mask2former import Mask2FormerConfig from torch import Tensor, nn import torch @auto_docstring(custom_intro='\n The Mask2Former Model with heads on top for instance/semantic/panoptic segmenta...
@auto_docstring(custom_intro='\n The Mask2Former Model with heads on top for instance/semantic/panoptic segmentation.\n ') class Mask2FormerForUniversalSegmentation(Mask2FormerPreTrainedModel): def __init__(self, config: Mask2FormerConfig): pass def get_loss_dict(self, masks_queries_logits: Tens...
8
1
48
8
21
18
4
0.83
1
11
4
0
5
4
5
6
248
45
111
44
86
92
54
26
48
11
2
3
19
3,632
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerForUniversalSegmentationOutput
from ...utils import auto_docstring, is_accelerate_available, logging from ...file_utils import ModelOutput, is_scipy_available, requires_backends from typing import Optional, Union from dataclasses import dataclass import torch @dataclass @auto_docstring(custom_intro='\n Class for outputs of [`Mask2FormerForUniver...
@dataclass @auto_docstring(custom_intro='\n Class for outputs of [`Mask2FormerForUniversalSegmentationOutput`].\n\n This output can be directly passed to [`~Mask2FormerImageProcessor.post_process_semantic_segmentation`] or\n [`~Mask2FormerImageProcessor.post_process_instance_segmentation`] or\n [`~Mask2Form...
3
1
0
0
0
0
0
3.25
1
0
0
0
0
0
0
0
54
3
12
12
11
39
12
12
11
0
1
0
0
3,633
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerHungarianMatcher
from torch import Tensor, nn import numpy as np import torch class Mask2FormerHungarianMatcher(nn.Module): """This class computes an assignment between the labels and the predictions of the network. For efficiency reasons, the labels don't include the no_object. Because of this, in general, there are more ...
class Mask2FormerHungarianMatcher(nn.Module): '''This class computes an assignment between the labels and the predictions of the network. For efficiency reasons, the labels don't include the no_object. Because of this, in general, there are more predictions than labels. In this case, we do a 1-to-1 matchin...
4
3
47
5
22
21
2
1.02
1
6
0
0
2
4
2
12
104
13
45
31
33
46
34
22
31
2
1
1
4
3,634
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerLoss
from ...utils import auto_docstring, is_accelerate_available, logging import numpy as np from ...file_utils import ModelOutput, is_scipy_available, requires_backends from typing import Optional, Union from .configuration_mask2former import Mask2FormerConfig from torch import Tensor, nn import torch class Mask2FormerLo...
class Mask2FormerLoss(nn.Module): def __init__(self, config: Mask2FormerConfig, weight_dict: dict[str, float]): ''' The Mask2Former Loss. The loss is computed very similar to DETR. The process happens in two steps: 1) we compute hungarian assignment between ground truth masks and the outpu...
12
7
27
3
14
11
2
0.77
1
12
2
0
11
7
11
21
310
39
154
91
120
119
108
69
96
3
1
2
19
3,635
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerMLPPredictionHead
from torch import Tensor, nn class Mask2FormerMLPPredictionHead(nn.Module): def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int=3): """ A classic Multi Layer Perceptron (MLP). Args: input_dim (`int`): The input dimensions. ...
class Mask2FormerMLPPredictionHead(nn.Module): def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int=3): ''' A classic Multi Layer Perceptron (MLP). Args: input_dim (`int`): The input dimensions. hidden_dim (`int`): ...
3
1
18
1
8
9
3
1.13
1
7
1
0
2
1
2
12
37
3
16
11
13
18
16
11
13
3
1
1
5
3,636
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerMaskPredictor
from torch import Tensor, nn from typing import Optional, Union import torch class Mask2FormerMaskPredictor(nn.Module): def __init__(self, hidden_size: int, num_heads: int, mask_feature_size: torch.Tensor): """ This class is used to get the predicted mask for a given Mask2FormerMaskedAttentionDeco...
class Mask2FormerMaskPredictor(nn.Module): def __init__(self, hidden_size: int, num_heads: int, mask_feature_size: torch.Tensor): ''' This class is used to get the predicted mask for a given Mask2FormerMaskedAttentionDecoder layer. It also generates the binarized attention mask associated ...
3
1
23
4
12
8
2
0.63
1
6
1
0
2
3
2
12
47
8
24
13
21
15
21
13
18
3
1
2
4
3,637
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerMaskedAttentionDecoder
from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig from typing import Optional, Union import torch class Mask2FormerMaskedAttentionDecoder(nn.Module): """ Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`Mask2FormerMaskedAttentionDecoder...
class Mask2FormerMaskedAttentionDecoder(nn.Module): ''' Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`Mask2FormerMaskedAttentionDecoderLayer`]. The decoder updates the query embeddings through multiple cross (masked) and self-attention layers. The decoder uses a ne...
3
2
79
13
50
16
8
0.42
1
10
4
0
2
10
2
12
171
29
101
38
87
42
53
26
50
14
1
2
15
3,638
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerMaskedAttentionDecoderLayer
from typing import Optional, Union from ...activations import ACT2FN from .configuration_mask2former import Mask2FormerConfig from torch import Tensor, nn from ...modeling_layers import GradientCheckpointingLayer import torch class Mask2FormerMaskedAttentionDecoderLayer(GradientCheckpointingLayer): """ The Mas...
class Mask2FormerMaskedAttentionDecoderLayer(GradientCheckpointingLayer): ''' The Mask2FormerMaskedAttentionDecoderLayer is made up of self-attention, cross (masked) attention as well as FFN blocks. The cross attention block used as part of `Mask2FormerMaskedAttentionDecoderLayer` is actually a `masked ...
6
2
39
5
29
5
2
0.24
1
6
2
0
5
13
5
15
212
32
145
58
109
35
71
28
65
2
1
1
9
3,639
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerModel
from ...utils import auto_docstring, is_accelerate_available, logging from typing import Optional, Union from .configuration_mask2former import Mask2FormerConfig from torch import Tensor, nn import torch @auto_docstring class Mask2FormerModel(Mask2FormerPreTrainedModel): main_input_name = 'pixel_values' def _...
@auto_docstring class Mask2FormerModel(Mask2FormerPreTrainedModel): def __init__(self, config: Mask2FormerConfig): pass @auto_docstring def forward(self, pixel_values: Tensor, pixel_mask: Optional[Tensor]=None, output_hidden_states: Optional[bool]=None, output_attentions: Optional[bool]=None, retur...
5
0
46
8
27
12
4
0.42
1
8
4
0
2
2
2
3
98
17
57
22
45
24
29
14
26
7
2
1
8
3,640
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerModelOutput
from ...utils import auto_docstring, is_accelerate_available, logging from ...file_utils import ModelOutput, is_scipy_available, requires_backends from typing import Optional, Union from dataclasses import dataclass import torch @dataclass @auto_docstring(custom_intro='\n Class for outputs of [`Mask2FormerModel`]. ...
null
3
1
0
0
0
0
0
3.1
1
0
0
0
0
0
0
0
43
2
10
10
9
31
10
10
9
0
1
0
0
3,641
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelDecoder
from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig import numpy as np import torch class Mask2FormerPixelDecoder(nn.Module): def __init__(self, config: Mask2FormerConfig, feature_channels): super().__init__() self.config = config feature_dim = config.feat...
class Mask2FormerPixelDecoder(nn.Module): def __init__(self, config: Mask2FormerConfig, feature_channels): pass def get_valid_ratio(self, mask, dtype=torch.float32): '''Get the valid ratio of all feature maps.''' pass def forward(self, features, encoder_outputs=None, output_atten...
4
1
60
9
46
4
5
0.09
1
11
4
0
3
13
3
13
182
30
140
67
129
12
89
60
85
11
1
2
16
3,642
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelDecoderEncoderLayer
from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig from typing import Optional, Union import torch class Mask2FormerPixelDecoderEncoderLayer(nn.Module): def __init__(self, config: Mask2FormerConfig): super().__init__() self.embed_dim = config.feature_size ...
class Mask2FormerPixelDecoderEncoderLayer(nn.Module): def __init__(self, config: Mask2FormerConfig): pass def forward(self, hidden_states: torch.Tensor, attention_mask: torch.Tensor, position_embeddings: Optional[torch.Tensor]=None, reference_points=None, spatial_shapes_list=None, level_start_index=N...
3
1
43
5
28
10
3
0.33
1
5
2
0
2
9
2
12
87
11
57
25
45
19
33
16
30
4
1
2
5
3,643
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelDecoderEncoderMultiscaleDeformableAttention
from torch import Tensor, nn import warnings from typing import Optional, Union import torch class Mask2FormerPixelDecoderEncoderMultiscaleDeformableAttention(nn.Module): """ Multiscale deformable attention as proposed in Deformable DETR. """ def __init__(self, embed_dim: int, num_heads: int, n_levels...
class Mask2FormerPixelDecoderEncoderMultiscaleDeformableAttention(nn.Module): ''' Multiscale deformable attention as proposed in Deformable DETR. ''' def __init__(self, embed_dim: int, num_heads: int, n_levels: int, n_points: int): pass def with_pos_embed(self, tensor: torch.Tensor, p...
4
1
30
2
26
1
4
0.09
1
6
0
0
3
9
3
13
96
10
79
34
64
7
42
23
38
6
1
1
11
3,644
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelDecoderEncoderOnly
from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithCrossAttentions from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig import torch class Mask2FormerPixelDecoderEncoderOnly(nn.Module): """ Transformer encoder consisting of *config.encoder_layers* deformable at...
class Mask2FormerPixelDecoderEncoderOnly(nn.Module): ''' Transformer encoder consisting of *config.encoder_layers* deformable attention layers. Each layer is a [`Mask2FormerPixelDecoderEncoderLayer`]. The encoder updates the flattened multi-scale feature maps through multiple deformable attention layer...
5
3
38
4
21
13
4
0.69
1
6
3
0
2
3
3
13
126
16
65
31
49
45
35
18
31
10
1
2
13
3,645
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelDecoderOutput
from ...utils import auto_docstring, is_accelerate_available, logging from ...file_utils import ModelOutput, is_scipy_available, requires_backends from typing import Optional, Union from dataclasses import dataclass import torch @dataclass @auto_docstring(custom_intro="\n Mask2Former's pixel decoder module output, ...
@dataclass @auto_docstring(custom_intro="\n Mask2Former's pixel decoder module output, practically a Multi-Scale Deformable Attention based decoder. It returns\n the mask features and the multiscale features.\n ") class Mask2FormerPixelDecoderOutput(ModelOutput): ''' multi_scale_features (`tuple(torch....
3
1
0
0
0
0
0
3.75
1
0
0
0
0
0
0
0
21
2
4
4
3
15
4
4
3
0
1
0
0
3,646
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelLevelModule
from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig from ...utils.backbone_utils import load_backbone class Mask2FormerPixelLevelModule(nn.Module): def __init__(self, config: Mask2FormerConfig): """ Pixel Level Module proposed in [Masked-attention Mask Transformer...
class Mask2FormerPixelLevelModule(nn.Module): def __init__(self, config: Mask2FormerConfig): ''' Pixel Level Module proposed in [Masked-attention Mask Transformer for Universal Image Segmentation](https://huggingface.co/papers/2112.01527). It runs the input image through a backbone and a p...
3
1
12
2
7
4
2
0.57
1
7
3
0
2
2
2
12
26
4
14
7
11
8
9
7
6
2
1
0
3
3,647
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPixelLevelModuleOutput
from ...utils import auto_docstring, is_accelerate_available, logging from ...file_utils import ModelOutput, is_scipy_available, requires_backends from typing import Optional, Union from dataclasses import dataclass import torch @dataclass @auto_docstring(custom_intro="\n Mask2Former's pixel level module output. It...
@dataclass @auto_docstring(custom_intro="\n Mask2Former's pixel level module output. It returns the output of the encoder (optional) and all hidden states\n (multi-scale features) from the `decoder`. By default, the `encoder` is a Swin Backbone and the `decoder` is a\n Multi-Scale Deformable Attention based de...
3
1
0
0
0
0
0
4
1
0
0
0
0
0
0
0
28
3
5
5
4
20
5
5
4
0
1
0
0
3,648
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPreTrainedModel
import math from ...utils import auto_docstring, is_accelerate_available, logging from ...modeling_utils import PreTrainedModel from .configuration_mask2former import Mask2FormerConfig from torch import Tensor, nn import torch @auto_docstring class Mask2FormerPreTrainedModel(PreTrainedModel): config: Mask2FormerCo...
@auto_docstring class Mask2FormerPreTrainedModel(PreTrainedModel): def _init_weights(self, module: nn.Module): pass
3
0
68
10
58
0
25
0
1
7
6
2
1
0
1
1
73
11
62
13
60
0
51
13
49
25
1
4
25
3,649
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerPredictionBlock
from torch import Tensor, nn class Mask2FormerPredictionBlock(nn.Module): def __init__(self, in_dim: int, out_dim: int, activation: nn.Module) -> None: super().__init__() self.layers = [nn.Linear(in_dim, out_dim), activation] for i, layer in enumerate(self.layers): self.add_mod...
class Mask2FormerPredictionBlock(nn.Module): def __init__(self, in_dim: int, out_dim: int, activation: nn.Module) -> None: pass def forward(self, input: Tensor) -> Tensor: pass
3
0
6
0
5
1
2
0.09
1
5
0
0
2
1
2
12
13
1
11
7
8
1
11
7
8
2
1
1
4
3,650
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerSinePositionEmbedding
from typing import Optional, Union from torch import Tensor, nn import torch import math from ...pytorch_utils import compile_compatible_method_lru_cache class Mask2FormerSinePositionEmbedding(nn.Module): """ This is a more standard version of the position embedding, very similar to the one used by the Attenti...
class Mask2FormerSinePositionEmbedding(nn.Module): ''' This is a more standard version of the position embedding, very similar to the one used by the Attention is all you need paper, generalized to work on images. ''' def __init__(self, num_pos_feats: int=64, temperature: int=10000, normalize: boo...
4
1
15
1
14
0
3
0.14
1
6
0
0
2
4
2
12
37
4
29
17
24
4
27
15
24
3
1
1
6
3,651
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mask2former/modeling_mask2former.py
transformers.models.mask2former.modeling_mask2former.Mask2FormerTransformerModule
from torch import Tensor, nn from .configuration_mask2former import Mask2FormerConfig class Mask2FormerTransformerModule(nn.Module): """ The Mask2Former's transformer module. """ def __init__(self, in_features: int, config: Mask2FormerConfig): super().__init__() hidden_dim = config.hid...
class Mask2FormerTransformerModule(nn.Module): ''' The Mask2Former's transformer module. ''' def __init__(self, in_features: int, config: Mask2FormerConfig): pass def forward(self, multi_scale_features: list[Tensor], mask_features: Tensor, output_hidden_states: bool=False, output_attentio...
3
1
30
4
25
1
3
0.1
1
9
4
0
2
7
2
12
65
10
50
26
41
5
30
20
27
3
1
2
5
3,652
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/configuration_maskformer.py
transformers.models.maskformer.configuration_maskformer.MaskFormerConfig
from ...utils.backbone_utils import verify_backbone_config_arguments from ..detr import DetrConfig from ...configuration_utils import PretrainedConfig from typing import Optional from ..auto import CONFIG_MAPPING from ..swin import SwinConfig class MaskFormerConfig(PretrainedConfig): """ This is the configurat...
class MaskFormerConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`MaskFormerModel`]. It is used to instantiate a MaskFormer model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yie...
6
2
56
3
45
9
5
0.84
1
9
2
0
1
18
2
2
194
19
95
50
70
80
43
28
40
8
1
2
9
3,653
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/configuration_maskformer_swin.py
transformers.models.maskformer.configuration_maskformer_swin.MaskFormerSwinConfig
from ...utils.backbone_utils import BackboneConfigMixin, get_aligned_output_features_output_indices from ...configuration_utils import PretrainedConfig class MaskFormerSwinConfig(BackboneConfigMixin, PretrainedConfig): """ This is the configuration class to store the configuration of a [`MaskFormerSwinModel`]....
class MaskFormerSwinConfig(BackboneConfigMixin, PretrainedConfig): ''' This is the configuration class to store the configuration of a [`MaskFormerSwinModel`]. It is used to instantiate a Donut model according to the specified arguments, defining the model architecture. Instantiating a configuration wi...
2
1
48
1
45
2
1
1.25
2
3
0
0
1
21
1
6
126
11
51
45
28
64
25
24
23
1
1
0
1
3,654
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/convert_maskformer_original_pytorch_checkpoint_to_pytorch.py
transformers.models.maskformer.convert_maskformer_original_pytorch_checkpoint_to_pytorch.Args
from dataclasses import dataclass @dataclass class Args: """Fake command line arguments needed by maskformer/detectron implementation""" config_file: str
@dataclass class Args: '''Fake command line arguments needed by maskformer/detectron implementation''' pass
2
1
0
0
0
0
0
0.5
0
0
0
0
0
0
0
0
4
1
2
1
1
1
2
1
1
0
0
0
0
3,655
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/convert_maskformer_original_pytorch_checkpoint_to_pytorch.py
transformers.models.maskformer.convert_maskformer_original_pytorch_checkpoint_to_pytorch.OriginalMaskFormerCheckpointToOursConverter
from collections.abc import Iterator from transformers.models.maskformer.modeling_maskformer import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerForInstanceSegmentationOutput, MaskFormerModel, MaskFormerModelOutput from pprint import pformat from pathlib import Path from torch import Tensor, nn class...
class OriginalMaskFormerCheckpointToOursConverter: def __init__(self, original_model: nn.Module, config: MaskFormerConfig): pass def pop_all(self, renamed_keys: list[tuple[str, str]], dst_state_dict: StateDict, src_state_dict: StateDict): pass def replace_backbone(self, dst_state_dict: S...
15
0
28
3
24
2
2
0.07
0
9
1
0
11
2
12
12
371
45
305
63
288
22
131
60
117
4
0
2
22
3,656
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/convert_maskformer_original_pytorch_checkpoint_to_pytorch.py
transformers.models.maskformer.convert_maskformer_original_pytorch_checkpoint_to_pytorch.OriginalMaskFormerConfigToImageProcessorConverter
from detectron2.data import MetadataCatalog from transformers.models.maskformer.feature_extraction_maskformer import MaskFormerImageProcessor import torch class OriginalMaskFormerConfigToImageProcessorConverter: def __call__(self, original_config: object) -> MaskFormerImageProcessor: model = original_conf...
class OriginalMaskFormerConfigToImageProcessorConverter: def __call__(self, original_config: object) -> MaskFormerImageProcessor: pass
2
0
14
1
13
1
1
0.07
0
2
0
0
1
0
1
1
15
1
14
5
12
1
6
5
4
1
0
0
1
3,657
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/convert_maskformer_original_pytorch_checkpoint_to_pytorch.py
transformers.models.maskformer.convert_maskformer_original_pytorch_checkpoint_to_pytorch.OriginalMaskFormerConfigToOursConverter
from transformers.models.maskformer.modeling_maskformer import MaskFormerConfig, MaskFormerForInstanceSegmentation, MaskFormerForInstanceSegmentationOutput, MaskFormerModel, MaskFormerModelOutput from detectron2.data import MetadataCatalog class OriginalMaskFormerConfigToOursConverter: def __call__(self, original...
class OriginalMaskFormerConfigToOursConverter: def __call__(self, original_config: object) -> MaskFormerConfig: pass
2
0
57
3
53
1
1
0.02
0
4
0
0
1
0
1
1
58
3
54
9
52
1
10
9
8
1
0
0
1
3,658
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/feature_extraction_maskformer.py
transformers.models.maskformer.feature_extraction_maskformer.MaskFormerFeatureExtractor
import warnings from ...utils.import_utils import requires from .image_processing_maskformer import MaskFormerImageProcessor @requires(backends=('vision',)) class MaskFormerFeatureExtractor(MaskFormerImageProcessor): def __init__(self, *args, **kwargs) -> None: warnings.warn('The class MaskFormerFeatureEx...
@requires(backends=('vision',)) class MaskFormerFeatureExtractor(MaskFormerImageProcessor): def __init__(self, *args, **kwargs) -> None: pass
3
0
7
0
7
0
1
0
1
2
0
0
1
0
1
39
8
0
8
2
6
0
4
2
2
1
4
0
1
3,659
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/image_processing_maskformer.py
transformers.models.maskformer.image_processing_maskformer.MaskFormerImageProcessor
from ...image_processing_utils import INIT_SERVICE_KWARGS, BaseImageProcessor, BatchFeature, get_size_dict from ...image_utils import ChannelDimension, ImageInput, PILImageResampling, get_image_size, infer_channel_dimension_format, is_scaled_image, make_flat_list_of_images, to_numpy_array, valid_images, validate_prepro...
@requires(backends=('vision',)) class MaskFormerImageProcessor(BaseImageProcessor): ''' Constructs a MaskFormer image processor. The image processor can be used to prepare image(s) and optional targets for the model. This image processor inherits from [`BaseImageProcessor`] which contains most of the ma...
21
13
47
4
30
14
4
0.53
1
15
3
1
17
13
18
38
921
95
544
242
383
288
244
104
225
17
3
3
77
3,660
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.DetrAttention
from typing import Optional, Union import torch from torch import Tensor, nn class DetrAttention(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 DETR paper). """ def __init__(self, embed_d...
class DetrAttention(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 DETR paper). ''' def __init__(self, embed_dim: int, num_heads: int, dropout: float=0.0, bias: bool=True): pass ...
5
2
29
4
22
3
4
0.19
1
6
0
0
4
9
4
14
127
22
88
41
69
17
60
27
55
9
1
2
14
3,661
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.DetrDecoder
from ...modeling_attn_mask_utils import _prepare_4d_attention_mask from ..detr import DetrConfig import torch from torch import Tensor, nn class DetrDecoder(nn.Module): """ Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`DetrDecoderLayer`]. The decoder updates the query...
class DetrDecoder(nn.Module): ''' Transformer decoder consisting of *config.decoder_layers* layers. Each layer is a [`DetrDecoderLayer`]. The decoder updates the query embeddings through multiple self-attention and cross-attention layers. Some small tweaks for DETR: - object_queries and query_posit...
3
2
75
11
45
20
11
0.53
1
7
3
0
2
6
2
12
165
27
90
29
76
48
48
18
45
21
1
3
22
3,662
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.DetrDecoderLayer
from torch import Tensor, nn import torch from ...modeling_layers import GradientCheckpointingLayer from typing import Optional, Union from ..detr import DetrConfig from ...activations import ACT2FN class DetrDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: DetrConfig): super().__init_...
class DetrDecoderLayer(GradientCheckpointingLayer): def __init__(self, config: DetrConfig): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.Tensor]=None, object_queries: Optional[torch.Tensor]=None, query_position_embeddings: Optional[torch.Tensor]=None, encoder_hid...
3
1
51
6
33
12
2
0.36
1
5
2
0
2
11
2
12
103
12
67
27
55
24
38
18
35
3
1
1
4
3,663
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.DetrDecoderOutput
from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union from dataclasses import dataclass from ...modeling_outputs import BaseModelOutputWithCrossAttentions import torch @dataclass @auto_docstring(custom_intro='\n B...
@dataclass @auto_docstring(custom_intro='\n Base class for outputs of the DETR decoder. This class adds one attribute to BaseModelOutputWithCrossAttentions,\n namely an optional stack of intermediate decoder activations, i.e. the output of each decoder layer, each of them\n gone through a layernorm. This is us...
3
1
0
0
0
0
0
11.5
1
0
0
0
0
0
0
0
27
2
2
2
1
23
2
2
1
0
2
0
0
3,664
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerFPNConvLayer
from torch import Tensor, nn class MaskFormerFPNConvLayer(nn.Module): def __init__(self, in_features: int, out_features: int, kernel_size: int=3, padding: int=1): """ A basic module that executes conv - norm - in sequence used in MaskFormer. Args: in_features (`int`): ...
class MaskFormerFPNConvLayer(nn.Module): def __init__(self, in_features: int, out_features: int, kernel_size: int=3, padding: int=1): ''' A basic module that executes conv - norm - in sequence used in MaskFormer. Args: in_features (`int`): The number of input fe...
3
1
15
1
7
7
2
0.93
1
5
0
0
2
1
2
12
31
2
15
7
12
14
11
7
8
2
1
1
4
3,665
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerFPNLayer
from torch import Tensor, nn class MaskFormerFPNLayer(nn.Module): def __init__(self, in_features: int, lateral_features: int): """ A Feature Pyramid Network Layer (FPN) layer. It creates a feature map by aggregating features from the previous and backbone layer. Due to the spatial mismatch...
class MaskFormerFPNLayer(nn.Module): def __init__(self, in_features: int, lateral_features: int): ''' A Feature Pyramid Network Layer (FPN) layer. It creates a feature map by aggregating features from the previous and backbone layer. Due to the spatial mismatch, the tensor coming from the ...
3
1
12
1
7
5
1
0.64
1
4
1
0
2
2
2
12
26
3
14
5
11
9
11
5
8
1
1
0
2
3,666
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerFPNModel
from torch import Tensor, nn class MaskFormerFPNModel(nn.Module): def __init__(self, in_features: int, lateral_widths: list[int], feature_size: int=256): """ Feature Pyramid Network, given an input tensor and a set of feature map of different feature/spatial size, it creates a list of feat...
class MaskFormerFPNModel(nn.Module): def __init__(self, in_features: int, lateral_widths: list[int], feature_size: int=256): ''' Feature Pyramid Network, given an input tensor and a set of feature map of different feature/spatial size, it creates a list of feature maps with the same featur...
3
1
14
1
8
6
2
0.69
1
6
2
0
2
2
2
12
29
2
16
10
13
11
14
10
11
2
1
1
3
3,667
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerForInstanceSegmentation
from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union from torch import Tensor, nn import torch from .configuration_maskformer import MaskFormerConfig class MaskFormerForInstanceSegmentation(MaskFormerPreTrainedModel...
class MaskFormerForInstanceSegmentation(MaskFormerPreTrainedModel): def __init__(self, config: MaskFormerConfig): pass def get_loss_dict(self, masks_queries_logits: Tensor, class_queries_logits: Tensor, mask_labels: Tensor, class_labels: Tensor, auxiliary_logits: dict[str, Tensor]) -> dict[str, Tenso...
7
1
49
7
28
14
5
0.5
1
16
7
0
5
6
5
6
250
39
141
53
116
70
69
35
63
13
2
3
26
3,668
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerForInstanceSegmentationOutput
from dataclasses import dataclass from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union import torch @dataclass @auto_docstring(custom_intro='\n Class for outputs of [`MaskFormerForInstanceSegmentation`].\n\n T...
@dataclass @auto_docstring(custom_intro='\n Class for outputs of [`MaskFormerForInstanceSegmentation`].\n\n This output can be directly passed to [`~MaskFormerImageProcessor.post_process_semantic_segmentation`] or or\n [`~MaskFormerImageProcessor.post_process_instance_segmentation`] or\n [`~MaskFormerImageP...
3
1
0
0
0
0
0
3.15
1
0
0
0
0
0
0
0
57
3
13
13
12
41
13
13
12
0
1
0
0
3,669
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerHungarianMatcher
from torch import Tensor, nn import numpy as np import torch class MaskFormerHungarianMatcher(nn.Module): """This class computes an assignment between the labels and the predictions of the network. For efficiency reasons, the labels don't include the no_object. Because of this, in general, there are more ...
class MaskFormerHungarianMatcher(nn.Module): '''This class computes an assignment between the labels and the predictions of the network. For efficiency reasons, the labels don't include the no_object. Because of this, in general, there are more predictions than labels. In this case, we do a 1-to-1 matching...
5
3
28
2
12
15
2
1.29
1
5
0
0
3
3
3
13
95
10
38
24
33
49
31
23
27
2
1
1
5
3,670
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerLoss
from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union from numbers import Number from torch import Tensor, nn import torch import numpy as np class MaskFormerLoss(nn.Module): def __init__(self, num_labels: int, ...
class MaskFormerLoss(nn.Module): def __init__(self, num_labels: int, matcher: MaskFormerHungarianMatcher, weight_dict: dict[str, float], eos_coef: float): ''' The MaskFormer Loss. The loss is computed very similar to DETR. The process happens in two steps: 1) we compute hungarian assignmen...
10
5
23
2
12
9
2
0.77
1
12
1
0
9
4
9
19
217
22
110
69
83
85
83
52
73
3
1
2
16
3,671
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerModel
from .configuration_maskformer import MaskFormerConfig from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union from torch import Tensor, nn import torch @auto_docstring class MaskFormerModel(MaskFormerPreTrainedModel):...
@auto_docstring class MaskFormerModel(MaskFormerPreTrainedModel): def __init__(self, config: MaskFormerConfig): pass @auto_docstring def forward(self, pixel_values: Tensor, pixel_mask: Optional[Tensor]=None, output_hidden_states: Optional[bool]=None, output_attentions: Optional[bool]=None, return_d...
5
1
47
10
27
10
5
0.35
1
9
4
0
2
2
2
3
97
20
57
24
45
20
33
16
30
8
2
1
9
3,672
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerModelOutput
from dataclasses import dataclass from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union import torch @dataclass @auto_docstring(custom_intro='\n Class for outputs of [`MaskFormerModel`]. This class returns all the...
@dataclass @auto_docstring(custom_intro='\n Class for outputs of [`MaskFormerModel`]. This class returns all the needed hidden states to compute the logits.\n ') class MaskFormerModelOutput(ModelOutput): ''' encoder_last_hidden_state (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)...
3
1
0
0
0
0
0
3.22
1
0
0
0
0
0
0
0
40
2
9
9
8
29
9
9
8
0
1
0
0
3,673
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerPixelDecoder
from torch import Tensor, nn class MaskFormerPixelDecoder(nn.Module): def __init__(self, *args, feature_size: int=256, mask_feature_size: int=256, **kwargs): """ Pixel Decoder Module proposed in [Per-Pixel Classification is Not All You Need for Semantic Segmentation](https://huggingface.co...
class MaskFormerPixelDecoder(nn.Module): def __init__(self, *args, feature_size: int=256, mask_feature_size: int=256, **kwargs): ''' Pixel Decoder Module proposed in [Per-Pixel Classification is Not All You Need for Semantic Segmentation](https://huggingface.co/papers/2107.06278). It first...
3
1
15
2
7
6
3
0.73
1
7
2
0
2
2
2
12
31
5
15
9
10
11
11
7
8
4
1
1
5
3,674
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerPixelDecoderOutput
from dataclasses import dataclass import torch from typing import Optional, Union from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends @dataclass @auto_docstring(custom_intro="\n MaskFormer's pixel decoder module output, practically a Feature Pyra...
@dataclass @auto_docstring(custom_intro="\n MaskFormer's pixel decoder module output, practically a Feature Pyramid Network. It returns the last hidden state\n and (optionally) the hidden states.\n ") class MaskFormerPixelDecoderOutput(ModelOutput): ''' last_hidden_state (`torch.FloatTensor` of shape `...
3
1
0
0
0
0
0
3.75
1
0
0
0
0
0
0
0
21
2
4
4
3
15
4
4
3
0
1
0
0
3,675
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerPixelLevelModule
from .configuration_maskformer_swin import MaskFormerSwinConfig from ...utils.backbone_utils import load_backbone from .configuration_maskformer import MaskFormerConfig from torch import Tensor, nn class MaskFormerPixelLevelModule(nn.Module): def __init__(self, config: MaskFormerConfig): """ Pixel...
class MaskFormerPixelLevelModule(nn.Module): def __init__(self, config: MaskFormerConfig): ''' Pixel Level Module proposed in [Per-Pixel Classification is Not All You Need for Semantic Segmentation](https://huggingface.co/papers/2107.06278). It runs the input image through a backbone and a...
3
1
24
2
17
5
4
0.29
1
8
4
0
2
2
2
12
49
5
34
14
29
10
22
12
19
5
1
2
7
3,676
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerPixelLevelModuleOutput
from dataclasses import dataclass from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from typing import Optional, Union import torch @dataclass @auto_docstring(custom_intro="\n MaskFormer's pixel level module output. It returns both the last and...
@dataclass @auto_docstring(custom_intro="\n MaskFormer's pixel level module output. It returns both the last and (optionally) the hidden states from the\n `encoder` and `decoder`. By default, the `encoder` is a MaskFormerSwin Transformer and the `decoder` is a Feature\n Pyramid Network (FPN).\n\n The `encod...
3
1
0
0
0
0
0
4
1
0
0
0
0
0
0
0
28
3
5
5
4
20
5
5
4
0
1
0
0
3,677
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerPreTrainedModel
from ...utils import ModelOutput, auto_docstring, is_accelerate_available, is_scipy_available, logging, requires_backends from torch import Tensor, nn from ...modeling_utils import PreTrainedModel from .configuration_maskformer import MaskFormerConfig @auto_docstring class MaskFormerPreTrainedModel(PreTrainedModel): ...
@auto_docstring class MaskFormerPreTrainedModel(PreTrainedModel): def _init_weights(self, module: nn.Module): pass
3
0
38
2
29
7
14
0.21
1
5
5
2
1
0
1
1
43
3
33
8
31
7
27
8
25
14
1
3
14
3,678
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerSinePositionEmbedding
from typing import Optional, Union from ...pytorch_utils import compile_compatible_method_lru_cache from torch import Tensor, nn import torch import math class MaskFormerSinePositionEmbedding(nn.Module): """ This is a more standard version of the position embedding, very similar to the one used by the Attentio...
class MaskFormerSinePositionEmbedding(nn.Module): ''' This is a more standard version of the position embedding, very similar to the one used by the Attention is all you need paper, generalized to work on images. ''' def __init__(self, num_pos_feats: int=64, temperature: int=10000, normalize: bool...
4
1
15
1
14
0
3
0.14
1
6
0
0
2
4
2
12
37
4
29
17
24
4
27
15
24
3
1
1
6
3,679
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskFormerTransformerModule
from torch import Tensor, nn from .configuration_maskformer import MaskFormerConfig import torch from typing import Optional, Union class MaskFormerTransformerModule(nn.Module): """ The MaskFormer's transformer module. """ def __init__(self, in_features: int, config: MaskFormerConfig): super()...
class MaskFormerTransformerModule(nn.Module): ''' The MaskFormer's transformer module. ''' def __init__(self, in_features: int, config: MaskFormerConfig): pass def forward(self, image_features: Tensor, output_hidden_states: bool=False, output_attentions: bool=False, return_dict: Optional[...
3
1
20
1
18
1
2
0.14
1
8
4
0
2
4
2
12
46
4
37
21
28
5
21
15
18
2
1
1
4
3,680
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer.py
transformers.models.maskformer.modeling_maskformer.MaskformerMLPPredictionHead
from torch import Tensor, nn class MaskformerMLPPredictionHead(nn.Module): def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int=3): """ A classic Multi Layer Perceptron (MLP). Args: input_dim (`int`): The input dimensions. ...
class MaskformerMLPPredictionHead(nn.Module): def __init__(self, input_dim: int, hidden_dim: int, output_dim: int, num_layers: int=3): ''' A classic Multi Layer Perceptron (MLP). Args: input_dim (`int`): The input dimensions. hidden_dim (`int`): ...
3
1
18
1
8
9
3
1.13
1
7
1
0
2
1
2
12
37
3
16
11
13
18
16
11
13
3
1
1
5
3,681
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinAttention
import torch from typing import Optional from torch import Tensor, nn from ...pytorch_utils import find_pruneable_heads_and_indices, meshgrid, prune_linear_layer class MaskFormerSwinAttention(nn.Module): def __init__(self, config, dim, num_heads, window_size): super().__init__() self.self = MaskFo...
class MaskFormerSwinAttention(nn.Module): def __init__(self, config, dim, num_heads, window_size): pass def prune_heads(self, heads): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_...
4
0
11
1
10
1
1
0.1
1
6
2
0
3
3
3
13
36
4
30
17
20
3
22
11
18
2
1
1
4
3,682
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinBackbone
from .configuration_maskformer_swin import MaskFormerSwinConfig from ...utils.backbone_utils import BackboneMixin from torch import Tensor, nn from ...modeling_outputs import BackboneOutput from typing import Optional class MaskFormerSwinBackbone(MaskFormerSwinPreTrainedModel, BackboneMixin): """ MaskFormerSwi...
class MaskFormerSwinBackbone(MaskFormerSwinPreTrainedModel, BackboneMixin): ''' MaskFormerSwin backbone, designed especially for the MaskFormer framework. This classes reshapes `hidden_states` from (`batch_size, sequence_length, hidden_size)` to (`batch_size, num_channels, height, width)`). It also add...
3
1
34
4
27
4
6
0.28
2
11
3
0
2
3
2
15
80
11
54
23
45
15
34
17
31
10
2
2
12
3,683
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinBaseModelOutput
from dataclasses import dataclass from ...utils import auto_docstring, torch_int from typing import Optional import torch from ...file_utils import ModelOutput @dataclass @auto_docstring(custom_intro="\n Class for SwinEncoder's outputs.\n ") class MaskFormerSwinBaseModelOutput(ModelOutput): """ hidden_st...
@dataclass @auto_docstring(custom_intro="\n Class for SwinEncoder's outputs.\n ") class MaskFormerSwinBaseModelOutput(ModelOutput): ''' hidden_states_spatial_dimensions (`tuple(tuple(int, int))`, *optional*): A tuple containing the spatial dimension of each `hidden_state` needed to reshape the `hi...
3
1
0
0
0
0
0
3.8
1
0
0
0
0
0
0
0
28
4
5
5
4
19
5
5
4
0
1
0
0
3,684
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinDropPath
import torch from torch import Tensor, nn from typing import Optional class MaskFormerSwinDropPath(nn.Module): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).""" def __init__(self, drop_prob: Optional[float]=None) -> None: super().__init__() self.dro...
class MaskFormerSwinDropPath(nn.Module): '''Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).''' def __init__(self, drop_prob: Optional[float]=None) -> None: pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass def extra_rep...
4
1
2
0
2
0
1
0.13
1
4
0
0
3
1
3
13
12
3
8
5
4
1
8
5
4
1
1
0
3
3,685
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinEmbeddings
from torch import Tensor, nn import torch from ...utils import auto_docstring, torch_int class MaskFormerSwinEmbeddings(nn.Module): """ Construct the patch and position embeddings. """ def __init__(self, config): super().__init__() self.patch_embeddings = MaskFormerSwinPatchEmbeddings(...
class MaskFormerSwinEmbeddings(nn.Module): ''' Construct the patch and position embeddings. ''' def __init__(self, config): pass def interpolate_pos_encoding(self, embeddings: torch.Tensor, height: int, width: int) -> torch.Tensor: ''' This method allows to interpolate the...
4
2
23
5
15
3
2
0.27
1
4
1
0
3
6
3
13
76
19
45
21
41
12
38
21
34
3
1
2
7
3,686
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinEncoder
import torch from torch import Tensor, nn class MaskFormerSwinEncoder(nn.Module): def __init__(self, config, grid_size): super().__init__() self.num_layers = len(config.depths) self.config = config dpr = [x.item() for x in torch.linspace(0, config.drop_path_rate, sum(config.depths)...
class MaskFormerSwinEncoder(nn.Module): def __init__(self, config, grid_size): pass def forward(self, hidden_states, input_dimensions, head_mask=None, output_attentions=False, output_hidden_states=False, return_dict=True): pass
3
0
38
5
33
0
6
0.01
1
8
3
0
2
4
2
12
78
10
67
22
56
1
29
14
26
10
1
2
12
3,687
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinIntermediate
from torch import Tensor, nn import torch from ...activations import ACT2FN class MaskFormerSwinIntermediate(nn.Module): def __init__(self, config, dim): super().__init__() self.dense = nn.Linear(dim, int(config.mlp_ratio * dim)) if isinstance(config.hidden_act, str): self.inte...
class MaskFormerSwinIntermediate(nn.Module): def __init__(self, config, dim): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
6
0
6
0
2
0
1
4
0
0
2
2
2
12
13
1
12
5
9
0
11
5
8
2
1
1
3
3,688
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinLayer
import torch from torch import Tensor, nn class MaskFormerSwinLayer(nn.Module): def __init__(self, config, dim, input_resolution, num_heads, drop_path_rate=0.0, shift_size=0): super().__init__() self.shift_size = shift_size self.window_size = config.window_size self.input_resolutio...
class MaskFormerSwinLayer(nn.Module): def __init__(self, config, dim, input_resolution, num_heads, drop_path_rate=0.0, shift_size=0): pass def get_attn_mask(self, input_resolution): pass def maybe_pad(self, hidden_states, height, width): pass def forward(self, hidden_states,...
5
0
26
4
21
2
3
0.08
1
7
4
0
4
9
4
14
108
18
85
42
80
7
70
42
65
5
1
3
12
3,689
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinModel
from torch import Tensor, nn import torch class MaskFormerSwinModel(MaskFormerSwinPreTrainedModel): def __init__(self, config, add_pooling_layer=True): super().__init__(config) self.config = config self.num_layers = len(config.depths) self.num_features = int(config.embed_dim * 2 **...
class MaskFormerSwinModel(MaskFormerSwinPreTrainedModel): def __init__(self, config, add_pooling_layer=True): pass def get_input_embeddings(self): pass def _prune_heads(self, heads_to_prune): ''' Prunes heads of the model. heads_to_prune: dict of {layer_num: list of heads...
5
1
20
3
15
2
3
0.15
1
6
3
0
4
7
4
5
82
14
59
26
46
9
34
18
29
8
2
1
13
3,690
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinModelOutputWithPooling
from ...file_utils import ModelOutput from dataclasses import dataclass from ...utils import auto_docstring, torch_int from typing import Optional import torch @dataclass @auto_docstring(custom_intro="\n Class for MaskFormerSwinModel's outputs that also contains the spatial dimensions of the hidden states.\n ") ...
@dataclass @auto_docstring(custom_intro="\n Class for MaskFormerSwinModel's outputs that also contains the spatial dimensions of the hidden states.\n ") class MaskFormerSwinModelOutputWithPooling(ModelOutput): ''' pooler_output (`torch.FloatTensor` of shape `(batch_size, hidden_size)`): Last layer...
3
1
0
0
0
0
0
3.5
1
0
0
0
0
0
0
0
31
4
6
6
5
21
6
6
5
0
1
0
0
3,691
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinOutput
import torch from torch import Tensor, nn class MaskFormerSwinOutput(nn.Module): def __init__(self, config, dim): super().__init__() self.dense = nn.Linear(int(config.mlp_ratio * dim), dim) self.dropout = nn.Dropout(config.hidden_dropout_prob) def forward(self, hidden_states: torch.Te...
class MaskFormerSwinOutput(nn.Module): def __init__(self, config, dim): pass def forward(self, hidden_states: torch.Tensor) -> torch.Tensor: pass
3
0
4
0
4
0
1
0
1
3
0
0
2
2
2
12
10
1
9
5
6
0
9
5
6
1
1
0
2
3,692
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinPatchEmbeddings
import collections.abc from torch import Tensor, nn import torch from typing import Optional class MaskFormerSwinPatchEmbeddings(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, se...
class MaskFormerSwinPatchEmbeddings(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, ...
4
1
11
1
10
0
2
0.2
1
4
0
0
3
6
3
13
41
5
30
17
26
6
30
17
26
3
1
1
7
3,693
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinPatchMerging
from torch import Tensor, nn import torch class MaskFormerSwinPatchMerging(nn.Module): """ Patch Merging Layer. Args: input_resolution (`tuple[int]`): Resolution of input feature. dim (`int`): Number of input channels. norm_layer (`nn.Module`, *optional*, de...
class MaskFormerSwinPatchMerging(nn.Module): ''' Patch Merging Layer. Args: input_resolution (`tuple[int]`): Resolution of input feature. dim (`int`): Number of input channels. norm_layer (`nn.Module`, *optional*, defaults to `nn.LayerNorm`): Norm...
4
1
12
1
9
3
1
0.67
1
3
0
0
3
4
3
13
52
8
27
16
23
18
27
16
23
2
1
1
4
3,694
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinPreTrainedModel
from torch import Tensor, nn from ...utils import auto_docstring, torch_int from ...modeling_utils import PreTrainedModel from .configuration_maskformer_swin import MaskFormerSwinConfig @auto_docstring class MaskFormerSwinPreTrainedModel(PreTrainedModel): config: MaskFormerSwinConfig base_model_prefix = 'model...
@auto_docstring class MaskFormerSwinPreTrainedModel(PreTrainedModel): def _init_weights(self, module): '''Initialize the weights''' pass
3
1
11
0
8
3
4
0.5
1
0
0
2
1
0
1
1
23
2
14
7
12
7
13
7
11
4
1
2
4
3,695
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinSelfAttention
from torch import Tensor, nn from typing import Optional import torch import collections.abc from ...pytorch_utils import find_pruneable_heads_and_indices, meshgrid, prune_linear_layer import math class MaskFormerSwinSelfAttention(nn.Module): def __init__(self, config, dim, num_heads, window_size): super(...
class MaskFormerSwinSelfAttention(nn.Module): def __init__(self, config, dim, num_heads, window_size): pass def forward(self, hidden_states: torch.Tensor, attention_mask: Optional[torch.FloatTensor]=None, head_mask: Optional[torch.FloatTensor]=None, output_attentions: Optional[bool]=False) -> tuple[t...
3
0
32
6
24
2
3
0.1
1
6
0
0
3
9
3
13
98
19
72
38
62
7
56
32
52
4
1
1
8
3,696
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinSelfOutput
import torch from torch import Tensor, nn class MaskFormerSwinSelfOutput(nn.Module): def __init__(self, config, dim): super().__init__() self.dense = nn.Linear(dim, dim) self.dropout = nn.Dropout(config.attention_probs_dropout_prob) def forward(self, hidden_states: torch.Tensor, input...
class MaskFormerSwinSelfOutput(nn.Module): def __init__(self, config, dim): pass def forward(self, hidden_states: torch.Tensor, input_tensor: torch.Tensor) -> torch.Tensor: pass
3
0
5
1
4
0
1
0
1
2
0
0
2
2
2
12
11
2
9
5
6
0
9
5
6
1
1
0
2
3,697
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/maskformer/modeling_maskformer_swin.py
transformers.models.maskformer.modeling_maskformer_swin.MaskFormerSwinStage
from torch import Tensor, nn from ...modeling_layers import GradientCheckpointingLayer class MaskFormerSwinStage(GradientCheckpointingLayer): def __init__(self, config, dim, input_resolution, depth, num_heads, drop_path, downsample): super().__init__() self.config = config self.dim = dim ...
class MaskFormerSwinStage(GradientCheckpointingLayer): def __init__(self, config, dim, input_resolution, depth, num_heads, drop_path, downsample): pass def forward(self, hidden_states, input_dimensions, head_mask=None, output_attentions=False, output_hidden_states=False): pass
3
0
26
5
21
1
5
0.05
1
4
1
0
2
5
2
12
55
10
43
17
38
2
27
15
24
7
1
2
10
3,698
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/configuration_mbart.py
transformers.models.mbart.configuration_mbart.MBartConfig
from ...configuration_utils import PretrainedConfig class MBartConfig(PretrainedConfig): """ This is the configuration class to store the configuration of a [`MBartModel`]. It is used to instantiate an MBART model according to the specified arguments, defining the model architecture. Instantiating a config...
class MBartConfig(PretrainedConfig): ''' This is the configuration class to store the configuration of a [`MBartModel`]. It is used to instantiate an MBART model according to the specified arguments, defining the model architecture. Instantiating a configuration with the defaults will yield a similar c...
2
1
56
0
56
1
1
1.08
1
1
0
0
1
20
1
1
134
10
60
52
31
65
26
25
24
1
1
0
1
3,699
huggingface/pytorch-pretrained-BERT
huggingface_pytorch-pretrained-BERT/src/transformers/models/mbart/configuration_mbart.py
transformers.models.mbart.configuration_mbart.MBartOnnxConfig
from ...onnx.utils import compute_effective_axis_dimension from ... import PreTrainedTokenizer from typing import Any from collections import OrderedDict from ...utils import is_torch_available, logging from ...onnx import OnnxConfig, OnnxConfigWithPast, OnnxSeq2SeqConfigWithPast from collections.abc import Mapping cl...
class MBartOnnxConfig(OnnxSeq2SeqConfigWithPast): @property def inputs(self) -> Mapping[str, Mapping[int, str]]: pass @property def outputs(self) -> Mapping[str, Mapping[int, str]]: pass def _generate_dummy_inputs_for_default_and_seq2seq_lm(self, tokenizer: PreTrainedTokenizer, ba...
10
0
30
2
27
1
4
0.05
1
9
0
0
7
1
7
7
221
20
191
73
151
10
89
42
79
8
1
3
28