Implementation of the DALL-E 3 from OpenAI into applications for fast image generation
In this article, I want to share how you can implement the DALL-E 3 model from OpenAI in your own application to generate stunning images from text descriptions.
Below is a function that generates an image and returns a link to this image.
def generate_image_from_text(prompt, size, quality, api_key):
client = OpenAI(api_key=api_key) # OpenAI API Key from https://openai.com/index/openai-api/
response = client.images.generate(
model="dall-e-3", # model for generating an image
prompt=prompt, # text prompt to generate an image
size=size, # image size: 1024x1024, 1792x1024, 1024x1792
quality=quality, # quality of the generated image: standard, hd
n=1
)
return response.data[0].url
To demonstrate how the program works, we have made a simple web application, below you can download the program and test it for yourself and use it in your projects.
Link to the project: https://github.com/Dataflow-kz/streamlit-ai-apps/tree/main/text-to-image-generator-app
- Streamlit;
- OpenAI (DALL-E 3);
- Requests;
Comments 4
Login to leave a comment
БЕХРУЗ ТОХТАМИШОВ · Sept. 26, 2024 15:48
🔥🔥
Nursultan Kabenov · Aug. 23, 2024 22:15
🔥
АСЕМ ДАВЛЕТЬЯРОВА · Aug. 7, 2024 00:22
очень интересно
Шахноза Алимханова · Aug. 6, 2024 13:48
интересно