transformers
8f2f7376 - Factor shared preprocessor save/load logic into PreprocessingMixin

Commit
3 days ago
Factor shared preprocessor save/load logic into PreprocessingMixin `ImageProcessingMixin` and `FeatureExtractionMixin` carried two near-identical copies of the same machinery: `BatchFeature`, config resolution against the hub, `from_pretrained`/`save_pretrained`, `to_dict` filtering and the auto-class registration helpers. Hoist all of it into a new `preprocessing_base.PreprocessingMixin`, with the per-modality differences expressed as class attributes (`_config_name`, `_type_key`, `_nested_config_keys`, `_auto_class_default`, `_file_type_label`, `_excluded_dict_keys`, `_filter_none_class_defaults`, `_extra_init_pops`, `_config_filename_kwarg`, `_subfolder_default`) plus a small set of hooks (`_standardize_kwargs`, `_validate_preprocess_kwargs`, `_preprocess_like_inputs`, `_serialize_value`, `_keep_in_dict`). Every hook already had an image-side override, so this is a factorization of existing behavior rather than new API. `BatchFeature` now lives in `preprocessing_base` and is re-exported unchanged from both `feature_extraction_utils` and `image_processing_base`, so existing import paths keep working and the class stays a single object identity. Also folds `BaseImageProcessor._set_attributes`, the validate/setdefault/ standardize preamble of `BaseImageProcessor.preprocess`, and its bespoke `to_dict` None-filtering into the shared base. No behavior change intended; no audio code involved.
Author
Committer
Parents
Loading