This repo consists of a pipeline to generate an infinite image from a newsfeed via stable diffusion inpainting.
There's also a frontend app to showcase the results Outpainting App.
We use LAION aesthetic predictor as quality assurance. Each image gets rated after generation and based on that score we either take or throw away that image.
This file consists of a Flask API to serve the Outpainting App.
It also supports a small standalone page to control some functionality localhost:8000.
We use news APIs to get the latest news headlines. This module handles that.
This module has a database class to connect to a local SQLite database.
This is the heart of the project. It handles the outpainting process.
The outpainting config can be found in the outpainting_config.ini
file. This module handles that config.
A collection of various different helper functions we use throughout the project.
To start the docker container, run the following command
docker compose up -d
For the hosting the files in the /docker
directory are used.
- Set up a structure like the following.
. ├── docker-compose.yml ├── outpainting └── outpainting-app
- Clone the Outpainting App and the Outpainting repo.
- Copy the
docker-compose.yml
fromoutpainting/docker/docker-compose.yml
. - Adjust the URL in
outpainting-app/.env.production
to the URL of the API.
- Now you can run both containers with the following command.
docker compose up -d
- You should now see both containers running.
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 673a5c02efae stsiguet-outpainting-api "conda run -n outpai…" 1 seconds ago Up 1 second 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp stsiguet-outpainting-api 602efcd982c7 stsiguet-outpainting-app "docker-entrypoint.s…" 1 seconds ago Up 1 second 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp stsiguet-outpainting-app
- Finished! You can now access the app via localhost:8080 and the Development Interface via localhost:8000.
- Or via your IP/URL on ports 8080 and 8000.
Install the Anaconda environment from the provided file
conda env create -f environment.yml
Set up the environment manually
conda create --name outpainting python=3.10
conda activate outpainting
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
pip install --upgrade Flask
pip install --upgrade flask-cors
pip install --upgrade diffusers[torch]
pip install transformers
pip install accelerate
pip install waitress
pip install open-clip-torch
pip install newsapi-python
Activate the environment
conda activate outpainting
Add a huggingface token
huggingface-cli login --token $HUGGINGFACE_TOKEN
python flask-dev.py
python serve.py
Create an 'input' directory and add a file named 'prompts.json'. The structure should look like that in the 'prompts.json.example'.
python generate.py
If necessary get new API keys from NYTimes and NewsAPI and replace the legacy keys in config.ini
.