Fix slow backbone tests - out_indices must match stage name ordering (#28186)

Indices must match stage name ordering
This commit is contained in:
amyeroberts
2023-12-21 18:16:50 +00:00
committed by GitHub
parent 260b9d2179
commit cd1350ce9b

View File

@@ -244,8 +244,8 @@ class AutoModelTest(unittest.TestCase):
self.assertIsInstance(model, TimmBackbone)
# Check kwargs are correctly passed to the backbone
model = AutoBackbone.from_pretrained("resnet18", use_timm_backbone=True, out_indices=(-1, -2))
self.assertEqual(model.out_indices, (-1, -2))
model = AutoBackbone.from_pretrained("resnet18", use_timm_backbone=True, out_indices=(-2, -1))
self.assertEqual(model.out_indices, (-2, -1))
# Check out_features cannot be passed to Timm backbones
with self.assertRaises(ValueError):
@@ -259,9 +259,9 @@ class AutoModelTest(unittest.TestCase):
self.assertIsInstance(model, ResNetBackbone)
# Check kwargs are correctly passed to the backbone
model = AutoBackbone.from_pretrained("microsoft/resnet-18", out_indices=[-1, -2])
self.assertEqual(model.out_indices, [-1, -2])
self.assertEqual(model.out_features, ["stage4", "stage3"])
model = AutoBackbone.from_pretrained("microsoft/resnet-18", out_indices=[-2, -1])
self.assertEqual(model.out_indices, [-2, -1])
self.assertEqual(model.out_features, ["stage3", "stage4"])
model = AutoBackbone.from_pretrained("microsoft/resnet-18", out_features=["stage2", "stage4"])
self.assertEqual(model.out_indices, [2, 4])