Contexts

AI Generated Images for Cognitive Tasks

Overview:

We systematically generated thousands of Context Images for our task’s backgrounds using the Dalle2 AI system, which creates realistic images from a description in natural language. This page details the steps we took to accomplish this.

Preparation / Excel Formation
  • Create context categories.
  • Create sub-categories and adjectives for each category.
  • Select artistic styles to apply to each category.
  • Create a numbering system for categories, sub-categories, adjectives, and art styles, giving each a unique identifier.
  • Structure the data in excel to contain a row for each category/sub-category, creating individual combinations that are the basis for the Python loops. 
  • Use excel formulas (V-Lookups) on the structured data to grab each categories corresponding ID and place it in a column next to the category name.  This allows the python loops to generate the contexts based on their names, and then save the files based on their corresponding IDs.
Python / Context Generation:
  1. Convert your excel workbook into a CSV file.
  2. Create a Python script:
    • Import Dalle2, CSV, and Requests.
    • Go to https://github.com/ezzcodeezzlife/dalle2-in-python and follow the setup directions, which will walk you through how to obtain your Bearer Token. Once obtained, add your bearer key to your Python script.
    • Add a string variable with the directory path of where to save the contexts.

Next, create a Python Method that:

  • Reads in the converted CSV file,
  • Loops through the string combinations, generating a Dalle2 image for each string, and saving the strings in the directory specified above.
  • Note: We save each context with a file name matching the numbering system used in the excel file above. This allows for easy categorization and retrieval of specific contexts.

Scroll to Top