Skip to content

Commit

Permalink
Fix add-new-model-like (huggingface#31773)
Browse files Browse the repository at this point in the history
* handle (processor_class, None) returned by ModelPatterns

* handle (slow, fast) image processors in add model

* handle old image processor case
  • Loading branch information
molbap authored Aug 8, 2024
1 parent d3b3551 commit b51d414
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/transformers/commands/add_new_model_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,12 @@ def retrieve_info_for_model(model_type, frameworks: Optional[List[str]] = None):
tokenizer_class = tokenizer_classes[0] if tokenizer_classes[0] is not None else tokenizer_classes[1]
else:
tokenizer_class = None
image_processor_class = auto_module.image_processing_auto.IMAGE_PROCESSOR_MAPPING_NAMES.get(model_type, None)
image_processor_classes = auto_module.image_processing_auto.IMAGE_PROCESSOR_MAPPING_NAMES.get(model_type, None)
if isinstance(image_processor_classes, tuple):
image_processor_class = image_processor_classes[0] # we take the slow image processor class.
else:
image_processor_class = image_processor_classes

feature_extractor_class = auto_module.feature_extraction_auto.FEATURE_EXTRACTOR_MAPPING_NAMES.get(model_type, None)
processor_class = auto_module.processing_auto.PROCESSOR_MAPPING_NAMES.get(model_type, None)

Expand Down

0 comments on commit b51d414

Please sign in to comment.