From 924f1c717a72261a4b9286a31f199d9512448dd0 Mon Sep 17 00:00:00 2001 From: Yoni Gozlan <74535834+yonigozlan@users.noreply.github.com> Date: Mon, 10 Feb 2025 07:59:34 -0500 Subject: [PATCH] Remove Multi-threaded image conversion for fast image processors (#36105) remove multithreaded image conversion Co-authored-by: Marc Sun <57196510+SunMarc@users.noreply.github.com> --- src/transformers/image_processing_utils_fast.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/transformers/image_processing_utils_fast.py b/src/transformers/image_processing_utils_fast.py index d21d352121..f990ce100d 100644 --- a/src/transformers/image_processing_utils_fast.py +++ b/src/transformers/image_processing_utils_fast.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from concurrent.futures import ThreadPoolExecutor from functools import lru_cache, partial from typing import Any, Dict, Iterable, List, Optional, Tuple, TypedDict, Union @@ -497,8 +496,10 @@ class BaseImageProcessorFast(BaseImageProcessor): input_data_format=input_data_format, device=device, ) - with ThreadPoolExecutor() as executor: - processed_images = list(executor.map(process_image_fn, images)) + # todo: yoni - check if we can parallelize this efficiently + processed_images = [] + for image in images: + processed_images.append(process_image_fn(image)) return processed_images