Skip to content

Commit d4b7ed8

Browse files
committed
Update on "Add preprocess to ci"
1. Run `test_preprocess.py` in ci. 2. Refactor `test_preprocess.py` by creating the model artifacts (eager, exported, et) once and then re-using them on different inputs. Test Plan: ``` python -m unittest examples.models.llama3_2_vision.preprocess.test_preprocess ``` [ghstack-poisoned]
1 parent 7a752e0 commit d4b7ed8

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/models/llama3_2_vision/preprocess/test_preprocess.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class TestImageTransform(unittest.TestCase):
5252
https://github.com/pytorch/torchtune/blob/main/torchtune/models/clip/inference/_transforms.py#L26
5353
"""
5454

55-
def initialize_models(self, resize_to_max_canvas: bool) -> Dict[str, Any]:
55+
@staticmethod
56+
def initialize_models(resize_to_max_canvas: bool) -> Dict[str, Any]:
5657
config = PreprocessConfig(resize_to_max_canvas=resize_to_max_canvas)
5758

5859
reference_model = CLIPImageTransform(
@@ -96,8 +97,12 @@ def initialize_models(self, resize_to_max_canvas: bool) -> Dict[str, Any]:
9697

9798
@classmethod
9899
def setUpClass(cls):
99-
cls.models_no_resize = cls.initialize_models(resize_to_max_canvas=False)
100-
cls.models_resize = cls.initialize_models(resize_to_max_canvas=True)
100+
cls.models_no_resize = TestImageTransform.initialize_models(
101+
resize_to_max_canvas=False
102+
)
103+
cls.models_resize = TestImageTransform.initialize_models(
104+
resize_to_max_canvas=True
105+
)
101106

102107
def setUp(self):
103108
np.random.seed(0)

0 commit comments

Comments
 (0)