Accelerating your advertising and marketing ideation with generative AI – Half 2: Generate customized advertising and marketing photos from historic references


Advertising groups face main challenges creating campaigns in in the present day’s digital atmosphere. They need to navigate by complicated information analytics and quickly altering client preferences to provide participating, personalised content material throughout a number of channels whereas sustaining model consistency and dealing inside tight deadlines. Utilizing generative AI can streamline and speed up the artistic course of whereas sustaining alignment with enterprise targets. Certainly, in accordance with McKinsey’s “The State of AI in 2023” report, 72% of organizations now combine AI into their operations, with advertising and marketing rising as a key space of implementation.

Constructing upon our earlier work of marketing campaign image generation using Amazon Nova foundation models, on this publish, we exhibit learn how to improve picture technology by studying from earlier advertising and marketing campaigns. We discover learn how to combine Amazon Bedrock, AWS Lambda, and Amazon OpenSearch Serverless to create a sophisticated picture technology system that makes use of reference campaigns to keep up model tips, ship constant content material, and improve the effectiveness and effectivity of recent marketing campaign creation.

The worth of earlier marketing campaign info

Historic marketing campaign information serves as a strong basis for creating efficient advertising and marketing content material. By analyzing efficiency patterns throughout previous campaigns, groups can determine and replicate profitable artistic parts that constantly drive larger engagement charges and conversions. These patterns would possibly embrace particular colour schemes, picture compositions, or visible storytelling methods that resonate with goal audiences. Earlier marketing campaign belongings additionally function confirmed references for sustaining constant model voice and visible identification throughout channels. This consistency is essential for constructing model recognition and belief, particularly in multi-channel advertising and marketing environments the place coherent messaging is important.

On this publish, we discover learn how to use historic marketing campaign belongings in advertising and marketing content material creation. We enrich reference photos with beneficial metadata, together with marketing campaign particulars and AI-generated picture descriptions, and course of them by embedding fashions. By integrating these reference belongings with AI-powered content material technology, advertising and marketing groups can remodel previous successes into actionable insights for future campaigns. Organizations can use this data-driven strategy to scale their advertising and marketing efforts whereas sustaining high quality and consistency, leading to extra environment friendly useful resource utilization and improved marketing campaign efficiency. We’ll exhibit how this systematic technique of utilizing earlier marketing campaign information can considerably improve advertising and marketing methods and outcomes.

Resolution overview

In our previous post, we carried out a advertising and marketing marketing campaign picture generator utilizing Amazon Nova Pro and Amazon Nova Canvas. On this publish, we discover learn how to improve this answer by incorporating a reference picture search engine that makes use of historic marketing campaign belongings to enhance technology outcomes. The next structure diagram illustrates the answer:

Architecture diagram for AI-powered marketing content generation and semantic image search on AWS

The primary structure parts are defined within the following listing:

  1. Our system begins with a web-based UI that customers can entry to start out the creation of recent advertising and marketing marketing campaign photos. Amazon Cognito handles person authentication and administration, serving to to make sure safe entry to the platform.
  2. The historic advertising and marketing belongings are uploaded to Amazon Simple Storage Service (Amazon S3) to construct a related reference library. This add course of is initiated by Amazon API Gateway. On this publish, we use the publicly accessible COCO (Common Objects in Context) dataset as our supply of reference photos.
  3. The picture processing AWS Step Functions workflow is triggered by API Gateway and processes photos in three steps:
    1. A Lambda perform (DescribeImgFunction) makes use of the Amazon Nova Professional mannequin to explain the photographs and determine their key parts.
    2. A Lambda perform (EmbedImgFunction) transforms the photographs into embeddings utilizing the Amazon Titan Multimodal Embeddings basis mannequin.
    3. A Lambda perform (IndexDataFunction) shops the reference picture embeddings in an OpenSearch Serverless index, enabling fast similarity searches.
  4. This step bridges asset discovery and content material technology. When customers provoke a brand new marketing campaign, a Lambda perform (GenerateRecommendationsFunction) transforms the marketing campaign necessities into vector embeddings and performs a similarity search within the OpenSearch Serverless index to determine probably the most related reference photos. The descriptions of chosen reference photos are then included into an enhanced immediate by a Lambda perform (GeneratePromptFunction). This immediate powers the creation of recent marketing campaign photos utilizing Amazon Bedrock by a Lambda perform (GenerateNewImagesFunction). For detailed details about the picture technology course of, see our previous blog.

Our answer is obtainable in GitHub. To deploy this venture, comply with the directions accessible within the README file.

Process

On this part, we study the technical parts of our answer, from reference picture processing by closing advertising and marketing content material technology.

Analyzing the reference picture dataset

Step one in our AWS Step Features workflow is analyzing reference photos utilizing the Lambda Operate DescribeImgFunction. This useful resource makes use of Amazon Nova Pro 1.0 to generate two key parts for every picture: an in depth description and an inventory of parts current within the picture. These metadata parts might be built-in into our vector database index later and used for creating new marketing campaign visuals.

For implementation particulars, together with the whole immediate template and Lambda perform code, see our GitHub repository. The next is the structured output generated by the perform when offered with a picture:

Baseball outfielder in white uniform catching a ball during a game with coach nearby on a natural field with trees in background

{
  "statusCode": 201,
  "physique": {
    "labels_list": [
      "baseball player in white t-shirt",
      "baseball player in green t-shirt",
      "blue helmet",
      "green cap",
      "baseball glove",
      "baseball field",
      "trees",
      "grass"
    ],
    "description": "A picture displaying two folks enjoying baseball. The individual in entrance, sporting a white t-shirt and blue helmet, is working in the direction of the bottom. The individual behind, sporting a inexperienced t-shirt and inexperienced cap, is holding a baseball glove in his proper hand, presumably making ready to catch the ball. The background features a lush inexperienced space with bushes and a dust baseball discipline.",
    "msg": "success"
  }
}

Producing reference picture embeddings

The Lambda perform EmbedImgFunction encodes the reference photos into vector representations utilizing the Amazon Titan Multimodal Embeddings mannequin. This mannequin can embed each modalities right into a joint house the place textual content and pictures are represented as numerical vectors in the identical dimensional house. On this unified illustration, semantically comparable objects (whether or not textual content or photos) are positioned nearer collectively. The mannequin preserves semantic relationships inside and throughout modalities, enabling direct comparisons between any mixture of photos and textual content. This permits highly effective capabilities equivalent to text-based picture search, picture similarity search, and mixed textual content and picture search.

The next code demonstrates the important logic for changing photos into vector embeddings. For the whole implementation of the Lambda perform, see our GitHub repository.

with open(image_path, "rb") as image_file:
    input_image = base64.b64encode(image_file.learn()).decode('utf8')

response = bedrock_runtime.invoke_model(
    physique=json.dumps({
        "inputImage": input_image,
        "embeddingConfig": {
            "outputEmbeddingLength": dimension
        }
    }),
    modelId=model_id
)
json.hundreds(response.get("physique").learn())

The perform outputs a structured response containing the picture particulars and its embedding vector, as proven within the following instance.

{
    'filename': '000000000872.jpg',
    'file_path': '{AMAZON_S3_PATH}',
    'embedding': [
        0.040705927,
        -0.007597826,
        -0.013537944,
        -0.038679842,
        ... // 1,024-dimensional vector by default, though this can be adjusted
    ]
}

Index reference photos with Amazon Bedrock and OpenSearch Serverless

Our answer makes use of OpenSearch Serverless to allow environment friendly vector search capabilities for reference photos. This course of entails two major steps: establishing the search infrastructure after which populating it with reference picture information.

Creation of the search index

Earlier than indexing our reference photos, we have to arrange the suitable search infrastructure. When our stack is deployed, it provisions a vector search assortment in OpenSearch Serverless, which robotically handles scaling and infrastructure administration. Inside this assortment, we create a search index utilizing the Lambda perform CreateOpenSearchIndexFn.

Our index mappings configuration, proven within the following code, defines the vector similarity algorithm and the marketing campaign metadata fields for filtering. We use the Hierarchical Navigable Small World (HNSW) algorithm, offering an optimum stability between search velocity and accuracy. The marketing campaign metadata contains an goal discipline that captures marketing campaign objectives (equivalent to clicks, consciousness, or likes) and a node discipline that identifies goal audiences (equivalent to followers, clients, or new clients). By filtering search outcomes utilizing these fields, we may also help be sure that reference photos come from campaigns with matching targets and goal audiences, sustaining alignment in our advertising and marketing strategy.

{
    "mappings": {
        "properties": {
            "outcomes": {"kind": "float"},
            "node": {"kind": "key phrase"},
            "goal": {"kind": "key phrase"},
            "image_s3_uri": {"kind": "textual content"},
            "image_description": {"kind": "textual content"},
            "img_element_list": {"kind": "textual content"},
            "embeddings": {
                "kind": "knn_vector",
                "dimension": 1024,
                "technique": {
                    "engine": "nmslib",
                    "space_type": "cosinesimil",
                    "title": "hnsw",
                    "parameters": {"ef_construction": 512, "m": 16}
                }
            }
        }
    }
}

For the whole implementation particulars, together with index settings and extra configurations, see our GitHub repository.

Indexing reference photos

With our search index in place, we will now populate it with reference picture information. The Lambda perform IndexDataFunction handles this course of by connecting to the OpenSearch Serverless index and storing every picture’s vector embedding alongside its metadata (marketing campaign targets, audience, descriptions, and different related info). We will use this listed information later to rapidly discover related reference photos when creating new advertising and marketing campaigns. Beneath is a simplified implementation, with the whole code accessible in our GitHub repository:

# Initialize the OpenSearch shopper
oss_client = OpenSearch(
    hosts=[{'host': OSS_HOST, 'port': 443}],
    http_auth=AWSV4SignerAuth(boto3.Session().get_credentials(), area, 'aoss'),
    use_ssl=True,
    verify_certs=True,
    connection_class=RequestsHttpConnection
)
# Put together doc for indexing
doc = {
    "id": image_id,
    "node": metadata['node'],
    "goal": metadata['objective'],
    "image_s3_uri": s3_url,
    "image_description": description,
    "img_element_list": parts,
    "embeddings": embedding_vector
}
# Index doc in OpenSearch
oss_response = oss_client.index(
    index=OSS_EMBEDDINGS_INDEX_NAME,
    physique=doc
)

Combine the search engine into the advertising and marketing campaigns picture generator

The picture technology workflow combines marketing campaign necessities with insights from earlier reference photos to create new advertising and marketing visuals. The method begins when customers provoke a brand new marketing campaign by the online UI. Customers present three key inputs: a textual content description of their desired marketing campaign, its goal, and its node. Utilizing these inputs, we carry out a vector similarity search in OpenSearch Serverless to determine probably the most related reference photos from our library. For these chosen photos, we retrieve their descriptions (created earlier by Lambda perform DescribeImgFunction) and incorporate them into our immediate engineering course of. The ensuing enhanced immediate serves as the inspiration for producing new marketing campaign photos that align with each: the person’s necessities and profitable reference examples. Let’s study every step of this course of intimately.

Get picture suggestions

When a person defines a brand new marketing campaign description, the Lambda perform GetRecommendationsFunction transforms it right into a vector embedding utilizing the Amazon Titan Multimodal Embeddings mannequin. By reworking the marketing campaign description into the identical vector house as our picture library, we will carry out exact similarity searches and determine reference photos that intently align with the marketing campaign’s targets and visible necessities.

The Lambda perform configures the search parameters, together with the variety of outcomes to retrieve and the okay worth for the k-NN algorithm. In our pattern implementation, we set okay to 5, retrieving the highest 5 most comparable photos. These parameters might be adjusted to stability outcome range and relevance.

To assist guarantee contextual relevance, we apply filters to match each the node (audience) and goal of the brand new marketing campaign. This strategy ensures that beneficial photos usually are not solely visually comparable but in addition aligned with the marketing campaign’s particular objectives and audience. We showcase a simplified implementation of our search question, with the whole code accessible in our GitHub repository.

physique = {
    "dimension": okay,
    "_source": {"exclude": ["embeddings"]},
    "question":
        {
            "knn":
                {
                    "embeddings": {
                        "vector": embedding,
                        "okay": okay,
                    }
                }
        },
    "post_filter": {
        "bool": {
            "filter": [
                {"term": {"node": node}},
                {"term": {"objective": objective}}
            ]
        }
    }
}
res = oss_client.search(index=OSS_EMBEDDINGS_INDEX_NAME, physique=physique)

The perform processes the search outcomes, that are saved in Amazon DynamoDB to keep up a persistent document of campaign-image associations for environment friendly retrieval. Customers can entry these suggestions by the UI and choose which reference photos to make use of for his or her new marketing campaign creation.

Enhancing the meta-prompting method with reference photos

The immediate technology part builds upon our meta-prompting method launched in our previous blog. Whereas sustaining the identical strategy with Amazon Nova Pro 1.0, we now improve the method by incorporating descriptions from user-selected reference photos. These descriptions are built-in into the template immediate utilizing XML tags (<related_images>), as proven within the following instance.

You're a graphics designer named Joe that focuses on creating visualizations aided by text-to-image basis fashions. Your colleagues come to you every time they wish to craft environment friendly prompts for creating photos with text-to-image basis fashions equivalent to Steady Difussion or Dall-E. 

You all the time reply to your colleagues requests with a really environment friendly immediate for creating nice visualizations utilizing text-to-image basis fashions.

These are some guidelines you'll comply with when interacting along with your colleagues:

* Your colleagues will focus on their concepts utilizing both Spanish or English, so please be versatile.
* Your solutions will all the time be in English whatever the language your colleague used to speak.
* Your immediate needs to be at most 512 characters. You might be inspired to make use of all of them.
* Don't give particulars about or decision of the photographs within the immediate you'll generate.
* You'll all the time say out loud what you might be pondering
* You all the time cause solely as soon as earlier than making a immediate
* It doesn't matter what you all the time present a immediate to your colleagues
* You'll create just one immediate
* If supplied with reference picture descriptions (might be in between <related_images> XML tags) rigorously stability the contributions of the campaigns description with the reference photos to create the immediate
* By no means recommend so as to add textual content to the photographs

Listed here are some tips you all the time comply with when crafting efficient picture prompts:

* Begin with a transparent imaginative and prescient: Have a transparent thought of the picture you need the AI to generate, picturing the scene or idea in your thoughts intimately.
* Select your topic: Clearly state the primary topic of your picture, making certain it's prominently talked about within the immediate.
* Set the scene: Describe the setting or background, together with the atmosphere, time of day, or particular location.
* Specify lighting and ambiance: Use descriptive phrases for lighting and temper, like "bathed in golden hour gentle" or "mystical ambiance".
* Incorporate particulars and textures: Enrich your immediate with descriptions of textures, colours, or particular objects so as to add depth.
* Use unfavourable key phrases correctly: Embody particular parts you need the AI to keep away from to refine the output.
* Be conscious of size and readability: Efficient prompts are typically detailed however not overly lengthy, offering key visible options, types, feelings or different descriptive parts.
* Particular tokens might be added to offer higher-level steering like "photorealistic", "cinematic lighting" and many others. These act like key phrases for the mannequin.
* Logically order immediate parts and use punctuation to point relationships. For instance, use commas to separate impartial clauses or colons to steer into an outline.
* Evaluation and revise: Examine your immediate for accuracy and readability, revising as wanted to higher seize your thought.

Listed here are some examples of prompts you've created beforehand to assist your colleagues:

{Textual content to picture immediate examples}

A colleague of yours has come to you for assist in making a immediate for:

{textual content}

He additionally discovered the next picture descriptions that match what he want to create and he desires you to contemplate the for crafting your immediate:

<related_images>
{Descriptions of associated reference photos}
</related_images>
Utilizing your data in text-to-image basis fashions craft a immediate to generate a picture in your colleague. You might be inspired to assume out loud in your artistic course of however please write it down in a scratchpad.

Construction your output in a JSON object with the next construction:

{json_schema}

The immediate technology is orchestrated by the Lambda perform GeneratePromptFunction. The perform receives the marketing campaign ID and the URLs of chosen reference photos, retrieves their descriptions from DynamoDB, and makes use of Amazon Nova Pro 1.0 to create an optimized immediate from the earlier template. This immediate is used within the subsequent picture technology part. The code implementation of the Lambda perform is obtainable in our GitHub repository.

Picture technology

After acquiring reference photos and producing an enhanced immediate, we use the Lambda perform GenerateNewImagesFunction to create the brand new marketing campaign picture. This perform makes use of Amazon Nova Canvas 1.0 to generate a closing visible asset that comes with insights from profitable reference campaigns. The implementation follows the picture technology course of we detailed in our previous blog. For the whole Lambda perform code, see our GitHub repository.

Creating a brand new advertising and marketing marketing campaign: An end-to-end instance

We developed an intuitive interface that guides customers by the marketing campaign creation course of. The interface handles the complexity of AI-powered picture technology, solely requiring customers to offer their marketing campaign description and fundamental particulars. We stroll by the steps to create a advertising and marketing marketing campaign utilizing our answer:

  1. Customers start by defining three key marketing campaign parts:
    1. Marketing campaign description: An in depth temporary that serves as the inspiration for picture technology.
    2. Marketing campaign goal: The advertising and marketing intention (for instance, Consciousness) that guides the visible technique.
    3. Goal node: The particular viewers section (for instance, Clients) for content material focusing on.

Definition of campaign elements

  1. Primarily based on the marketing campaign particulars, the system presents related photos from earlier profitable campaigns. Customers can evaluation and choose the photographs that align with their imaginative and prescient. These alternatives will information the picture technology course of.

Suggestions of relevant images from previous marketing campaigns

  1. Utilizing the marketing campaign description and chosen reference photos, the system generates an enhanced immediate that serves because the enter for the ultimate picture technology step.

AI-generated prompt for marketing image creation

  1. Within the closing step, our system generates visible belongings based mostly on the immediate that would probably be used as inspiration for an entire marketing campaign briefing.

AI-generated marketing campaign images

How Bancolombia is utilizing Amazon Nova to streamline their advertising and marketing marketing campaign belongings technology

Bancolombia, one among Colombia’s main banks, has been experimenting with this advertising and marketing content material creation strategy for greater than a 12 months. Their implementation offers beneficial insights into how this answer might be built-in into established advertising and marketing workflows. Bancolombia has been capable of streamline their artistic workflow whereas making certain that the generated visuals align with the marketing campaign’s strategic intent. Juan Pablo Duque, Advertising Scientist Lead at Bancolombia, shares his perspective on the influence of this know-how:

“For the Bancolombia crew, leveraging historic imagery was a cornerstone in constructing this answer. Our purpose was to immediately sort out three main business ache factors:

  • Lengthy and dear iterative processes: By implementing meta-prompting methods and making certain strict model tips, we’ve considerably diminished the time customers spend producing high-quality photos.
  • Problem sustaining context throughout artistic variations: By figuring out and locking in key visible parts, we guarantee seamless consistency throughout all graphic belongings.
  • Lack of management over outputs: The suite of methods built-in into our answer offers customers with a lot better precision and management over the outcomes.

And that is only the start. This train permits us to validate new AI creations towards our present library, making certain we don’t over-rely on the identical visuals and protecting our model’s look contemporary and fascinating.”

Clear up

To keep away from incurring future costs, you need to delete all of the sources used on this answer. As a result of the answer was deployed utilizing a number of AWS CDK stacks, you need to delete them within the reverse order of deployment to correctly take away all sources. Comply with these steps to wash up your atmosphere:

  1. Delete the frontend stack:
  1. Delete the picture technology backend stack:
cd ../backend-img-generation
cdk destroy

  1. Delete the picture indexing backend stack:
cd ../backend-img-indexing
cdk destroy

  1. Delete the OpenSearch roles stack:
cd ../create-opensearch-roles
cdk destroy

The cdk destroy command will take away most sources robotically, however there is likely to be some sources that require handbook deletion equivalent to S3 buckets with content material and OpenSearch collections. Ensure to test the AWS Administration Console to confirm that each one sources have been correctly eliminated. For extra details about the cdk destroy command, see the AWS CDK Command Line Reference.

Conclusion

This publish has offered an answer that enhances advertising and marketing content material creation by combining generative AI with insights from historic campaigns. Utilizing Amazon OpenSearch Serverless and Amazon Bedrock, we constructed a system that effectively searches and makes use of reference photos from earlier advertising and marketing campaigns. The system filters these photos based mostly on marketing campaign targets and goal audiences, serving to to make sure strategic alignment. These references then feed into our immediate engineering course of. Utilizing Amazon Nova Professional, we generate a immediate that mixes new marketing campaign necessities with insights from profitable previous campaigns, offering model consistency within the closing picture technology.

This implementation represents an preliminary step in utilizing generative AI for advertising and marketing. The whole answer, together with detailed implementations of the Lambda capabilities and configuration information, is obtainable in our GitHub repository for adaptation to particular organizational wants.

For extra info, see the next associated sources:


In regards to the authors

María Fernanda Cortés is a Senior Knowledge Scientist on the Skilled Providers crew of AWS. She’s centered on designing and creating end-to-end AI/ML options to handle enterprise challenges for purchasers globally. She’s obsessed with scientific data sharing and volunteering in technical communities.

David Laredo is a Senior Utilized Scientist at Amazon, the place he helps innovate on behalf of consumers by the appliance of state-of-the-art methods in ML. With over 10 years of AI/ML expertise David is a regional technical chief for LATAM who consistently produces content material within the type of blogposts, code samples and public talking periods. He at present leads the AI/ML skilled group in LATAM.

Adriana Dorado is a Pc Engineer and Machine Studying Technical Area Neighborhood (TFC) member at AWS, the place she has been for five years. She’s centered on serving to small and medium-sized companies and monetary companies clients to architect on the cloud and leverage AWS companies to derive enterprise worth. Outdoors of labor she’s obsessed with serving because the Vice President of the Society of Girls Engineers (SWE) Colombia chapter, studying science fiction and fantasy novels, and being the proud aunt of an exquisite niece.

Yunuen Piña is a Options Architect at AWS, specializing in serving to small and medium-sized companies throughout Mexico to rework their concepts into progressive cloud options that drive enterprise progress.

Juan Pablo Duque is a Advertising Science Lead at Bancolombia, the place he merges science and advertising and marketing to drive effectivity and effectiveness. He transforms complicated analytics into compelling narratives. Keen about GenAI in MarTech, he writes informative weblog posts. He leads information scientists devoted to reshaping the advertising and marketing panorama and defining new methods to measure.

Leave a Reply

Your email address will not be published. Required fields are marked *