Fix various imports (#22281)
* Fix various imports * Fix copies * Fix import
This commit is contained in:
@@ -6009,16 +6009,6 @@ if TYPE_CHECKING:
|
|||||||
tf_top_k_top_p_filtering,
|
tf_top_k_top_p_filtering,
|
||||||
)
|
)
|
||||||
from .keras_callbacks import KerasMetricCallback, PushToHubCallback
|
from .keras_callbacks import KerasMetricCallback, PushToHubCallback
|
||||||
from .modeling_tf_layoutlm import (
|
|
||||||
TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
|
|
||||||
TFLayoutLMForMaskedLM,
|
|
||||||
TFLayoutLMForQuestionAnswering,
|
|
||||||
TFLayoutLMForSequenceClassification,
|
|
||||||
TFLayoutLMForTokenClassification,
|
|
||||||
TFLayoutLMMainLayer,
|
|
||||||
TFLayoutLMModel,
|
|
||||||
TFLayoutLMPreTrainedModel,
|
|
||||||
)
|
|
||||||
from .modeling_tf_utils import TFPreTrainedModel, TFSequenceSummary, TFSharedEmbeddings, shape_list
|
from .modeling_tf_utils import TFPreTrainedModel, TFSequenceSummary, TFSharedEmbeddings, shape_list
|
||||||
|
|
||||||
# TensorFlow model imports
|
# TensorFlow model imports
|
||||||
@@ -6272,6 +6262,16 @@ if TYPE_CHECKING:
|
|||||||
TFHubertModel,
|
TFHubertModel,
|
||||||
TFHubertPreTrainedModel,
|
TFHubertPreTrainedModel,
|
||||||
)
|
)
|
||||||
|
from .models.layoutlm import (
|
||||||
|
TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST,
|
||||||
|
TFLayoutLMForMaskedLM,
|
||||||
|
TFLayoutLMForQuestionAnswering,
|
||||||
|
TFLayoutLMForSequenceClassification,
|
||||||
|
TFLayoutLMForTokenClassification,
|
||||||
|
TFLayoutLMMainLayer,
|
||||||
|
TFLayoutLMModel,
|
||||||
|
TFLayoutLMPreTrainedModel,
|
||||||
|
)
|
||||||
from .models.layoutlmv3 import (
|
from .models.layoutlmv3 import (
|
||||||
TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
|
TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST,
|
||||||
TFLayoutLMv3ForQuestionAnswering,
|
TFLayoutLMv3ForQuestionAnswering,
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class ConvertCommand(BaseTransformersCLICommand):
|
|||||||
|
|
||||||
convert_xlm_checkpoint_to_pytorch(self._tf_checkpoint, self._pytorch_dump_output)
|
convert_xlm_checkpoint_to_pytorch(self._tf_checkpoint, self._pytorch_dump_output)
|
||||||
elif self._model_type == "lxmert":
|
elif self._model_type == "lxmert":
|
||||||
from ..models.lxmert.convert_lxmert_original_pytorch_checkpoint_to_pytorch import (
|
from ..models.lxmert.convert_lxmert_original_tf_checkpoint_to_pytorch import (
|
||||||
convert_lxmert_checkpoint_to_pytorch,
|
convert_lxmert_checkpoint_to_pytorch,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,12 @@ import torch
|
|||||||
from fairseq.modules import TransformerSentenceEncoderLayer
|
from fairseq.modules import TransformerSentenceEncoderLayer
|
||||||
from packaging import version
|
from packaging import version
|
||||||
|
|
||||||
from transformers import Data2VecTextConfig, Data2VecTextForMaskedLM, Data2VecTextForSequenceClassification
|
from transformers import (
|
||||||
|
Data2VecTextConfig,
|
||||||
|
Data2VecTextForMaskedLM,
|
||||||
|
Data2VecTextForSequenceClassification,
|
||||||
|
Data2VecTextModel,
|
||||||
|
)
|
||||||
from transformers.models.bert.modeling_bert import (
|
from transformers.models.bert.modeling_bert import (
|
||||||
BertIntermediate,
|
BertIntermediate,
|
||||||
BertLayer,
|
BertLayer,
|
||||||
@@ -35,7 +40,6 @@ from transformers.models.bert.modeling_bert import (
|
|||||||
|
|
||||||
# IMPORTANT: In order for this script to run, please make sure to download the dictionary: `dict.txt` from wget https://dl.fbaipublicfiles.com/fairseq/models/roberta.large.tar.gz
|
# IMPORTANT: In order for this script to run, please make sure to download the dictionary: `dict.txt` from wget https://dl.fbaipublicfiles.com/fairseq/models/roberta.large.tar.gz
|
||||||
# File copied from https://github.com/pytorch/fairseq/blob/main/examples/data2vec/models/data2vec_text.py
|
# File copied from https://github.com/pytorch/fairseq/blob/main/examples/data2vec/models/data2vec_text.py
|
||||||
from transformers.models.data2vec.data2vec_text import Data2VecTextModel
|
|
||||||
from transformers.utils import logging
|
from transformers.utils import logging
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ from pathlib import Path
|
|||||||
import torch
|
import torch
|
||||||
from torch.serialization import default_restore_location
|
from torch.serialization import default_restore_location
|
||||||
|
|
||||||
from .transformers import BertConfig, DPRConfig, DPRContextEncoder, DPRQuestionEncoder, DPRReader
|
from transformers import BertConfig, DPRConfig, DPRContextEncoder, DPRQuestionEncoder, DPRReader
|
||||||
|
|
||||||
|
|
||||||
CheckpointState = collections.namedtuple(
|
CheckpointState = collections.namedtuple(
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ else:
|
|||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .configuration_mgp_str import MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP, MgpstrConfig
|
from .configuration_mgp_str import MGP_STR_PRETRAINED_CONFIG_ARCHIVE_MAP, MgpstrConfig
|
||||||
from .processing_mgp_str.py import MgpstrProcessor
|
from .processing_mgp_str import MgpstrProcessor
|
||||||
from .tokenization_mgp_str import MgpstrTokenizer
|
from .tokenization_mgp_str import MgpstrTokenizer
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from .base import ChunkPipeline
|
|||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from pyctcdecode import BeamSearchDecoderCTC
|
from pyctcdecode import BeamSearchDecoderCTC
|
||||||
|
|
||||||
from ...feature_extraction_sequence_utils import SequenceFeatureExtractor
|
from ..feature_extraction_sequence_utils import SequenceFeatureExtractor
|
||||||
|
|
||||||
logger = logging.get_logger(__name__)
|
logger = logging.get_logger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -125,58 +125,6 @@ class PushToHubCallback(metaclass=DummyObject):
|
|||||||
requires_backends(self, ["tf"])
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST = None
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMForMaskedLM(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMForQuestionAnswering(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMForSequenceClassification(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMForTokenClassification(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMMainLayer(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMModel(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFLayoutLMPreTrainedModel(metaclass=DummyObject):
|
|
||||||
_backends = ["tf"]
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
requires_backends(self, ["tf"])
|
|
||||||
|
|
||||||
|
|
||||||
class TFPreTrainedModel(metaclass=DummyObject):
|
class TFPreTrainedModel(metaclass=DummyObject):
|
||||||
_backends = ["tf"]
|
_backends = ["tf"]
|
||||||
|
|
||||||
@@ -1456,6 +1404,58 @@ class TFHubertPreTrainedModel(metaclass=DummyObject):
|
|||||||
requires_backends(self, ["tf"])
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
TF_LAYOUTLM_PRETRAINED_MODEL_ARCHIVE_LIST = None
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMForMaskedLM(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMForQuestionAnswering(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMForSequenceClassification(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMForTokenClassification(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMMainLayer(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMModel(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
|
class TFLayoutLMPreTrainedModel(metaclass=DummyObject):
|
||||||
|
_backends = ["tf"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
requires_backends(self, ["tf"])
|
||||||
|
|
||||||
|
|
||||||
TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST = None
|
TF_LAYOUTLMV3_PRETRAINED_MODEL_ARCHIVE_LIST = None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user