Content-Length: 309262 | pFad | https://github.com/googleapis/python-aiplatform/commit/cbe3a0de14a2ee189df07f445545f68fa4bdd4ae

D5 fix: LVM - Fixed negative prompt in `ImageGenerationModel` · googleapis/python-aiplatform@cbe3a0d · GitHub
Skip to content

Commit cbe3a0d

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: LVM - Fixed negative prompt in ImageGenerationModel
PiperOrigin-RevId: 574652096
1 parent d9ced10 commit cbe3a0d

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

tests/unit/aiplatform/test_vision_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def test_generate_images(self):
251251
actual_parameters = predict_kwargs["parameters"]
252252
actual_instance = predict_kwargs["instances"][0]
253253
assert actual_instance["prompt"] == prompt1
254-
assert actual_instance["negativePrompt"] == negative_prompt1
254+
assert actual_parameters["negativePrompt"] == negative_prompt1
255255
# TODO(b/295946075) The service stopped supporting image sizes.
256256
# assert actual_parameters["sampleImageSize"] == str(max(width, height))
257257
# assert actual_parameters["aspectRatio"] == f"{width}:{height}"

vertexai/vision_models/_vision_models.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ def _generate_images(
174174
"number_of_images_in_batch": number_of_images,
175175
}
176176

177-
if negative_prompt:
178-
instance["negativePrompt"] = negative_prompt
179-
shared_generation_parameters["negative_prompt"] = negative_prompt
180-
181177
if base_image:
182178
base_image_base64 = (
183179
base_image._as_base64_string()
@@ -207,6 +203,9 @@ def _generate_images(
207203
parameters["aspectRatio"] = f"{width}:{height}"
208204

209205
parameters["sampleCount"] = number_of_images
206+
if negative_prompt:
207+
parameters["negativePrompt"] = negative_prompt
208+
shared_generation_parameters["negative_prompt"] = negative_prompt
210209

211210
if seed is not None:
212211
# Note: String seed and numerical seed give different results

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/googleapis/python-aiplatform/commit/cbe3a0de14a2ee189df07f445545f68fa4bdd4ae

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy