To prepare the project, the following steps will be necessary:
- Install git locally;
- On your local server, run a
git clonecommand;
To execute the project, there's two ways to do it:
- First download python 3. After, install the dependencies by typing
pip install -r requirements.txtand runpython main.pyon your terminal if you just want to verify all the routes and see if the API algorithm is working;- If you already have Docker installed on you machine, run
docker-compose -f docker-compose.dev.yml up --build -don the terminal to create an image and container for the aplication (and for the cache server when it's available). This way allows you to install all application dependencies as well as automate the API testing process through docker;
In both flows, after uploading the application you can access it at localhost:8000/docs, as well as check the logs informations at localhost:8000/stable-diffusion/logs.
The repository features the following tool:
- This repository contains a tool in REST API format to generate images using the public stable diffusion model trained by the hugging face company 🤗.
- POST
/stable-diffusion/image - Request body
{
"text": "string"
}- Media type:
application/json - Response
{
"image": '_filename'.jpg
}- GET
/stable-diffusion/metrics - Media type:
text/plain - Response
"string"- GET
/stable-diffusion/logs - Media type:
text/plain - Response
"string"- GET
/stable-diffusion/health - Media type:
application/json - Response
{
"health": "string"
}After asking for a specific word, the API will return a AI created image related to the respective requested word, as shown in the following examples:
POST http://localhost:8000/stable-diffusion/image
Request Body:
{
"text": "A realistic image of Synthwave futuristic city"
}Response Body:
Request Body:
{
"text": "impressionist painting of a galaxy"
}Response Body:
- FastAPI
- Prometheus
- Graypy
- Diffusers
- Transformers
- StableDiffusion
- Redis

