1

I am learning to use AI and am utilizing Colab, Python, and Google Cloud. I am able to successfully generate images with the following code:

Setup:

!pip install --quiet --upgrade --user google-cloud-aiplatform

import IPython import time

app = IPython.Application.instance() app.kernel.do_shutdown(True) from google.colab import auth auth.authenticate_user()

import vertexai vertexai.init(project="$PROJECT_ID", location = "us-central1") from vertexai.preview.vision_models import ImageGenerationModel model = ImageGenerationModel.from_pretrained("imagegeneration@005") !pip install --upgrade watermark


Working generation code:

response = model.generate_images( prompt = '''A flower.''', number_of_images = 2 )


The issue is when I try and use a seed:

model.watermark_enabled = False response = model.generate_images( prompt = '''A flower.''', number_of_images = 2, seed = 42 )

I recieve this:

 

    _InactiveRpcError                         Traceback (most recent call last)
    /usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
         71         try:
    ---> 72             return callable_(*args, **kwargs)
         73         except grpc.RpcError as exc:
    
    8 frames
    _InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Image generation failed with the following error: Seed is not supported when watermark is enabled."
        debug_error_string = "UNKNOWN:Error received from peer ipv4:142.250.141.95:443 {created_time:"2024-05-23T14:53:50.497705026+00:00", grpc_status:3, grpc_message:"Image generation failed with the following error: Seed is not supported when watermark is enabled."}"
    >
    
    The above exception was the direct cause of the following exception:
    
    InvalidArgument                           Traceback (most recent call last)
    /usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
         72             return callable_(*args, **kwargs)
         73         except grpc.RpcError as exc:
    ---> 74             raise exceptions.from_grpc_error(exc) from exc
         75 
         76     return error_remapped_callable
    
    InvalidArgument: 400 Image generation failed with the following error: Seed is not supported when watermark is enabled.

[Error report](https://i.sstatic.net/mZ0FbeDs.png)


When the error first occured I added this:

model.watermark_enabled = False


When it didn't work, i did the opposite:

model.watermark_enabled = True

When that failed I ran this and went through the two options above:

!pip install --upgrade watermark

1 Answer 1

1

I got the same error and found an add_watermark=False as a parameter of the generate_images.

response = model.generate_images(
    prompt = '''A flower.''',
    number_of_images = 2,
    seed = 42,
    add_watermark=False,
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.