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:
@@ -32,7 +32,6 @@ if is_torch_available():
|
||||
from torch import nn
|
||||
|
||||
from transformers import ResNetBackbone, ResNetForImageClassification, ResNetModel
|
||||
from transformers.models.resnet.modeling_resnet import RESNET_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -273,9 +272,9 @@ class ResNetModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = ResNetModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "microsoft/resnet-50"
|
||||
model = ResNetModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
# We will verify our results on an image of cute cats
|
||||
@@ -289,15 +288,11 @@ def prepare_img():
|
||||
class ResNetModelIntegrationTest(unittest.TestCase):
|
||||
@cached_property
|
||||
def default_image_processor(self):
|
||||
return (
|
||||
AutoImageProcessor.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0])
|
||||
if is_vision_available()
|
||||
else None
|
||||
)
|
||||
return AutoImageProcessor.from_pretrained("microsoft/resnet-50") if is_vision_available() else None
|
||||
|
||||
@slow
|
||||
def test_inference_image_classification_head(self):
|
||||
model = ResNetForImageClassification.from_pretrained(RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0]).to(torch_device)
|
||||
model = ResNetForImageClassification.from_pretrained("microsoft/resnet-50").to(torch_device)
|
||||
|
||||
image_processor = self.default_image_processor
|
||||
image = prepare_img()
|
||||
|
||||
@@ -35,7 +35,6 @@ if is_tf_available():
|
||||
import tensorflow as tf
|
||||
|
||||
from transformers import TFResNetForImageClassification, TFResNetModel
|
||||
from transformers.models.resnet.modeling_tf_resnet import TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
@@ -214,9 +213,9 @@ class TFResNetModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCa
|
||||
|
||||
@slow
|
||||
def test_model_from_pretrained(self):
|
||||
for model_name in TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
|
||||
model = TFResNetModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
model_name = "microsoft/resnet-50"
|
||||
model = TFResNetModel.from_pretrained(model_name)
|
||||
self.assertIsNotNone(model)
|
||||
|
||||
|
||||
# We will verify our results on an image of cute cats
|
||||
@@ -230,15 +229,11 @@ def prepare_img():
|
||||
class TFResNetModelIntegrationTest(unittest.TestCase):
|
||||
@cached_property
|
||||
def default_image_processor(self):
|
||||
return (
|
||||
AutoImageProcessor.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0])
|
||||
if is_vision_available()
|
||||
else None
|
||||
)
|
||||
return AutoImageProcessor.from_pretrained("microsoft/resnet-50") if is_vision_available() else None
|
||||
|
||||
@slow
|
||||
def test_inference_image_classification_head(self):
|
||||
model = TFResNetForImageClassification.from_pretrained(TF_RESNET_PRETRAINED_MODEL_ARCHIVE_LIST[0])
|
||||
model = TFResNetForImageClassification.from_pretrained("microsoft/resnet-50")
|
||||
|
||||
image_processor = self.default_image_processor
|
||||
image = prepare_img()
|
||||
|
||||
Reference in New Issue
Block a user