Thursday, April 25, 2024
HomeCloud ComputingAmazon Titan Picture Generator and watermark detection API at the moment are...

Amazon Titan Picture Generator and watermark detection API at the moment are out there in Amazon Bedrock


Voiced by Polly

Throughout AWS re:Invent 2023, we introduced the preview of Amazon Titan Picture Generator, a generative synthetic intelligence (generative AI) basis mannequin (FM) that you need to use to rapidly create and refine life like, studio-quality photos utilizing English pure language prompts.

I’m blissful to share that Amazon Titan Picture Generator is now usually out there in Amazon Bedrock, supplying you with a simple option to construct and scale generative AI functions with new picture era and picture enhancing capabilities, together with on the spot customization of photos.

In my earlier put up, I additionally talked about that each one photos generated by Titan Picture Generator comprise an invisible watermark, by default, which is designed to assist cut back the unfold of misinformation by offering a mechanism to determine AI-generated photos.

I’m excited to announce that watermark detection for Titan Picture Generator is now usually out there within the Amazon Bedrock console. At this time, we’re additionally introducing a brand new DetectGeneratedContent API (preview) in Amazon Bedrock that checks for the existence of this watermark and helps you affirm whether or not a picture was generated by Titan Picture Generator.

Let me present you methods to get began with these new capabilities.

Prompt picture customization utilizing Amazon Titan Picture Generator
Now you can generate new photos of a topic by offering as much as 5 reference photos. You may create the topic in several scenes whereas preserving its key options, switch the model from the reference photos to new photos, or combine kinds from a number of reference photos. All this may be achieved with out further immediate engineering or fine-tuning of the mannequin.

For this demo, I immediate Titan Picture Generator to create a picture of a “parrot consuming a banana.” Within the first try, I take advantage of Titan Picture Generator to create this new picture with out offering a reference picture.

Observe: Within the following code examples, I’ll use the AWS SDK for Python (Boto3) to work together with Amazon Bedrock. You could find further code examples for C#/.NET, Go, Java, and PHP within the Bedrock Consumer Information.

import boto3
import json

bedrock_runtime = boto3.shopper(service_name="bedrock-runtime")

physique = json.dumps(
    {
        "taskType": "TEXT_IMAGE",
        "textToImageParams": {
            "textual content": "parrot consuming a banana",   
        },
        "imageGenerationConfig": {
            "numberOfImages": 1,   
            "high quality": "premium", 
            "peak": 768,
            "width": 1280,
            "cfgScale": 10, 
            "seed": 42
        }
    }
)
response = bedrock_runtime.invoke_model(
    physique=physique, 
    modelId="amazon.titan-image-generator-v1",
    settle for="utility/json", 
    contentType="utility/json"
)

You may show the generated picture utilizing the next code.

import io
import base64
from PIL import Picture

response_body = json.hundreds(response.get("physique").learn())

photos = [
    Image.open(io.BytesIO(base64.b64decode(base64_image)))
    for base64_image in response_body.get("images")
]

for img in photos:
    show(img)

Right here’s the generated picture:

Image of a parrot eating a banana generated by Amazon Titan Image Generator

Then, I take advantage of the brand new on the spot picture customization functionality with the identical immediate, however now additionally offering the next two reference photos. For simpler comparability, I’ve resized the pictures, added a caption, and plotted them aspect by aspect.

Reference images for Amazon Titan Image Generator

Right here’s the code. The brand new on the spot customization is offered by the IMAGE_VARIATION activity:

# Import reference photos
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.learn()).decode("utf8")

with open(image_path_2, "rb") as image_file:
    input_image_2 = base64.b64encode(image_file.learn()).decode("utf8")

# ImageVariationParams choices:
#   textual content: Immediate to information the mannequin on methods to generate variations
#   photos: Base64 string illustration of a reference picture, as much as 5 photos are supported
#   similarityStrength: Parameter you possibly can tune to manage similarity with reference picture(s)

physique = json.dumps(
    {
        "taskType": "IMAGE_VARIATION",
        "imageVariationParams": {
            "textual content": "parrot consuming a banana",  # Required
            "photos": [input_image_1, input_image_2],  # Required 1 to five photos
            "similarityStrength": 0.7,  # Vary: 0.2 to 1.0
        },
        "imageGenerationConfig": {
            "numberOfImages": 1,
            "high quality": "premium",
            "peak": 768,
            "width": 1280,
            "cfgScale": 10,
            "seed": 42
        }
    }
)

response = bedrock_runtime.invoke_model(
    physique=physique, 
    modelId="amazon.titan-image-generator-v1",
    settle for="utility/json", 
    contentType="utility/json"
)

As soon as once more, I’ve resized the generated picture, added a caption, and plotted it aspect by aspect with the initially generated picture. Amazon Titan Image Generator instance customization results

You may see how the parrot within the second picture that has been generated utilizing the moment picture customization functionality resembles in model the mix of the supplied reference photos.

Watermark detection for Amazon Titan Picture Generator
All Amazon Titan FMs are constructed with accountable AI in thoughts. They detect and take away dangerous content material from information, reject inappropriate person inputs, and filter mannequin outputs. As content material creators create realistic-looking photos with AI, it’s vital to advertise accountable improvement of this know-how and cut back the unfold of misinformation. That’s why all photos generated by Titan Picture Generator comprise an invisible watermark, by default. Watermark detection is an modern know-how, and Amazon Internet Companies (AWS) is among the many first main cloud suppliers to broadly launch built-in watermarks for AI picture outputs.

Titan Picture Generator’s new watermark detection characteristic is a mechanism that permits you to determine photos generated by Amazon Titan. These watermarks are designed to be tamper-resistant, serving to enhance transparency round AI-generated content material as these capabilities proceed to advance.

Watermark detection utilizing the console
Watermark detection is usually out there within the Amazon Bedrock console. You may add a picture to detect watermarks embedded in photos created by Titan Picture Generator, together with these generated by the bottom mannequin and any personalized variations. Should you add a picture that was not created by Titan Picture Generator, then the mannequin will point out {that a} watermark has not been detected.

The watermark detection characteristic additionally comes with a confidence rating. The boldness rating represents the arrogance degree in watermark detection. In some circumstances, the detection confidence could also be low if the unique picture has been modified. This new functionality allows content material creators, information organizations, threat analysts, fraud detection groups, and others to higher determine and mitigate deceptive AI-generated content material, selling transparency and accountable AI deployment throughout organizations.

Watermark detection utilizing the API (preview)
Along with watermark detection utilizing the console, we’re introducing a brand new DetectGeneratedContent API (preview) in Amazon Bedrock that checks for the existence of this watermark and helps you affirm whether or not a picture was generated by Titan Picture Generator. Let’s see how this works.

For this demo, let’s test if the picture of the inexperienced iguana I confirmed within the Titan Picture Generator preview put up was certainly generated by the mannequin.

Green iguana generated by Amazon Titan Image Generator

I outline the imports, arrange the Amazon Bedrock boto3 runtime shopper, and base64-encode the picture. Then, I name the DetectGeneratedContent API by specifying the muse mannequin and offering the encoded picture.

import boto3
import json
import base64

bedrock_runtime = boto3.shopper(service_name="bedrock-runtime")

image_path = "green-iguana.png"

with open(image_path, "rb") as image_file:
    input_image_iguana = image_file.learn()

response = bedrock_runtime.detect_generated_content(
    foundationModelId = "amazon.titan-image-generator-v1",
    content material = {
        "imageContent": { "bytes": input_image_iguana }
    }
)

Let’s test the response.

response.get("detectionResult")
'GENERATED'
response.get("confidenceLevel")
'HIGH'

The response GENERATED with the arrogance degree HIGH confirms that Amazon Bedrock detected a watermark generated by Titan Picture Generator.

Now, let’s test one other picture I generated utilizing Steady Diffusion XL 1.0 on Amazon Bedrock. On this case, a “meerkat dealing with the sundown.”

Meerkat facing the sunset

I name the API once more, this time with the picture of the meerkat.

image_path = "meerkat.png"

with open(image_path, "rb") as image_file:
    input_image_meerkat = image_file.learn()

response = bedrock_runtime.detect_generated_content(
    foundationModelId = "amazon.titan-image-generator-v1",
    content material = {
        "imageContent": { "bytes": input_image_meerkat }
    }
)

response.get("detectionResult")
'NOT_GENERATED'

And certainly, the response NOT_GENERATED tells me that there was no watermark by Titan Picture Generator detected, and due to this fact, the picture almost certainly wasn’t generated by the mannequin.

Utilizing Amazon Titan Picture Generator and watermark detection within the console
Right here’s a brief demo of methods to get began with Titan Picture Generator and the brand new watermark detection characteristic within the Amazon Bedrock console, put collectively by my colleague Nirbhay Agarwal.

Availability
Amazon Titan Picture Generator, the brand new on the spot customization capabilities, and watermark detection within the Amazon Bedrock console can be found at the moment within the AWS Areas US East (N. Virginia) and US West (Oregon). Examine the full Area record for future updates. The brand new DetectGeneratedContent API in Amazon Bedrock is offered at the moment in public preview within the AWS Areas US East (N. Virginia) and US West (Oregon).

Amazon Titan Picture Generator, now additionally out there in PartyRock
Titan Picture Generator is now additionally out there in PartyRock, an Amazon Bedrock playground. PartyRock offers you a no-code, AI-powered app-building expertise that doesn’t require a bank card. You need to use PartyRock to create apps that generate photos in seconds by deciding on out of your selection of picture era fashions from Stability AI and Amazon.

Extra assets
To be taught extra in regards to the Amazon Titan household of fashions, go to the Amazon Titan product web page. For pricing particulars, test Amazon Bedrock Pricing.

Give Amazon Titan Picture Generator a strive in PartyRock or discover the mannequin’s superior picture era and enhancing capabilities within the Amazon Bedrock console. Ship suggestions to AWS re:Put up for Amazon Bedrock or by your typical AWS contacts.

For extra deep-dive technical content material and to have interaction with the generative AI Builder neighborhood, go to our generative AI house at neighborhood.aws.

— Antje



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments