Бұл жазба автоматты түрде орыс тілінен аударылған. English
Бұл мақалада мен OpenAI-ден DALL-E 3 моделін мәтіндік сипаттамалардан таңғажайып кескіндер жасау үшін өз қосымшаңызда қалай жүзеге асыруға болатындығымен бөліскім келеді.
Төменде кескін жасайтын және сол кескінге сілтемені қайтаратын функция берілген.
def generate_image_from_text (шақыру, өлшем, сапа, api_key):
клиент = OpenAI (api_key=api_key) # OpenAI API Кілті https://openai.com/index/openai-api/
жауап = клиент.суреттер.генерациялау(
модель= "dall-e-3", # кескін жасауға арналған модель
prompt=prompt, # кескін жасау үшін мәтіндік шақыру
өлшем=өлшем, # сурет өлшемі: 1024x1024, 1792x1024, 1024x1792
сапа=сапа, # жасалған кескіннің сапасы: стандартты, hd
n=1
)
жауапты қайтару.деректер[0].url мекенжайы
Бағдарламаның қалай жұмыс істейтінін көрсету үшін біз қарапайым веб-қосымшаны жасадық, төменде сіз бағдарламаны жүктеп алып, оны өзіңіз тексеріп, өз жобаларыңызда қолдана аласыз.
Жобаға сілтеме: https://github.com/Dataflow-kz/streamlit-ai-apps/tree/main/text-to-image-generator-app
- Жеңілдетілген;
- Ашық (ДАЛЛ-Е 3);
- Өтініштер;
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;