Raise unused kwargs image processor
What does this PR do?
This PR captures all kwargs passed to an ImageProcessor preprocess method and compares them to what's expected, raising an exception or logging an informative message when a difference is found.
This will
- Make preprocess methods more reliable
- Inform users when an expected kwargs has no actual impact in the preprocessing
- [x] Did you write any new necessary tests?
Who can review?
- vision models: @amyeroberts
Finishing up draft, removing this validation functionality from #28711
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.
Main concern I had was using inspect, so I moved it to the test suite instead of the actual validation function. That way we don't inspect at runtime, we just compare static lists. For new model additions, self._valid_processor_keys remain optional (if it's not there, nothing is run) but it'd be a recommendation.
As to what the validation raises, for now it's a logger.info, could be a warning instead but should not raise an exception as a good chunk of existing models /processors from the hub would break down