Skip to content

Commit 0aad52e

Browse files
yonigozlanBernardZach
authored andcommitted
Ignore unsupported kwarg in ProcessorMixin call (huggingface#34285)
Fix accept any common kwargs
1 parent 746df7b commit 0aad52e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/transformers/processing_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,11 @@ class MyProcessingKwargs(ProcessingKwargs, CommonKwargs, TextKwargs, ImagesKwarg
874874
else:
875875
# kwargs is a flat dictionary
876876
for key in kwargs:
877-
if key not in used_keys:
877+
if key not in ModelProcessorKwargs.__annotations__["common_kwargs"].__annotations__.keys():
878+
logger.warning_once(
879+
f"Keyword argument `{key}` is not a valid argument for this processor and will be ignored."
880+
)
881+
elif key not in used_keys:
878882
output_kwargs["common_kwargs"][key] = kwargs[key]
879883

880884
# all modality-specific kwargs are updated with common kwargs

0 commit comments

Comments
 (0)