Open eridiumeng opened 2 months ago
+1 same issue even with a single image. Generation works fine through the Studio though for the same Imagegeneration@006 model, even for 4 images.
Based on the log output, you're running this on either Cloud Run or Cloud Functions. The default resources on these services will be less than a dedicated environment like (presumably from johanpicard's comment) Vertex AI Studio
You may need to increase either the CPU or memory in order to ensure the computation completes before the deadline.
eridumeng is however, as I am, calling the Vertex AI API which is timing out here, with no ties to the client's configuration which is just waiting idly ?
After further troubleshooting, I realized that the issue was coming from the "output_gcs_uri" parameter which is supposed to output the generated images to GCS - very handy on paper. Very fast without, hangs and then "Deadline" when included however.
I fixed it by not using it, generating the images, then grabbing the GeneratedImage elements and wrote them myself to GCS using the following code :
` images = model.generate_images( prompt=prompt, number_of_images=config.IMAGE_COUNT, language="en", aspect_ratio="1:1", safety_filter_level="block_some",
)
storage_client = storage.Client()
bucket = storage_client.bucket(config.BUCKET_NAME)
if images:
images_urls = []
clean_concept = concept.replace(" ", "_") # Replace spaces with underscores
# Process each generated image
for i, generated_image in enumerate(images):
# Create a blob in the concept-specific folder
blob_name = f"{clean_concept}/{clean_concept}_{i}.png"
blob = bucket.blob(blob_name)
# Upload the generated image content
blob.upload_from_string(generated_image._image_bytes)
# Store the GCS URL
image_url = f"gs://{bucket_name}/{blob_name}"
image_urls.append(image_url)
return image_urls
else:
return []`
Example code:
Log output