Amazon is looking to improve its generative AI capabilities by bringing Titan Image Generator and Watermark Detection API on Bedrock. How powerful and efficient are these tools and what features do they come with? Let’s explore!
Highlights:
- Amazon now offers its Titan Image Generator with Watermark Detection API on their Bedrock platform.
- Titan Image Generator can generate customizable instant images or by using reference images.
- The watermark detection API helps to determine whether the image is generated by Amazon or not.
Exploring Amazon Titan Image Generator
Amazon’s Titan Image Generator can generate new images of a subject by providing up to five reference images of the subject.
Users can use the style from the reference photographs to create new images, mix styles from different reference images, or construct the subject in other contexts while keeping its essential qualities. All of this is possible without the need for further prompt engineering or model fine-tuning.
Here’s an example code that was prompted to Titan Image Generator to generate an image of a “parrot eating a banana.” The code is in the Python language which was written with the help of AWS SDK for Python (Boto3). The below code was used to generate the image:
import boto3 import json bedrock_runtime = boto3.client(service_name="bedrock-runtime") body = json.dumps( { "taskType": "TEXT_IMAGE", "textToImageParams": { "text": "parrot eating a banana", }, "imageGenerationConfig": { "numberOfImages": 1, "quality": "premium", "height": 768, "width": 1280, "cfgScale": 10, "seed": 42 } } ) response = bedrock_runtime.invoke_model( body=body, modelId="amazon.titan-image-generator-v1", accept="application/json", contentType="application/json" )
Now prompt this below code to view the generated image:
import io import base64 from PIL import Image response_body = json.loads(response.get("body").read()) images = [ Image.open(io.BytesIO(base64.b64decode(base64_image))) for base64_image in response_body.get("images") ] for img in images: display(img)
Here’s the image generated:
The Titan Image Generator can also be used to generate images by providing 2 or more reference images. In the below code, a parrot image was generated again but this time with the help of 2 reference images:
This is the code in the Python language which was used in Bedrock:
# Import reference images image_path_1 = "parrot-cartoon.png" image_path_2 = "bird-sketch.png" with open(image_path_1, "rb") as image_file: input_image_1 = base64.b64encode(image_file.read()).decode("utf8") with open(image_path_2, "rb") as image_file: input_image_2 = base64.b64encode(image_file.read()).decode("utf8") # ImageVariationParams options: # text: Prompt to guide the model on how to generate variations # images: Base64 string representation of a reference image, up to 5 images are supported # similarityStrength: Parameter you can tune to control similarity with reference image(s) body = json.dumps( { "taskType": "IMAGE_VARIATION", "imageVariationParams": { "text": "parrot eating a banana", # Required "images": [input_image_1, input_image_2], # Required 1 to 5 images "similarityStrength": 0.7, # Range: 0.2 to 1.0 }, "imageGenerationConfig": { "numberOfImages": 1, "quality": "premium", "height": 768, "width": 1280, "cfgScale": 10, "seed": 42 } } ) response = bedrock_runtime.invoke_model( body=body, modelId="amazon.titan-image-generator-v1", accept="application/json", contentType="application/json" )
Here’s the generated image by Amazon Titan Image Generator. As we can see, the parrot in the second image, which was created with the help of the instant image customization feature, is stylistically similar to the set of reference photographs that were provided.
But what is Amazon Watermark Detector?
Users can now check whether an image has been generated by Amazon Bedrock. They introduced Watermark Detector in preview mode through API. As AI-generated content continues to progress, these tamper-resistant watermarks will contribute to greater transparency.
“All Amazon Titan FMs are built with responsible AI in mind. They detect and remove harmful content from data, reject inappropriate user inputs, and filter model outputs. As content creators create realistic-looking images with AI, it’s important to promote responsible development of this technology and reduce the spread of misinformation. That’s why all images generated by Titan Image Generator contain an invisible watermark, by default.”
Amazon Web Services (AWS) is one of the first major cloud providers to extensively distribute built-in watermarks for AI picture outputs. Watermark detection is an innovative technology.
Watermark Detection through Bedrock Console
The Amazon Bedrock console typically has watermark detection.
To find watermarks embedded in photos produced by Titan Image Generator, including those produced by the base model and any modified variations, user can upload an image. The model will show that no watermark has been found if you submit a picture that wasn’t made with Titan picture Generator.
There is also a confidence score associated with the watermark-detecting feature. The degree of confidence in watermark detection is indicated by the confidence score. If the original image has been altered, the detection confidence could occasionally be low.
This confidence score metric will make it easy for you to determine whether the image is AWS-generated or not.
This new tool encourages transparency and ethical AI deployment across organizations by making it easier for content creators, news organizations, fraud detection teams, risk analysts, and others to recognize and remediate deceptive AI-generated material.
Watermark Detection through the API
Apart from the watermark detection through the console, Amazon has launched a new DetectGeneratedContent API in Amazon Bedrock that verifies if a picture was created using the Titan picture Generator and looks for the watermark. The API has been launched in the preview mode.
Here’s an image that was checked by the API to see if it was Amazon-generated or not:
This is the Python code that was written to call the Watermark API. In the code, you have to define the imports, set up the Amazon Bedrock boto3 runtime client, and base64-encode the image. Then we can call the DetectGeneratedContent API by specifying the foundation model and providing the encoded image:
import boto3 import json import base64 bedrock_runtime = boto3.client(service_name="bedrock-runtime") image_path = "green-iguana.png" with open(image_path, "rb") as image_file: input_image_iguana = image_file.read() response = bedrock_runtime.detect_generated_content( foundationModelId = "amazon.titan-image-generator-v1", content = { "imageContent": { "bytes": input_image_iguana } } )
Here’s the response generated:
response.get("detectionResult") 'GENERATED' response.get("confidenceLevel") 'HIGH'
You can see in the response that the confidence level is “High”. This shows that Amazon Bedrock detected a watermark generated by the Titan Image Generator.
If the image is not generated by Amazon you will get the response as “Not_Generated”. Confidence level will also be low.
How to Access them?
In the AWS Regions US East (North Virginia) and US West (Oregon), Amazon Titan Image Generator, the new immediate customization features, and watermark detection in the Amazon Bedrock console are now accessible.
The Amazon Bedrock playground PartyRock also now offers Titan Image Generator. PartyRock offers a credit-card-free, no-code, AI-powered app development experience. Using PartyRock, you can design apps that produce photos in a matter of seconds by choosing from a variety of image production models available from Stability AI and Amazon.
And now just images, Amazon is also giving major updates in the world of music, using AI Playlists with Amazon Maestro.
Conclusion
Amazon has done great in introducing two highly powerful tools into the world of Generative AI. These tools hold immense potential to completely transform the world of Image Generation and DeepFake detection forever. Let’s find out how users make use of these tools in the days to come for their Gen AI projects and tasks!