transformers icon indicating copy to clipboard operation
transformers copied to clipboard

Raise unused kwargs image processor

Open molbap opened this issue 1 year ago • 3 comments

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

  1. Make preprocess methods more reliable
  2. 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

molbap avatar Feb 16 '24 15:02 molbap

Finishing up draft, removing this validation functionality from #28711

molbap avatar Feb 16 '24 15:02 molbap

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

molbap avatar Feb 16 '24 16:02 molbap