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:
@@ -50,7 +50,6 @@ if is_torch_available():
|
||||
from torch import nn
|
||||
|
||||
from transformers import Owlv2ForObjectDetection, Owlv2Model, Owlv2TextModel, Owlv2VisionModel
|
||||
from transformers.models.owlv2.modeling_owlv2 import OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -138,7 +137,7 @@ class Owlv2VisionModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTVisionModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTVisionModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2, owlvit-base-patch32->owlv2-base-patch16-ensemble
|
||||
class Owlv2VisionModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
"""
|
||||
Here we also overwrite some of the tests of test_modeling_common.py, as OWLV2 does not use input_ids, inputs_embeds,
|
||||
@@ -219,9 +218,9 @@ class Owlv2VisionModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = Owlv2VisionModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/owlv2-base-patch16-ensemble"
|
||||
model = Owlv2VisionModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTTextModelTester with OwlViT->Owlv2
|
||||
@@ -315,7 +314,7 @@ class Owlv2TextModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTTextModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTTextModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2, owlvit-base-patch32->owlv2-base-patch16-ensemble
|
||||
class Owlv2TextModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Owlv2TextModel,) if is_torch_available() else ()
|
||||
fx_compatible = False
|
||||
@@ -367,9 +366,9 @@ class Owlv2TextModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = Owlv2TextModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/owlv2-base-patch16-ensemble"
|
||||
model = Owlv2TextModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
class Owlv2ModelTester:
|
||||
@@ -430,7 +429,7 @@ class Owlv2ModelTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTModelTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2, owlvit-base-patch32->owlv2-base-patch16-ensemble
|
||||
class Owlv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Owlv2Model,) if is_torch_available() else ()
|
||||
pipeline_model_mapping = (
|
||||
@@ -578,9 +577,9 @@ class Owlv2ModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = Owlv2Model.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/owlv2-base-patch16-ensemble"
|
||||
model = Owlv2Model.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTForObjectDetectionTester with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2
|
||||
@@ -644,7 +643,7 @@ class Owlv2ForObjectDetectionTester:
|
||||
|
||||
|
||||
@require_torch
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTForObjectDetectionTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2
|
||||
# Copied from tests.models.owlvit.test_modeling_owlvit.OwlViTForObjectDetectionTest with OwlViT->Owlv2, OWL-ViT->OwlV2, OWLVIT->OWLV2, owlvit-base-patch32->owlv2-base-patch16-ensemble
|
||||
class Owlv2ForObjectDetectionTest(ModelTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (Owlv2ForObjectDetection,) if is_torch_available() else ()
|
||||
fx_compatible = False
|
||||
@@ -777,9 +776,9 @@ class Owlv2ForObjectDetectionTest(ModelTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in OWLV2_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = Owlv2ForObjectDetection.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "google/owlv2-base-patch16-ensemble"
|
||||
model = Owlv2ForObjectDetection.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
# We will verify our results on an image of cute cats
|
||||
|
||||
Reference in New Issue
Block a user