A simple API that generates images from text prompts using stable diffusion. The main goal of this project is to explore stable diffusion techniques for image generation and provide a user-friendly interface for generating images by providing a text prompt. This API is lightweight, easy to use, and can be a great starting point for learning about text-to-image generation
- Python 3.7 or higher
- Pipenv
- A stable internet connection for downloading the model (approx. 10GB)
- A GPU for running the model (tested with Nvidia 2060 Super)
To generate an image using the API, send a GET request with the prompt query parameter:
http://localhost:5000/generate?prompt=Beautiful%20sunset%20over%20the%20oceanThis will return a generated image of a beautiful sunset over the ocean.
-
Clone the repository:
bash
git clone https://github.com/prakashrx/stable-diffusion.git cd stable-diffusion -
Install the dependencies using Pipenv:
pip install pipenv pipenv install
-
Activate the virtual environment:
pipenv shell -
Run the Flask app:
python app.py -
The API will be available at
http://localhost:5000/generate.
- Method:
GET - Query Parameters:
prompt(required): The text prompt to generate an image from.
- Response: An image in JPEG format.
