This is a simple Python implementation using JSON to construct the prompts. The JSON files become assets you can keep for specific campaigns.
To reduce the amount of custom code, the solution leverages BQFlow AI helpers.
git clone https://github.com/google/bqflow
python3 -m pip install -r bqflow/requirements.txt
export PYTHONPATH=$PYTHONPATH:/$PWD/bqflow
For a step by step execution of the basic demo, run the shape_shifter_basic.ipynb colab notebook.
Used to generate advertising copy from JSON files.
The script authenticates against a GCP project and executes the given prompts. The included AI helpers from BQFlow are set to generate products correctly. If you want to modify the behavior of the AI please see the BQFlow modules.
python text.py text.json -p [GCP PROJECT] -u ~user.json -v
Results are in: generated/text_ads.json
The Prompt file consists of three parts:
The general prompt added to every AI call.
Specific pitches your are making to help tune towards an audience.
The products for which the ads are being generated.
These are variables used to customize the prompt and scenes. Each key is replaced with its value in the final prompt sent to the AI. This allows creating unlimited custom variants.
The resulting ads go into the generated/ads.json file. The program checks for ads that already exist and skips asking the AI for those.
- Create a JSON file for you products, pitches, and targeting.
- Generate a few ads and improve the prompts by editing the JSON.
- Once prompt is good, run all the variants.
- Review the file with the ads and remove any ads that need improving.
- Run the script again and repeat culling until satisfied.
- Transform the ads JSON into a CSV and upload the ads to the ad platform.
Adding campaign or ad level identifiers scenes, targeting, or images. This allows you to synchronize creatives with campaigns. For advanced users, modify the Python script to generate a mapping file.
Used to generate advertising images from JSON files.
The script authenticates against a GCP project and executes the given prompts. The included AI helpers from BQFlow are set to generate products correctly. If you want to modify the behavior of the AI please see the BQFlow modules.
python image.py image.json -p [GCP PROJECT] -u ~user.json -v
The Prompt file consists of three parts:
The general prompt added to every scene.
Currently sourced from ../docs/images/, these are loaded into the AI for editing. Each image has a name, path, and associated scenes the AI will generate.
These are specific prompts to render the product into.
These are variables used to customize the prompt and scenes. Each key is replaced with its value in the final prompt sent to the AI. This allows creating unlimited custom variants.
The resulting images go into the generated folder. The program checks for images that already exist and skips asking the AI for those. They have the following format:
generated/image_ads.json generated/IMAGE - SCENE - TARGETING - VARIANT.jpg
- IMAGE, SCENE, TARGETING are from the JSON file.
- VARIANT is 1 unless you alter the script to generate multiple prompt images.
- Create a JSON file for you product, scenes, and targeting.
- Generate a few images and improve the prompts by editing the JSON.
- Once prompt is good, run all the variants.
- Review the folder with the images and remove any images that need improving.
- Run the script again and repeat culling until satisfied.
- Upload the images as creatives to the ad platform.
Adding campaign or ad level identifiers scenes, targeting, or images. This allows you to synchronize creatives with campaigns. For advanced users, modify the Python script to generate a mapping file.