{"id":4186,"date":"2024-04-26T10:04:48","date_gmt":"2024-04-26T10:04:48","guid":{"rendered":"https:\/\/favtutor.com\/articles\/?p=4186"},"modified":"2024-04-26T10:04:49","modified_gmt":"2024-04-26T10:04:49","slug":"amazon-titan-image-generator-watermark-detection-api","status":"publish","type":"post","link":"https:\/\/favtutor.com\/articles\/amazon-titan-image-generator-watermark-detection-api\/","title":{"rendered":"Amazon Titan Image Generator Now Available on Bedrock"},"content":{"rendered":"\n<p>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&#8217;s explore!<\/p>\n\n\n\n<p><strong>Highlights:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Amazon now offers its Titan Image Generator with Watermark Detection API on their Bedrock platform.<\/li>\n\n\n\n<li>Titan Image Generator can generate customizable instant images or by using reference images.<\/li>\n\n\n\n<li>The watermark detection API helps to determine whether the image is generated by Amazon or not.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Exploring Amazon Titan Image Generator<\/strong><\/h2>\n\n\n\n<p><strong>Amazon\u2019s Titan Image Generator can generate new images of a subject by providing up to five reference images of the subject.<\/strong><\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<div class=\"jeg_video_container jeg_video_content\"><iframe title=\"Amazon Titan Image Generator Demo - Watermark Detection | Amazon Web Services\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/M5Vqb3UoXtc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<\/div><\/figure>\n\n\n\n<p>Here\u2019s an example code that was prompted to Titan Image Generator to generate an image of a <em>\u201cparrot eating a banana.\u201d <\/em>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:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\">import boto3\nimport json\n\nbedrock_runtime = boto3.client(service_name=&quot;bedrock-runtime&quot;)\n\nbody = json.dumps(\n    {\n        &quot;taskType&quot;: &quot;TEXT_IMAGE&quot;,\n        &quot;textToImageParams&quot;: {\n            &quot;text&quot;: &quot;parrot eating a banana&quot;,   \n        },\n        &quot;imageGenerationConfig&quot;: {\n            &quot;numberOfImages&quot;: 1,   \n            &quot;quality&quot;: &quot;premium&quot;, \n            &quot;height&quot;: 768,\n            &quot;width&quot;: 1280,\n            &quot;cfgScale&quot;: 10, \n            &quot;seed&quot;: 42\n        }\n    }\n)\nresponse = bedrock_runtime.invoke_model(\n    body=body, \n    modelId=&quot;amazon.titan-image-generator-v1&quot;,\n    accept=&quot;application\/json&quot;, \n    contentType=&quot;application\/json&quot;\n)<\/pre><\/div>\n\n\n\n<p>Now prompt this below code to view the generated image:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\">import io\nimport base64\nfrom PIL import Image\n\nresponse_body = json.loads(response.get(&quot;body&quot;).read())\n\nimages = [\n    Image.open(io.BytesIO(base64.b64decode(base64_image)))\n    for base64_image in response_body.get(&quot;images&quot;)\n]\n\nfor img in images:\n    display(img)<\/pre><\/div>\n\n\n\n<p>Here&#8217;s the image generated:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1280\" height=\"768\" src=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/parrot-banana-new-1-1-1.png\" alt=\"Image generated using Amazon Titan Image Generator\" class=\"wp-image-4187\" srcset=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/parrot-banana-new-1-1-1.png 1280w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/parrot-banana-new-1-1-1-768x461.png 768w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/parrot-banana-new-1-1-1-750x450.png 750w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/parrot-banana-new-1-1-1-1140x684.png 1140w\" sizes=\"(max-width: 1280px) 100vw, 1280px\" \/><figcaption class=\"wp-element-caption\">Source: <a href=\"https:\/\/aws.amazon.com\/blogs\/aws\/amazon-titan-image-generator-and-watermark-detection-api-are-now-available-in-amazon-bedrock\/\" target=\"_blank\" data-type=\"link\" data-id=\"https:\/\/aws.amazon.com\/blogs\/aws\/amazon-titan-image-generator-and-watermark-detection-api-are-now-available-in-amazon-bedrock\/\" rel=\"noreferrer noopener nofollow\">Amazon Blog<\/a><\/figcaption><\/figure>\n<\/div>\n\n\n<p>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:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"937\" height=\"287\" src=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-590.png\" alt=\"Using Refenrece Images\" class=\"wp-image-4188\" srcset=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-590.png 937w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-590-768x235.png 768w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-590-750x230.png 750w\" sizes=\"(max-width: 937px) 100vw, 937px\" \/><\/figure>\n<\/div>\n\n\n<p>This is the code in the Python language which was used in Bedrock:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\"># Import reference images\nimage_path_1 = &quot;parrot-cartoon.png&quot;\nimage_path_2 = &quot;bird-sketch.png&quot;\n\nwith open(image_path_1, &quot;rb&quot;) as image_file:\n    input_image_1 = base64.b64encode(image_file.read()).decode(&quot;utf8&quot;)\n\nwith open(image_path_2, &quot;rb&quot;) as image_file:\n    input_image_2 = base64.b64encode(image_file.read()).decode(&quot;utf8&quot;)\n\n# ImageVariationParams options:\n#   text: Prompt to guide the model on how to generate variations\n#   images: Base64 string representation of a reference image, up to 5 images are supported\n#   similarityStrength: Parameter you can tune to control similarity with reference image(s)\n\nbody = json.dumps(\n    {\n        &quot;taskType&quot;: &quot;IMAGE_VARIATION&quot;,\n        &quot;imageVariationParams&quot;: {\n            &quot;text&quot;: &quot;parrot eating a banana&quot;,  # Required\n            &quot;images&quot;: [input_image_1, input_image_2],  # Required 1 to 5 images\n            &quot;similarityStrength&quot;: 0.7,  # Range: 0.2 to 1.0\n        },\n        &quot;imageGenerationConfig&quot;: {\n            &quot;numberOfImages&quot;: 1,\n            &quot;quality&quot;: &quot;premium&quot;,\n            &quot;height&quot;: 768,\n            &quot;width&quot;: 1280,\n            &quot;cfgScale&quot;: 10,\n            &quot;seed&quot;: 42\n        }\n    }\n)\n\nresponse = bedrock_runtime.invoke_model(\n    body=body, \n    modelId=&quot;amazon.titan-image-generator-v1&quot;,\n    accept=&quot;application\/json&quot;, \n    contentType=&quot;application\/json&quot;\n)<\/pre><\/div>\n\n\n\n<p>Here\u2019s 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.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1117\" height=\"361\" src=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-591.png\" alt=\"New Image with Reference Images on Amazon Titan Image Generator\" class=\"wp-image-4189\" srcset=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-591.png 1117w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-591-768x248.png 768w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-591-750x242.png 750w\" sizes=\"(max-width: 1117px) 100vw, 1117px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><strong>But what is Amazon Watermark Detector?<\/strong><\/h2>\n\n\n\n<p><strong>Users can now check whether an image has been generated by Amazon Bedrock. They introduced Watermark Detector in preview mode through API.\u00a0<\/strong>As AI-generated content continues to progress, these tamper-resistant watermarks will contribute to greater transparency.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><em>\u201cAll 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\u2019s important to promote responsible development of this technology and reduce the spread of misinformation. That\u2019s why all images generated by Titan Image Generator contain an invisible watermark, by default.\u201d<\/em><\/p>\n<\/blockquote>\n\n\n\n<p>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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Watermark Detection through Bedrock Console<\/strong><\/h3>\n\n\n\n<p>The Amazon Bedrock console typically has watermark detection.<\/p>\n\n\n\n<p>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&#8217;t made with Titan picture Generator.<\/p>\n\n\n\n<p>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. <\/p>\n\n\n\n<p>This confidence score metric will make it easy for you to determine whether the image is AWS-generated or not.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Watermark Detection through the API<\/strong><\/h3>\n\n\n\n<p><strong>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.<\/strong><\/p>\n\n\n\n<p>Here\u2019s an image that was checked by the API to see if it was Amazon-generated or not:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1049\" height=\"633\" src=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-592-1-1.png\" alt=\"\" class=\"wp-image-4190\" srcset=\"https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-592-1-1.png 1049w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-592-1-1-768x463.png 768w, https:\/\/favtutor.com\/articles\/wp-content\/uploads\/2024\/04\/Screenshot-592-1-1-750x453.png 750w\" sizes=\"(max-width: 1049px) 100vw, 1049px\" \/><\/figure>\n<\/div>\n\n\n<p>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:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\">import boto3\nimport json\nimport base64\n\nbedrock_runtime = boto3.client(service_name=&quot;bedrock-runtime&quot;)\n\nimage_path = &quot;green-iguana.png&quot;\n\nwith open(image_path, &quot;rb&quot;) as image_file:\n    input_image_iguana = image_file.read()\n\nresponse = bedrock_runtime.detect_generated_content(\n    foundationModelId = &quot;amazon.titan-image-generator-v1&quot;,\n    content = {\n        &quot;imageContent&quot;: { &quot;bytes&quot;: input_image_iguana }\n    }\n)<\/pre><\/div>\n\n\n\n<p>Here\u2019s the response generated:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;Python&quot;,&quot;modeName&quot;:&quot;python&quot;}\">response.get(&quot;detectionResult&quot;)\n'GENERATED'\nresponse.get(&quot;confidenceLevel&quot;)\n'HIGH'<\/pre><\/div>\n\n\n\n<p>You can see in the response that the confidence level is \u201cHigh\u201d. This shows that Amazon Bedrock detected a watermark generated by the Titan Image Generator.<\/p>\n\n\n\n<p>If the image is not generated by Amazon you will get the response as \u201cNot_Generated\u201d. Confidence level will also be low.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Access them?<\/strong><\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The Amazon Bedrock playground <a href=\"https:\/\/partyrock.aws\/\" data-type=\"link\" data-id=\"https:\/\/partyrock.aws\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">PartyRock <\/a>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.<\/p>\n\n\n\n<p>And now just images, Amazon is also giving major updates in the world of music, using <a href=\"https:\/\/favtutor.com\/articles\/amazon-music-maestro-ai-playlist\/\">AI Playlists with Amazon Maestro<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>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\u2019s find out how users make use of these tools in the days to come for their Gen AI projects and tasks!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Amazon now offers its Titan Image Generator with Watermark Detection API on their Bedrock platform. Let&#8217;s explore how they work?<\/p>\n","protected":false},"author":15,"featured_media":4197,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":null,"jnews_primary_category":{"id":"","hide":""},"footnotes":""},"categories":[57],"tags":[56,191,211,59],"class_list":["post-4186","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ai","tag-ai","tag-amazon","tag-bedrock","tag-generative-ai"],"_links":{"self":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/4186","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/comments?post=4186"}],"version-history":[{"count":3,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/4186\/revisions"}],"predecessor-version":[{"id":4198,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/posts\/4186\/revisions\/4198"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/media\/4197"}],"wp:attachment":[{"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/media?parent=4186"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/categories?post=4186"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/favtutor.com\/articles\/wp-json\/wp\/v2\/tags?post=4186"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}