Remove static pretrained maps from the library's internals (#29112)
* [test_all] Remove static pretrained maps from the library's internals * Deprecate archive maps instead of removing them * Revert init changes * [test_all] Deprecate instead of removing * [test_all] PVT v2 support * [test_all] Tests should all pass * [test_all] Style * Address review comments * Update src/transformers/models/deprecated/_archive_maps.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> * Update src/transformers/models/deprecated/_archive_maps.py Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com> * [test_all] trigger tests * [test_all] LLAVA * [test_all] Bad rebase --------- Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
This commit is contained in:
@@ -48,7 +48,6 @@ if is_torch_available():
|
||||
from torch import nn
|
||||
|
||||
from transformers import SiglipForImageClassification, SiglipModel, SiglipTextModel, SiglipVisionModel
|
||||
from transformers.models.siglip.modeling_siglip import SIGLIP_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -217,9 +216,9 @@ class SiglipVisionModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in SIGLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = SiglipVisionModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/siglip-base-patch16-224"
|
||||
model = SiglipVisionModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
class SiglipTextModelTester:
|
||||
@@ -374,9 +373,9 @@ class SiglipTextModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in SIGLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = SiglipTextModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/siglip-base-patch16-224"
|
||||
model = SiglipTextModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
class SiglipModelTester:
|
||||
@@ -578,11 +577,10 @@ class SiglipModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
self.assertDictEqual(config.text_config.to_dict(), text_config.to_dict())
|
||||
|
||||
@slow
|
||||
# Copied from tests.models.clip.test_modeling_clip.CLIPModelTest.test_model_from_pretrained with CLIPModel->SiglipModel, CLIP->SIGLIP
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in SIGLIP_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = SiglipModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/siglip-base-patch16-224"
|
||||
model = SiglipModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
class SiglipForImageClassificationModelTester(SiglipModelTester):
|
||||
|
||||
@@ -348,14 +348,6 @@ class SiglipTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
|
||||
special_tokens_string_rust = rust_tokenizer.convert_tokens_to_string(special_tokens)
|
||||
self.assertEqual(special_tokens_string, special_tokens_string_rust)
|
||||
|
||||
# overwritten from `test_tokenization_common` since Siglip has no max length
|
||||
# Copied from tests.models.t5.test_tokenization_t5.T5TokenizationTest.test_pretrained_model_lists with T5->Siglip
|
||||
def test_pretrained_model_lists(self):
|
||||
# We should have at least one default checkpoint for each tokenizer
|
||||
# We should specify the max input length as well (used in some part to list the pretrained checkpoints)
|
||||
self.assertGreaterEqual(len(self.tokenizer_class.pretrained_vocab_files_map), 1)
|
||||
self.assertGreaterEqual(len(list(self.tokenizer_class.pretrained_vocab_files_map.values())[0]), 1)
|
||||
|
||||
@slow
|
||||
def test_tokenizer_integration(self):
|
||||
tokenizer = SiglipTokenizer.from_pretrained("google/siglip-base-patch16-224")
|
||||
|
||||
Reference in New Issue
Block a user