[Transformers v5] fix missing pixtral/voxtral multimodal dispatch (#38410)
Signed-off-by: allgather <all2allops@gmail.com>
This commit is contained in:
@@ -50,16 +50,18 @@ class MistralCommonImageProcessor:
|
||||
class MistralCommonPixtralProcessor(ProcessorMixin):
|
||||
attributes = ["image_processor", "tokenizer"]
|
||||
|
||||
def __init__(self, tokenizer: MistralTokenizer) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
tokenizer: MistralTokenizer,
|
||||
image_processor: MistralCommonImageProcessor,
|
||||
) -> None:
|
||||
self.tokenizer = tokenizer.transformers_tokenizer
|
||||
|
||||
# Back-compatibility for Transformers v4
|
||||
if not hasattr(self.tokenizer, "init_kwargs"):
|
||||
self.tokenizer.init_kwargs = {}
|
||||
|
||||
self.image_processor = MistralCommonImageProcessor(
|
||||
tokenizer.instruct.mm_encoder
|
||||
)
|
||||
self.image_processor = image_processor
|
||||
|
||||
image_special_ids = self.image_processor.mm_encoder.special_ids
|
||||
self.image_break_id = image_special_ids.img_break
|
||||
|
||||
@@ -57,16 +57,18 @@ class MistralCommonFeatureExtractor:
|
||||
class MistralCommonVoxtralProcessor(ProcessorMixin):
|
||||
attributes = ["feature_extractor", "tokenizer"]
|
||||
|
||||
def __init__(self, tokenizer: MistralTokenizer) -> None:
|
||||
def __init__(
|
||||
self,
|
||||
tokenizer: MistralTokenizer,
|
||||
feature_extractor: MistralCommonFeatureExtractor,
|
||||
) -> None:
|
||||
self.tokenizer = tokenizer.transformers_tokenizer
|
||||
|
||||
# Back-compatibility for Transformers v4
|
||||
if not hasattr(self.tokenizer, "init_kwargs"):
|
||||
self.tokenizer.init_kwargs = {}
|
||||
|
||||
self.feature_extractor = MistralCommonFeatureExtractor(
|
||||
tokenizer.instruct.audio_encoder
|
||||
)
|
||||
self.feature_extractor = feature_extractor
|
||||
|
||||
audio_special_ids = self.feature_extractor.audio_encoder.special_ids
|
||||
self.audio_token_id = audio_special_ids.audio
|
||||
|
||||
Reference in New Issue
Block a user