diff --git a/src/transformers/pipelines/image_text_to_text.py b/src/transformers/pipelines/image_text_to_text.py index 6937b63ae6a8b4..f2a10208345768 100644 --- a/src/transformers/pipelines/image_text_to_text.py +++ b/src/transformers/pipelines/image_text_to_text.py @@ -208,14 +208,6 @@ def _sanitize_parameters( " please use only one" ) forward_kwargs["generate_kwargs"]["max_new_tokens"] = max_new_tokens - else: - if "generate_kwargs" not in forward_kwargs: - forward_kwargs["generate_kwargs"] = {} - if "max_new_tokens" not in forward_kwargs["generate_kwargs"]: - logger.warning_once( - "The `max_new_tokens` parameter is not set. By default, the model will generate up to 20 tokens." - ) - forward_kwargs["generate_kwargs"]["max_new_tokens"] = 20 if return_full_text is not None and return_type is None: if return_tensors is not None: diff --git a/tests/pipelines/test_pipelines_image_text_to_text.py b/tests/pipelines/test_pipelines_image_text_to_text.py index 9ededa28d20f94..d7f7c74bf3b061 100644 --- a/tests/pipelines/test_pipelines_image_text_to_text.py +++ b/tests/pipelines/test_pipelines_image_text_to_text.py @@ -71,7 +71,7 @@ def test_small_model_pt_token(self): image = "./tests/fixtures/tests_samples/COCO/000000039769.png" text = " What this is? Assistant: This is" - outputs = pipe(image, text=text, max_new_tokens=20) + outputs = pipe(image, text=text) self.assertEqual( outputs, [ @@ -82,7 +82,7 @@ def test_small_model_pt_token(self): ], ) - outputs = pipe([image, image], text=[text, text], max_new_tokens=20) + outputs = pipe([image, image], text=[text, text]) self.assertEqual( outputs, [ @@ -103,8 +103,8 @@ def test_consistent_batching_behaviour(self): image = "./tests/fixtures/tests_samples/COCO/000000039769.png" prompt = "a photo of" - outputs = pipe([image, image], text=[prompt, prompt], max_new_tokens=20) - outputs_batched = pipe([image, image], text=[prompt, prompt], max_new_tokens=20, batch_size=2) + outputs = pipe([image, image], text=[prompt, prompt]) + outputs_batched = pipe([image, image], text=[prompt, prompt], batch_size=2) self.assertEqual(outputs, outputs_batched) @slow @@ -123,7 +123,7 @@ def test_model_pt_chat_template(self): ], } ] - outputs = pipe([image_ny, image_chicago], text=messages, max_new_tokens=20) + outputs = pipe([image_ny, image_chicago], text=messages) self.assertEqual( outputs, [ @@ -178,7 +178,7 @@ def test_model_pt_chat_template_continue_final_message(self): ], }, ] - outputs = pipe(text=messages, max_new_tokens=20) + outputs = pipe(text=messages) self.assertEqual( outputs, [ @@ -237,7 +237,7 @@ def test_model_pt_chat_template_new_text(self): ], } ] - outputs = pipe(text=messages, max_new_tokens=20, return_full_text=False) + outputs = pipe(text=messages, return_full_text=False) self.assertEqual( outputs, [