Include image processor in add-new-model-like (#20439)
This commit is contained in:
@@ -44,12 +44,14 @@ BERT_MODEL_FILES = {
|
||||
"src/transformers/models/bert/configuration_bert.py",
|
||||
"src/transformers/models/bert/tokenization_bert.py",
|
||||
"src/transformers/models/bert/tokenization_bert_fast.py",
|
||||
"src/transformers/models/bert/tokenization_bert_tf.py",
|
||||
"src/transformers/models/bert/modeling_bert.py",
|
||||
"src/transformers/models/bert/modeling_flax_bert.py",
|
||||
"src/transformers/models/bert/modeling_tf_bert.py",
|
||||
"src/transformers/models/bert/convert_bert_original_tf_checkpoint_to_pytorch.py",
|
||||
"src/transformers/models/bert/convert_bert_original_tf2_checkpoint_to_pytorch.py",
|
||||
"src/transformers/models/bert/convert_bert_pytorch_checkpoint_to_original_tf.py",
|
||||
"src/transformers/models/bert/convert_bert_token_dropping_original_tf2_checkpoint_to_pytorch.py",
|
||||
}
|
||||
|
||||
VIT_MODEL_FILES = {
|
||||
@@ -58,6 +60,7 @@ VIT_MODEL_FILES = {
|
||||
"src/transformers/models/vit/convert_dino_to_pytorch.py",
|
||||
"src/transformers/models/vit/convert_vit_timm_to_pytorch.py",
|
||||
"src/transformers/models/vit/feature_extraction_vit.py",
|
||||
"src/transformers/models/vit/image_processing_vit.py",
|
||||
"src/transformers/models/vit/modeling_vit.py",
|
||||
"src/transformers/models/vit/modeling_tf_vit.py",
|
||||
"src/transformers/models/vit/modeling_flax_vit.py",
|
||||
@@ -89,7 +92,8 @@ class TestAddNewModelLike(unittest.TestCase):
|
||||
|
||||
def check_result(self, file_name, expected_result):
|
||||
with open(file_name, "r", encoding="utf-8") as f:
|
||||
self.assertEqual(f.read(), expected_result)
|
||||
result = f.read()
|
||||
self.assertEqual(result, expected_result)
|
||||
|
||||
def test_re_class_func(self):
|
||||
self.assertEqual(_re_class_func.search("def my_function(x, y):").groups()[0], "my_function")
|
||||
@@ -439,7 +443,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
self.check_result(dest_file_name, bert_expected)
|
||||
|
||||
def test_filter_framework_files(self):
|
||||
files = ["modeling_tf_bert.py", "modeling_bert.py", "modeling_flax_bert.py", "configuration_bert.py"]
|
||||
files = ["modeling_bert.py", "modeling_tf_bert.py", "modeling_flax_bert.py", "configuration_bert.py"]
|
||||
self.assertEqual(filter_framework_files(files), files)
|
||||
self.assertEqual(set(filter_framework_files(files, ["pt", "tf", "flax"])), set(files))
|
||||
|
||||
@@ -467,7 +471,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
bert_files = get_model_files("bert")
|
||||
|
||||
doc_file = str(Path(bert_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/bert.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/bert.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["model_files"]}
|
||||
self.assertEqual(model_files, BERT_MODEL_FILES)
|
||||
@@ -476,17 +480,17 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["test_files"]}
|
||||
bert_test_files = {
|
||||
"tests/test_tokenization_bert.py",
|
||||
"tests/test_modeling_bert.py",
|
||||
"tests/test_modeling_tf_bert.py",
|
||||
"tests/test_modeling_flax_bert.py",
|
||||
"tests/models/bert/test_tokenization_bert.py",
|
||||
"tests/models/bert/test_modeling_bert.py",
|
||||
"tests/models/bert/test_modeling_tf_bert.py",
|
||||
"tests/models/bert/test_modeling_flax_bert.py",
|
||||
}
|
||||
self.assertEqual(test_files, bert_test_files)
|
||||
|
||||
# VIT
|
||||
vit_files = get_model_files("vit")
|
||||
doc_file = str(Path(vit_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/vit.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/vit.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["model_files"]}
|
||||
self.assertEqual(model_files, VIT_MODEL_FILES)
|
||||
@@ -495,17 +499,17 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["test_files"]}
|
||||
vit_test_files = {
|
||||
"tests/test_feature_extraction_vit.py",
|
||||
"tests/test_modeling_vit.py",
|
||||
"tests/test_modeling_tf_vit.py",
|
||||
"tests/test_modeling_flax_vit.py",
|
||||
"tests/models/vit/test_feature_extraction_vit.py",
|
||||
"tests/models/vit/test_modeling_vit.py",
|
||||
"tests/models/vit/test_modeling_tf_vit.py",
|
||||
"tests/models/vit/test_modeling_flax_vit.py",
|
||||
}
|
||||
self.assertEqual(test_files, vit_test_files)
|
||||
|
||||
# Wav2Vec2
|
||||
wav2vec2_files = get_model_files("wav2vec2")
|
||||
doc_file = str(Path(wav2vec2_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/wav2vec2.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/wav2vec2.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["model_files"]}
|
||||
self.assertEqual(model_files, WAV2VEC2_MODEL_FILES)
|
||||
@@ -514,12 +518,12 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["test_files"]}
|
||||
wav2vec2_test_files = {
|
||||
"tests/test_feature_extraction_wav2vec2.py",
|
||||
"tests/test_modeling_wav2vec2.py",
|
||||
"tests/test_modeling_tf_wav2vec2.py",
|
||||
"tests/test_modeling_flax_wav2vec2.py",
|
||||
"tests/test_processor_wav2vec2.py",
|
||||
"tests/test_tokenization_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_feature_extraction_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_tf_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_flax_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_processor_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_tokenization_wav2vec2.py",
|
||||
}
|
||||
self.assertEqual(test_files, wav2vec2_test_files)
|
||||
|
||||
@@ -528,7 +532,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
bert_files = get_model_files("bert", frameworks=["pt"])
|
||||
|
||||
doc_file = str(Path(bert_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/bert.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/bert.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["model_files"]}
|
||||
bert_model_files = BERT_MODEL_FILES - {
|
||||
@@ -541,15 +545,15 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["test_files"]}
|
||||
bert_test_files = {
|
||||
"tests/test_tokenization_bert.py",
|
||||
"tests/test_modeling_bert.py",
|
||||
"tests/models/bert/test_tokenization_bert.py",
|
||||
"tests/models/bert/test_modeling_bert.py",
|
||||
}
|
||||
self.assertEqual(test_files, bert_test_files)
|
||||
|
||||
# VIT
|
||||
vit_files = get_model_files("vit", frameworks=["pt"])
|
||||
doc_file = str(Path(vit_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/vit.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/vit.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["model_files"]}
|
||||
vit_model_files = VIT_MODEL_FILES - {
|
||||
@@ -562,15 +566,15 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["test_files"]}
|
||||
vit_test_files = {
|
||||
"tests/test_feature_extraction_vit.py",
|
||||
"tests/test_modeling_vit.py",
|
||||
"tests/models/vit/test_feature_extraction_vit.py",
|
||||
"tests/models/vit/test_modeling_vit.py",
|
||||
}
|
||||
self.assertEqual(test_files, vit_test_files)
|
||||
|
||||
# Wav2Vec2
|
||||
wav2vec2_files = get_model_files("wav2vec2", frameworks=["pt"])
|
||||
doc_file = str(Path(wav2vec2_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/wav2vec2.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/wav2vec2.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["model_files"]}
|
||||
wav2vec2_model_files = WAV2VEC2_MODEL_FILES - {
|
||||
@@ -583,10 +587,10 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["test_files"]}
|
||||
wav2vec2_test_files = {
|
||||
"tests/test_feature_extraction_wav2vec2.py",
|
||||
"tests/test_modeling_wav2vec2.py",
|
||||
"tests/test_processor_wav2vec2.py",
|
||||
"tests/test_tokenization_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_feature_extraction_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_processor_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_tokenization_wav2vec2.py",
|
||||
}
|
||||
self.assertEqual(test_files, wav2vec2_test_files)
|
||||
|
||||
@@ -595,7 +599,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
bert_files = get_model_files("bert", frameworks=["tf", "flax"])
|
||||
|
||||
doc_file = str(Path(bert_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/bert.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/bert.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["model_files"]}
|
||||
bert_model_files = BERT_MODEL_FILES - {"src/transformers/models/bert/modeling_bert.py"}
|
||||
@@ -605,16 +609,16 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in bert_files["test_files"]}
|
||||
bert_test_files = {
|
||||
"tests/test_tokenization_bert.py",
|
||||
"tests/test_modeling_tf_bert.py",
|
||||
"tests/test_modeling_flax_bert.py",
|
||||
"tests/models/bert/test_tokenization_bert.py",
|
||||
"tests/models/bert/test_modeling_tf_bert.py",
|
||||
"tests/models/bert/test_modeling_flax_bert.py",
|
||||
}
|
||||
self.assertEqual(test_files, bert_test_files)
|
||||
|
||||
# VIT
|
||||
vit_files = get_model_files("vit", frameworks=["tf", "flax"])
|
||||
doc_file = str(Path(vit_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/vit.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/vit.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["model_files"]}
|
||||
vit_model_files = VIT_MODEL_FILES - {"src/transformers/models/vit/modeling_vit.py"}
|
||||
@@ -624,16 +628,16 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in vit_files["test_files"]}
|
||||
vit_test_files = {
|
||||
"tests/test_feature_extraction_vit.py",
|
||||
"tests/test_modeling_tf_vit.py",
|
||||
"tests/test_modeling_flax_vit.py",
|
||||
"tests/models/vit/test_feature_extraction_vit.py",
|
||||
"tests/models/vit/test_modeling_tf_vit.py",
|
||||
"tests/models/vit/test_modeling_flax_vit.py",
|
||||
}
|
||||
self.assertEqual(test_files, vit_test_files)
|
||||
|
||||
# Wav2Vec2
|
||||
wav2vec2_files = get_model_files("wav2vec2", frameworks=["tf", "flax"])
|
||||
doc_file = str(Path(wav2vec2_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/wav2vec2.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/wav2vec2.mdx")
|
||||
|
||||
model_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["model_files"]}
|
||||
wav2vec2_model_files = WAV2VEC2_MODEL_FILES - {"src/transformers/models/wav2vec2/modeling_wav2vec2.py"}
|
||||
@@ -643,11 +647,11 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in wav2vec2_files["test_files"]}
|
||||
wav2vec2_test_files = {
|
||||
"tests/test_feature_extraction_wav2vec2.py",
|
||||
"tests/test_modeling_tf_wav2vec2.py",
|
||||
"tests/test_modeling_flax_wav2vec2.py",
|
||||
"tests/test_processor_wav2vec2.py",
|
||||
"tests/test_tokenization_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_feature_extraction_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_tf_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_flax_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_processor_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_tokenization_wav2vec2.py",
|
||||
}
|
||||
self.assertEqual(test_files, wav2vec2_test_files)
|
||||
|
||||
@@ -688,7 +692,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
expected_model_classes = {
|
||||
"pt": set(bert_classes),
|
||||
"tf": {f"TF{m}" for m in bert_classes},
|
||||
"flax": {f"Flax{m}" for m in bert_classes[:-1]},
|
||||
"flax": {f"Flax{m}" for m in bert_classes[:-1] + ["BertForCausalLM"]},
|
||||
}
|
||||
|
||||
self.assertEqual(set(bert_info["frameworks"]), {"pt", "tf", "flax"})
|
||||
@@ -701,15 +705,15 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in all_bert_files["test_files"]}
|
||||
bert_test_files = {
|
||||
"tests/test_tokenization_bert.py",
|
||||
"tests/test_modeling_bert.py",
|
||||
"tests/test_modeling_tf_bert.py",
|
||||
"tests/test_modeling_flax_bert.py",
|
||||
"tests/models/bert/test_tokenization_bert.py",
|
||||
"tests/models/bert/test_modeling_bert.py",
|
||||
"tests/models/bert/test_modeling_tf_bert.py",
|
||||
"tests/models/bert/test_modeling_flax_bert.py",
|
||||
}
|
||||
self.assertEqual(test_files, bert_test_files)
|
||||
|
||||
doc_file = str(Path(all_bert_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/bert.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/bert.mdx")
|
||||
|
||||
self.assertEqual(all_bert_files["module_name"], "bert")
|
||||
|
||||
@@ -751,14 +755,14 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in all_bert_files["test_files"]}
|
||||
bert_test_files = {
|
||||
"tests/test_tokenization_bert.py",
|
||||
"tests/test_modeling_bert.py",
|
||||
"tests/test_modeling_tf_bert.py",
|
||||
"tests/models/bert/test_tokenization_bert.py",
|
||||
"tests/models/bert/test_modeling_bert.py",
|
||||
"tests/models/bert/test_modeling_tf_bert.py",
|
||||
}
|
||||
self.assertEqual(test_files, bert_test_files)
|
||||
|
||||
doc_file = str(Path(all_bert_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/bert.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/bert.mdx")
|
||||
|
||||
self.assertEqual(all_bert_files["module_name"], "bert")
|
||||
|
||||
@@ -777,8 +781,9 @@ NEW_BERT_CONSTANT = "value"
|
||||
def test_retrieve_info_for_model_with_vit(self):
|
||||
vit_info = retrieve_info_for_model("vit")
|
||||
vit_classes = ["ViTForImageClassification", "ViTModel"]
|
||||
pt_only_classes = ["ViTForMaskedImageModeling"]
|
||||
expected_model_classes = {
|
||||
"pt": set(vit_classes),
|
||||
"pt": set(vit_classes + pt_only_classes),
|
||||
"tf": {f"TF{m}" for m in vit_classes},
|
||||
"flax": {f"Flax{m}" for m in vit_classes},
|
||||
}
|
||||
@@ -793,27 +798,28 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in all_vit_files["test_files"]}
|
||||
vit_test_files = {
|
||||
"tests/test_feature_extraction_vit.py",
|
||||
"tests/test_modeling_vit.py",
|
||||
"tests/test_modeling_tf_vit.py",
|
||||
"tests/test_modeling_flax_vit.py",
|
||||
"tests/models/vit/test_feature_extraction_vit.py",
|
||||
"tests/models/vit/test_modeling_vit.py",
|
||||
"tests/models/vit/test_modeling_tf_vit.py",
|
||||
"tests/models/vit/test_modeling_flax_vit.py",
|
||||
}
|
||||
self.assertEqual(test_files, vit_test_files)
|
||||
|
||||
doc_file = str(Path(all_vit_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/vit.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/vit.mdx")
|
||||
|
||||
self.assertEqual(all_vit_files["module_name"], "vit")
|
||||
|
||||
vit_model_patterns = vit_info["model_patterns"]
|
||||
self.assertEqual(vit_model_patterns.model_name, "ViT")
|
||||
self.assertEqual(vit_model_patterns.checkpoint, "google/vit-base-patch16-224")
|
||||
self.assertEqual(vit_model_patterns.checkpoint, "google/vit-base-patch16-224-in21k")
|
||||
self.assertEqual(vit_model_patterns.model_type, "vit")
|
||||
self.assertEqual(vit_model_patterns.model_lower_cased, "vit")
|
||||
self.assertEqual(vit_model_patterns.model_camel_cased, "ViT")
|
||||
self.assertEqual(vit_model_patterns.model_upper_cased, "VIT")
|
||||
self.assertEqual(vit_model_patterns.config_class, "ViTConfig")
|
||||
self.assertEqual(vit_model_patterns.feature_extractor_class, "ViTFeatureExtractor")
|
||||
self.assertEqual(vit_model_patterns.image_processor_class, "ViTImageProcessor")
|
||||
self.assertIsNone(vit_model_patterns.tokenizer_class)
|
||||
self.assertIsNone(vit_model_patterns.processor_class)
|
||||
|
||||
@@ -844,17 +850,17 @@ NEW_BERT_CONSTANT = "value"
|
||||
|
||||
test_files = {str(Path(f).relative_to(REPO_PATH)) for f in all_wav2vec2_files["test_files"]}
|
||||
wav2vec2_test_files = {
|
||||
"tests/test_feature_extraction_wav2vec2.py",
|
||||
"tests/test_modeling_wav2vec2.py",
|
||||
"tests/test_modeling_tf_wav2vec2.py",
|
||||
"tests/test_modeling_flax_wav2vec2.py",
|
||||
"tests/test_processor_wav2vec2.py",
|
||||
"tests/test_tokenization_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_feature_extraction_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_tf_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_modeling_flax_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_processor_wav2vec2.py",
|
||||
"tests/models/wav2vec2/test_tokenization_wav2vec2.py",
|
||||
}
|
||||
self.assertEqual(test_files, wav2vec2_test_files)
|
||||
|
||||
doc_file = str(Path(all_wav2vec2_files["doc_file"]).relative_to(REPO_PATH))
|
||||
self.assertEqual(doc_file, "docs/source/model_doc/wav2vec2.mdx")
|
||||
self.assertEqual(doc_file, "docs/source/en/model_doc/wav2vec2.mdx")
|
||||
|
||||
self.assertEqual(all_wav2vec2_files["module_name"], "wav2vec2")
|
||||
|
||||
@@ -881,32 +887,72 @@ _import_structure = {
|
||||
"tokenization_gpt2": ["GPT2Tokenizer"],
|
||||
}
|
||||
|
||||
if is_tokenizers_available():
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_gpt2_fast"] = ["GPT2TokenizerFast"]
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_gpt2"] = ["GPT2Model"]
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_gpt2"] = ["TFGPT2Model"]
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_gpt2"] = ["FlaxGPT2Model"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config, GPT2OnnxConfig
|
||||
from .tokenization_gpt2 import GPT2Tokenizer
|
||||
|
||||
if is_tokenizers_available():
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_gpt2_fast import GPT2TokenizerFast
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_gpt2 import GPT2Model
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_gpt2 import TFGPT2Model
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_gpt2 import FlaxGPT2Model
|
||||
|
||||
else:
|
||||
@@ -924,25 +970,55 @@ _import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
}
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_gpt2"] = ["GPT2Model"]
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_gpt2"] = ["TFGPT2Model"]
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_gpt2"] = ["FlaxGPT2Model"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config, GPT2OnnxConfig
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_gpt2 import GPT2Model
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_gpt2 import TFGPT2Model
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_gpt2 import FlaxGPT2Model
|
||||
|
||||
else:
|
||||
@@ -961,20 +1037,40 @@ _import_structure = {
|
||||
"tokenization_gpt2": ["GPT2Tokenizer"],
|
||||
}
|
||||
|
||||
if is_tokenizers_available():
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["tokenization_gpt2_fast"] = ["GPT2TokenizerFast"]
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_gpt2"] = ["GPT2Model"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config, GPT2OnnxConfig
|
||||
from .tokenization_gpt2 import GPT2Tokenizer
|
||||
|
||||
if is_tokenizers_available():
|
||||
try:
|
||||
if not is_tokenizers_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .tokenization_gpt2_fast import GPT2TokenizerFast
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_gpt2 import GPT2Model
|
||||
|
||||
else:
|
||||
@@ -992,13 +1088,23 @@ _import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
}
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_gpt2"] = ["GPT2Model"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_gpt2 import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP, GPT2Config, GPT2OnnxConfig
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_gpt2 import GPT2Model
|
||||
|
||||
else:
|
||||
@@ -1032,32 +1138,72 @@ _import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
}
|
||||
|
||||
if is_vision_available():
|
||||
_import_structure["feature_extraction_vit"] = ["ViTFeatureExtractor"]
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["image_processing_vit"] = ["ViTImageProcessor"]
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_vit"] = ["ViTModel"]
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_vit"] = ["TFViTModel"]
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_vit"] = ["FlaxViTModel"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig
|
||||
|
||||
if is_vision_available():
|
||||
from .feature_extraction_vit import ViTFeatureExtractor
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .image_processing_vit import ViTImageProcessor
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_vit import ViTModel
|
||||
|
||||
if is_tf_available():
|
||||
from .modeling_tf_vit import ViTModel
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_vit import TFViTModel
|
||||
|
||||
if is_flax_available():
|
||||
from .modeling_flax_vit import ViTModel
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_vit import FlaxViTModel
|
||||
|
||||
else:
|
||||
import sys
|
||||
@@ -1074,26 +1220,56 @@ _import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
}
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_vit"] = ["ViTModel"]
|
||||
|
||||
if is_tf_available():
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_tf_vit"] = ["TFViTModel"]
|
||||
|
||||
if is_flax_available():
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_flax_vit"] = ["FlaxViTModel"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_vit import ViTModel
|
||||
|
||||
if is_tf_available():
|
||||
from .modeling_tf_vit import ViTModel
|
||||
try:
|
||||
if not is_tf_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_tf_vit import TFViTModel
|
||||
|
||||
if is_flax_available():
|
||||
from .modeling_flax_vit import ViTModel
|
||||
try:
|
||||
if not is_flax_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_flax_vit import FlaxViTModel
|
||||
|
||||
else:
|
||||
import sys
|
||||
@@ -1110,19 +1286,39 @@ _import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
}
|
||||
|
||||
if is_vision_available():
|
||||
_import_structure["feature_extraction_vit"] = ["ViTFeatureExtractor"]
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["image_processing_vit"] = ["ViTImageProcessor"]
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_vit"] = ["ViTModel"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig
|
||||
|
||||
if is_vision_available():
|
||||
from .feature_extraction_vit import ViTFeatureExtractor
|
||||
try:
|
||||
if not is_vision_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .image_processing_vit import ViTImageProcessor
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_vit import ViTModel
|
||||
|
||||
else:
|
||||
@@ -1140,13 +1336,23 @@ _import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
}
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
_import_structure["modeling_vit"] = ["ViTModel"]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .configuration_vit import VIT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViTConfig
|
||||
|
||||
if is_torch_available():
|
||||
try:
|
||||
if not is_torch_available():
|
||||
raise OptionalDependencyNotAvailable()
|
||||
except OptionalDependencyNotAvailable:
|
||||
pass
|
||||
else:
|
||||
from .modeling_vit import ViTModel
|
||||
|
||||
else:
|
||||
@@ -1218,7 +1424,7 @@ Overview of the model.
|
||||
|
||||
## Overview
|
||||
|
||||
The GPT-New New model was proposed in [<INSERT PAPER NAME HERE>(<INSERT PAPER LINK HERE>) by <INSERT AUTHORS HERE>.
|
||||
The GPT-New New model was proposed in [<INSERT PAPER NAME HERE>](<INSERT PAPER LINK HERE>) by <INSERT AUTHORS HERE>.
|
||||
<INSERT SHORT SUMMARY HERE>
|
||||
|
||||
The abstract from the paper is the following:
|
||||
@@ -1229,7 +1435,7 @@ Tips:
|
||||
|
||||
<INSERT TIPS ABOUT MODEL HERE>
|
||||
|
||||
This model was contributed by [INSERT YOUR HF USERNAME HERE](<https://huggingface.co/<INSERT YOUR HF USERNAME HERE>).
|
||||
This model was contributed by [INSERT YOUR HF USERNAME HERE](https://huggingface.co/<INSERT YOUR HF USERNAME HERE>).
|
||||
The original code can be found [here](<INSERT LINK TO GITHUB REPO HERE>).
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user