Skip to content

Latest commit

 

History

History
66 lines (62 loc) · 4.12 KB

4.Generate images with Azure OpenAI Service.MD

File metadata and controls

66 lines (62 loc) · 4.12 KB

What is DALL-E?

  • DALL-E is a neural network based model that can generate graphical data from natural language input.
  • Put more simply, you can provide DALL-E with a description and it can generate an appropriate image.
  • For example, you might submit the following natural language prompt to DALL-E: A squirrel on a motorcycle
  • This prompt could result in the generation of graphical output such as the following image:
  • The images generated by DALL-E are original; they are not retrieved from a curated image catalog.
  • In other words, DALL-E is not a search system for finding appropriate images - it is an AI model that generates new images based on the data on which it was trained.

Explore DALL-E in Azure AI Studio

  • To experiment with DALL-E, use the Images playground to submit prompts and view the resulting generated images.
  • When using the playground, you can adjust the settings to specify:
    1. The resolution (size) of the generated images. Available sizes are 1024x1024 (which is the default value), 1792x1024, or 1024x1792.
    2. The image style to be generated (such as vivid or natural).
    3. The image quality (choose from standard or hd).

Use the Azure OpenAI REST API to consume DALL-E models

  • Initiate the image generation process by submitting a POST request. The request must contain the following parameters in a JSON body:
    1. prompt: The description of the image to be generated.
    2. n: The number of images to be generated. DALL-E 3 only supports n=1.
    3. size: The resolution of the image(s) to be generated (1024x1024, 1792x1024, or 1024x1792).
    4. quality Optional: The quality of the image (standard or hd). Defaults to standard.
    5. style Optional: The visual style of the image (natural or vivid). Defaults to vivid.
  • For example, the following JSON could be used to generate an 512 x 512 image of a badger wearing a tuxedo:
{
    "prompt": "A badger wearing a tuxedo",
    "n": 1,
    "size": "512x512",
    "quality": "hd", 
    "style": "vivid"
}
  • Using an older generation model such as DALL-E 2, the initial request does not immediately return the results of the image generation process.
    1. Instead, the response includes an operation-location header with a URL for a callback service that your application code can poll until the results of image generation are ready.
  • With DALL-E 3, the result from the request is processed synchronously with the response containing the URL for the generated image. The response is similar to the following JSON:
{
    "created": 1686780744,
    "data": [
        {
            "url": "<URL of generated image>",
            "revised_prompt": "<prompt that was used>"
        }
    ]
}
  1. The data element includes the url value, which references a PNG image file generated from the prompt that you can then view or download.
  2. The response also contains a revised prompt that was used to generate the image, which was updated by the system to achieve the most desirable results.

Knowledge check

  1. You want to use a model in Azure OpenAI to generate images. Which model should you use?
    1. DALL-E - The DALL-E model is used to generate images based on natural language prompts.
    2. GPT-35-Turbo
    3. Text-Davinci
  2. Which playground in Azure AI Studio should you use to utilize the DALL-E model?
    1. Completions
    2. Chat
    3. Images - The Images playground is used to explore image generation models.
  3. In a REST request to generate images, what does the n parameter indicate?
    1. The description of the desired image.
    2. The number of images to be generated - Correct The number of images to be generated is specified in the n parameter.
    3. The size of the image to be generated - The size of the desired image is specified in the size parameter