GitHub - gitmagox/Fooocus-API: FastAPI powered API for Fooocus

Fooocus-API

Docker Image CI

FastAPI powered API for Fooocus

Currently loaded Fooocus version: 2.1.728

Run with Replicate

Now you can use Fooocus-API by Replicate, the model is in konieshadow/fooocus-api.

I believe this is the easiest way to generate image with Fooocus's power.

Colab

The colab notebook uses the Fooocus's colab branch, which may lack some latest features.

Colab Info
Open In Colab Fooocus-API

Reuse model files from Fooocus

You can simple copy user_path_config.txt file from your local Fooocus folder to Fooocus-API's root folder. See Customization for details.

Start app

Need python version >= 3.10, or use conda to create a new env.

conda env create -f environment.yaml
conda activate fooocus-api

Run

On default, server is listening on 'http://127.0.0.1:8888'

For pragram arguments, see

Start with docker

Run

docker run --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all -p 8888:8888 konieshadow/fooocus-api

For a more complex usage:

mkdir ~/repositories
mkdir -p ~/.cache/pip

docker run --gpus=all -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all \
    -v ~/repositories:/app/repositories \
    -v ~/.cache/pip:/root/.cache/pip \
    -p 8888:8888 konieshadow/fooocus-api

It will persistent the dependent repositories and pip cache.

Test API

You can open the Swagger Document in "http://127.0.0.1:8888/docs", then click "Try it out" to send a request.

Completed Apis

Swagger openapi defination see openapi.json.

You can import it in Swagger-UI editor.

All the generation api support for response in PNG bytes directly when request's 'Accept' header is 'image/png'.

All the generation api support async process by pass parameter `async_process`` to true. And then use query job api to retrieve progress and generation results.

Text to Image

POST /v1/generation/text-to-image

Alternative api for the normal image generation of Fooocus Gradio interface.

Image Upscale or Variation

POST /v1/generation/image-upscale-vary

Alternative api for 'Upscale or Variation' tab of Fooocus Gradio interface.

Image Inpaint or Outpaint

POST /v1/generation/image-inpait-outpaint

Alternative api for 'Inpaint or Outpaint' tab of Fooocus Gradio interface.

Image Prompt

POST /v1/generation/image-prompt

Alternative api for 'Image Prompt' tab of Fooocus Gradio interface.

Query Job

GET /v1/generation/query-job

Query async generation request results, return job progress and generation results.