Member-only story

Build your own Text to Image AI app with diffusion models

Emad Dehnavi
6 min readMay 18, 2024

Have you ever tried the OpenAI DALL-E text-to-image app? it’s awesome isn’t? Do you like to build your own and run it in your local machine? then stay with me and by the end of this tutorial, you going to build your own text to image app.

Create a new Poetry project

We going to use Poetry for Python packaging and dependency management. Let’s create a new Poetry project:

poetry new text-to-image

if you don’t yet have Poetry installed, see this post: How to install Poetry in MacOS

This will create a new project with following file structure:

text-to-image
├── pyproject.toml
├── README.md
├── text_to_image
│ └── __init__.py
└── tests
└── __init__.py

Now, let’s add our dependencies to the project:

poetry add gradio numpy diffusers torch transformers accelerate

Now let’s see what are these dependencies:

  • Gradio: is an open-source Python package that allows you to quickly build a demo or web application for your machine learning model, API, or any arbitary Python function. With Gradio you also have the option to generate a shareable link for your project.
  • Numpy: it’s a package…

--

--

Emad Dehnavi
Emad Dehnavi

Written by Emad Dehnavi

With 8 years as a software engineer, I write about AI and technology in a simple way. My goal is to make these topics easy and interesting for everyone.

No responses yet