Using Azure OpenAI Dall-E Image generation with Power Apps

3 minute read

Using Azure OpenAI Dall-E Image generation with Power Apps

Introduction

Dall-E is a neural network that can generate images from text descriptions. It is named after the artist Salvador Dali and the Pixar character WALL-E. Dall-E can create realistic and surrealistic images of anything one can imagine, such as a snail made of a harp, a radish wearing a tutu, or a painting of a capybara in a field of tulips.

This article will explain how Dall-E works, how to use it with Azure OpenAI, the benefits of using it, and how you can use it in Power Apps.

How Dall-E works

Dall-E uses a large-scale language model called GPT-3, which can generate natural language texts from any input. GPT-3 is trained on a huge corpus of text from the internet, and it can learn to generate coherent and diverse texts on any topic. Dall-E extends GPT-3 by adding a vision component, which can generate images from text inputs. Dall-E uses a technique called text-to-image synthesis, which converts natural language descriptions into pixel values. Dall-E can also generate images from incomplete or ambiguous texts, such as “an armchair in the shape of an avocado” or “a cat wearing a suit”.

The benefits of using Dall-E with Azure OpenAI

Using Dall-E with Azure OpenAI has many benefits, such as:

  • One can access the most advanced image generation model without any coding or infrastructure.
  • One can create unique and original images for one’s projects, such as logos, illustrations, posters, or memes.
  • One can explore one’s creativity and imagination by generating images from any text input.
  • One can learn more about the capabilities and limitations of artificial intelligence and its impact on society.

How to use Dall-E with Azure OpenAI

Azure OpenAI is a cloud service that provides access to the most advanced artificial intelligence models, such as GPT-3 and Dall-E. Azure OpenAI allows one to create and deploy applications that use these models without any coding or infrastructure. One can use Azure OpenAI to experiment with Dall-E and generate images from one’s text inputs. The following are the steps to use Dall-E with Azure OpenAI:

  1. Create an Azure account and sign up for Azure OpenAI.
  2. Go to the Azure OpenAI portal and select Dall-E from the list of models.
  3. Enter one’s text input in the query box and click on generate.
  4. Wait for a few seconds and see the images generated by Dall-E.
  5. One can also modify the text input or select different images from the grid.

The View code option provides the endpoint and key information on how to consume the Dall-E API.

On the Network tab of the browser, you should see a response with the id of the image generated.

You should see another GET request with the above generated id.

The response shows the URL to the image generated.

Postman Collection

We will now create a Postman collection of the above two requests.

The Postman collection is attached here for reference.

Custom Connector in Power Platform

With the Postman collection, we can proceed to create a custom connector in Power Platform.

Power Apps for Dall-E image generation

In the Power Apps app, add the custom connector (for e.g., named Dall-E) to get started. The canvas looks as follows with the basic elements in place.

The below table shows the events and code on each element.

Element Event Code
ButtonDownload OnSelect Download(ImageDallE.Image)
ImageDallE Image Text(First(varFinalResponse.result.data).url)
Timer OnSelect Set(varResponse, ‘Dall-E’.Prompt(“2023-06-01-preview”, {prompt: TextInput.Text, n:1, size:”1024x1024”}));
  Duration 10000

The app looks as follows:

Summary

Dall-E is a neural network that can generate images from text descriptions. It uses a large-scale language model called GPT-3, which can generate natural language texts from any input. Using Postman collection and custom connector in Power Platform, Dall-E can be consumed in Power Apps for image generation.

Leave a comment