transformers/tests/utils
amyeroberts 49e44b216b
Update feature extractor methods to enable type cast before normalize (#18499)
* Update methods to optionally rescale
This is necessary to allow for casting our images / videos to numpy arrays within the feature extractors' call. We want to do this to make sure the behaviour is as expected when flags like  are False. If some transformations aren't applied, then the output type can't be unexpected e.g. a list of PIL images instead of numpy arrays.

* Cast images to numpy arrays in call to enable consistent behaviour with different configs

* Remove accidental clip changes

* Update tests to reflect the scaling logic
We write a generic  function to handle rescaling of our arrays. In order for the API to be intuitive, we take some factor c and rescale the image values by that. This means, the rescaling done in normalize and to_numpy_array are now done with array * (1/255) instead of array / 255. This leads to small differences in the resulting image. When testing, this was in the order of 1e-8, and so deemed OK
2022-08-17 19:57:07 +01:00
..
__init__.py [Test refactor 1/5] Per-folder tests reorganization (#15725) 2022-02-23 15:46:28 -05:00
test_activations_tf.py TF: Add sigmoid activation function (#16819) 2022-04-19 16:13:08 +01:00
test_activations.py TF: Add sigmoid activation function (#16819) 2022-04-19 16:13:08 +01:00
test_add_new_model_like.py Reorganize file utils (#16264) 2022-03-23 10:26:33 -04:00
test_cli.py CLI: reenable pt_to_tf test (#18108) 2022-07-12 13:38:05 +01:00
test_convert_slow_tokenizer.py Black preview (#17217) 2022-05-12 16:25:55 -04:00
test_doc_samples.py [Test refactor 1/5] Per-folder tests reorganization (#15725) 2022-02-23 15:46:28 -05:00
test_file_utils.py Clean up hub (#18497) 2022-08-08 08:48:10 -04:00
test_generic.py Add MLFLOW_FLATTEN_PARAMS support in MLflowCallback (#17148) 2022-05-10 14:29:18 -04:00
test_hf_argparser.py Support PEP 563 for HfArgumentParser (#15795) 2022-03-17 13:51:37 -04:00
test_image_utils.py Update feature extractor methods to enable type cast before normalize (#18499) 2022-08-17 19:57:07 +01:00
test_logging.py [Test refactor 1/5] Per-folder tests reorganization (#15725) 2022-02-23 15:46:28 -05:00
test_model_card.py Black preview (#17217) 2022-05-12 16:25:55 -04:00
test_model_output.py Reorganize file utils (#16264) 2022-03-23 10:26:33 -04:00
test_modeling_tf_core.py Update serving code to enable saved_model=True (#18153) 2022-07-22 18:05:38 +01:00
test_offline.py Make sharded checkpoints work in offline mode (#18125) 2022-07-13 12:43:08 -04:00
test_skip_decorators.py [Test refactor 1/5] Per-folder tests reorganization (#15725) 2022-02-23 15:46:28 -05:00
test_utils_check_copies.py Black preview (#17217) 2022-05-12 16:25:55 -04:00
test_versions_utils.py [Test refactor 1/5] Per-folder tests reorganization (#15725) 2022-02-23 15:46:28 -05:00