🚨 🚨 Setup -> setupclass conversion (#37282)
* More limited setup -> setupclass conversion * make fixup * Trigger tests * Fixup UDOP * Missed a spot * tearDown -> tearDownClass where appropriate * Couple more class fixes * Fixups for UDOP and VisionTextDualEncoder * Ignore errors when removing the tmpdir, in case it already got cleaned up somewhere * CLIP fixes * More correct classmethods * Wav2Vec2Bert fixes * More methods become static * More class methods * More class methods * Revert changes for integration tests / modeling files * Use a different tempdir for tests that actually write to it * Remove addClassCleanup and just use teardownclass * Remove changes in modeling files * Cleanup get_processor_dict() for got_ocr2 * Fix regression on Wav2Vec2BERT test that was masked by this before * Rework tests that modify the tmpdir * make fix-copies * revert clvp modeling test changes * Fix CLIP processor test * make fix-copies
This commit is contained in:
@@ -36,21 +36,23 @@ if is_vision_available():
|
||||
class MllamaProcessorTest(ProcessorTesterMixin, unittest.TestCase):
|
||||
processor_class = MllamaProcessor
|
||||
|
||||
def setUp(self):
|
||||
self.checkpoint = "hf-internal-testing/mllama-11b"
|
||||
processor = MllamaProcessor.from_pretrained(self.checkpoint)
|
||||
self.image1 = Image.new("RGB", (224, 220))
|
||||
self.image2 = Image.new("RGB", (512, 128))
|
||||
self.image_token = processor.image_token
|
||||
self.image_token_id = processor.image_token_id
|
||||
self.pad_token_id = processor.tokenizer.pad_token_id
|
||||
self.bos_token = processor.bos_token
|
||||
self.bos_token_id = processor.tokenizer.bos_token_id
|
||||
self.tmpdirname = tempfile.mkdtemp()
|
||||
processor.save_pretrained(self.tmpdirname)
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.checkpoint = "hf-internal-testing/mllama-11b"
|
||||
processor = MllamaProcessor.from_pretrained(cls.checkpoint)
|
||||
cls.image1 = Image.new("RGB", (224, 220))
|
||||
cls.image2 = Image.new("RGB", (512, 128))
|
||||
cls.image_token = processor.image_token
|
||||
cls.image_token_id = processor.image_token_id
|
||||
cls.pad_token_id = processor.tokenizer.pad_token_id
|
||||
cls.bos_token = processor.bos_token
|
||||
cls.bos_token_id = processor.tokenizer.bos_token_id
|
||||
cls.tmpdirname = tempfile.mkdtemp()
|
||||
processor.save_pretrained(cls.tmpdirname)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tmpdirname)
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.tmpdirname, ignore_errors=True)
|
||||
|
||||
def prepare_processor_dict(self):
|
||||
return {"chat_template": "{% for message in messages %}{% if loop.index0 == 0 %}{{ bos_token }}{% endif %}{{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' }}{% if message['content'] is string %}{{ message['content'] }}{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' %}{{ '<|image|>' }}{% elif content['type'] == 'text' %}{{ content['text'] }}{% endif %}{% endfor %}{% endif %}{{ '<|eot_id|>' }}{% endfor %}{% if add_generation_prompt %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}{% endif %}"} # fmt: skip
|
||||
|
||||
Reference in New Issue
Block a user