You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Instructions/Exercises/05-generate-images.md
+13-16Lines changed: 13 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -7,30 +7,32 @@ lab:
7
7
8
8
The Azure OpenAI Service includes an image-generation model named DALL-E. You can use this model to submit natural language prompts that describe a desired image, and the model will generate an original image based on the description you provide.
9
9
10
+
In this exercise, you'll use a DALL-E version 3 model to generate images based on natural language prompts.
11
+
10
12
This exercise will take approximately **25** minutes.
11
13
12
14
## Provision an Azure OpenAI resource
13
15
14
-
Before you can use Azure OpenAI models, you must provision an Azure OpenAI resource in your Azure subscription.
16
+
Before you can use Azure OpenAI to generate images, you must provision an Azure OpenAI resource in your Azure subscription. The resource must be in a region where DALL-E models are supported.
15
17
16
18
1. Sign into the **Azure portal** at `https://portal.azure.com`.
17
19
2. Create an **Azure OpenAI** resource with the following settings:
18
20
-**Subscription**: *Select an Azure subscription that has been approved for access to the Azure OpenAI service, including DALL-E*
19
21
-**Resource group**: *Choose or create a resource group*
20
-
-**Region**: **East US**\*
22
+
-**Region**: *Choose either **East US** or **Sweden Central***\*
21
23
-**Name**: *A unique name of your choice*
22
24
-**Pricing tier**: Standard S0
23
25
24
-
> \* DALL-E models are only available in Azure OpenAI service resources in the **East US**region.
26
+
> \* DALL-E 3 models are only available in Azure OpenAI service resources in the **East US**and **Sweden Central** regions.
25
27
26
28
3. Wait for deployment to complete. Then go to the deployed Azure OpenAI resource in the Azure portal.
27
29
28
30
## Explore image-generation in the DALL-E playground
29
31
30
32
You can use the DALL-E playground in **Azure OpenAI Studio** to experiment with image-generation.
31
33
32
-
1. In the Azure portal, on the **Overview** page for your Azure OpenAI resource, use the **Explore** button to open Azure OpenAI Studio in a new browser tab. Alternatively, navigate to [Azure OpenAI Studio](https://oai.azure.com) directly.
33
-
2. In the **Playground** section, select the **DALL-E** playground.
34
+
1. In the Azure portal, on the **Overview** page for your Azure OpenAI resource, use the **Explore** button to open Azure OpenAI Studio in a new browser tab. Alternatively, navigate to [Azure OpenAI Studio](https://oai.azure.com) directly at `https://oai.azure.com`.
35
+
2. In the **Playground** section, select the **DALL-E** playground. A deployment of the DALL-E model named *Dalle3* will be created automatically.
34
36
3. In the **Prompt** box, enter a description of an image you'd like to generate. For example, `An elephant on a skateboard` Then select **Generate** and view the image that is generated.
35
37
36
38

@@ -61,7 +63,7 @@ Now let's explore how you could build a custom app that uses Azure OpenAI servic
61
63
62
64
### Configure your application
63
65
64
-
Applications for both C# and Python have been provided. Both apps feature the same functionality. First, you'll complete some key parts of the application to enable using your Azure OpenAI resource.
66
+
Applications for both C# and Python have been provided. Both apps feature the same functionality. First, you'll add the endpoint and key for your Azure OpenAI resource to the app's configuration file.
65
67
66
68
1. In Visual Studio Code, in the **Explorer** pane, browse to the **Labfiles/05-image-generation** folder and expand the **CSharp** or **Python** folder depending on your language preference. Each folder contains the language-specific files for an app into which you're you're going to integrate Azure OpenAI functionality.
67
69
2. In the **Explorer** pane, in the **CSharp** or **Python** folder, open the configuration file for your preferred language
@@ -82,14 +84,9 @@ Now you're ready to explore the code used to call the REST API and generate an i
82
84
- Python: `generate-image.py`
83
85
84
86
2. Review the code that the file contains, noting the following key features:
85
-
- The code makes https requests to the endpoint for your service, including the key for your service in the header. Both of these values are obtained from the configuration file.
86
-
- The process consists of <u>two</u> REST requests: One to initiate the image-generation request, and another to retrieve the results.
87
-
The initial request includes the following data:
88
-
- The user-provided prompt that describes the image to be generated
89
-
- The number of images to be generated (in this case, 1)
90
-
- The resolution (size) of the image to be generated.
91
-
- The response header from the initial request includes an **operation-location** value that is used for the subsequent callback to get the results.
92
-
- The code polls the callback URL until the status of the image-generation task is *succeeded*, and then extracts and displays a URL for the generated image.
87
+
- The code makes an https request to the endpoint for your service, including the key for your service in the header. Both of these values are obtained from the configuration file.
88
+
- The request includes some parameters, including the prompt from on the image should be based, the number of images to generate, and the size of the generated image(s).
89
+
- The response includes a revised prompt that the DALL-E model extrapolated from the user-provided prompt to make it more descriptive, and the URL for the generated image.
93
90
94
91
### Run the app
95
92
@@ -112,9 +109,9 @@ Now that you've reviewed the code, it's time to run it and generate some images.
112
109
113
110
4. Wait for the image to be generated - a hyperlink will be displayed in the terminal pane. Then select the hyperlink to open a new browser tab and review the image that was generated.
114
111
115
-
> **TIP**: If the app can't find the header, wait a minute and try again. Newly deployed resources can take up to 5 minutes to become available.
112
+
> **TIP**: If the app doesn't return a response, wait a minute and try again. Newly deployed resources can take up to 5 minutes to become available.
116
113
117
-
6. Close the browser tab containing the generated image and re-run the app to generate a new image with a different prompt.
114
+
5. Close the browser tab containing the generated image and re-run the app to generate a new image with a different prompt.
0 commit comments