Ace your AI-102 certification! Discover the key to specifying image resolution in Azure OpenAI’s DALL-E using Python. Get the code snippet & boost your marketing application skills.
Table of Contents
Question
Your organization, Nutex Corporation, is developing a marketing application that allows users to create custom advertising visuals by generating images based on specific text prompts. The application uses Azure OpenAI’s DALL-E model to generate high-quality images for promotional campaigns.
Below is a snippet of the Python code you will be using to interact with the DALL-E API:
import openai openai.api_type = "azure" openai.api_base = "https://<your-endpoint>.openai.azure.com/" openai.api_version = "2023-06-01-preview" openai.api_key = "<your-api-key>" response = openai.Image.create( prompt="A dog by a lake at sunset", n=2, MISSING="1024x1024" ) image_url = response['data'][0]['url'] print("Generated image URL:", image_url)
Which of the following is the correct parameter to complete the blank in the code to ensure that the generated images match the desired resolution?
A. resolution
B. dimensions
C. size
D. scale
Answer
C. size
Explanation
You would use the size parameter to specify the dimensions of the generated image. In this scenario, setting it to “1024×1024” ensures that the output image will have a resolution of 1024 x 1024 pixels. Below is the complete code:
import openai openai.api_type = "azure" openai.api_base = "https://<your-endpoint>.openai.azure.com/" openai.api_version = "2023-06-01-preview" openai.api_key = "<your-api-key>" response = openai.Image.create( prompt=" A dog by a lake at sunset ", n=2, size ="1024x1024" ) image_url = response['data'][0]['url'] print("Generated image URL:", image_url)
You would not use the resolution parameter to specify the dimensions of the generated image. While the term “resolution” refers to the dimensions of an image, this is not a valid parameter name for the DALL-E API.
You would not use the dimensions parameter to specify the dimensions of the generated image. The term “dimensions” might seem relevant as it describes the width and height of an image. However, the DALL-E API uses the size parameter to specify these attributes.
You would not use the scale parameter to specify the dimensions of the generated image. The term “scale” is often used to describe resizing or scaling images, but it is not a valid parameter in the DALL-E API for specifying image resolution.
Microsoft Azure AI Engineer Associate AI-102 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Microsoft Azure AI Engineer Associate AI-102 exam and earn Microsoft Azure AI Engineer Associate AI-102 certification.