Skip to content
This repository was archived by the owner on Aug 2, 2025. It is now read-only.

Commit 0c7f95a

Browse files
committed
v0.3.30-Standalone
A major release introducing two types of workflows - NetworkVolume and Standalone
1 parent eff18cb commit 0c7f95a

File tree

10 files changed

+551
-387
lines changed

10 files changed

+551
-387
lines changed

Dockerfile

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,83 @@
1-
# Base image
2-
FROM runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04
1+
# ---------------------------------------------------------------------------- #
2+
# Part 1: Download the files #
3+
# ---------------------------------------------------------------------------- #
4+
FROM alpine/git:2.43.0 as download
5+
COPY builder/clone.sh /clone.sh
36

4-
# Use bash shell with pipefail option
5-
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
7+
# Clone the repos
8+
# Fooocus-API
9+
RUN . /clone.sh /workspace https://github.com/konieshadow/Fooocus-API.git 074a956d2fc6e12e9b669cfe6611fd576dd7e315
10+
# Fooocus
11+
RUN . /clone.sh /workspace/repositories/Fooocus https://github.com/lllyasviel/Fooocus.git 624f74a1ed78ea09467c856cef35aeee0af863f6
12+
13+
RUN apk add --no-cache wget
14+
# Models (You can use cloud links with RUN wget or COPY to load files from your PC)
15+
#RUN wget -q -O /workspace/repositories/Fooocus/models/checkpoints/juggernautXL_version6Rundiffusion.safetensors https://huggingface.co/lllyasviel/fav_models/resolve/main/fav/juggernautXL_version6Rundiffusion.safetensors
16+
# OR
17+
# COPY your/path_relative_to_dockerfile/model.safetensors /workspace/repositories/Fooocus/models/checkpoints/destinationmodelname.safetensors
618

7-
# Set the working directory
8-
WORKDIR /
19+
# These are all the models Fooocus needs by default
20+
COPY models/juggernautXL_version6Rundiffusion.safetensors /workspace/repositories/Fooocus/models/checkpoints/juggernautXL_version6Rundiffusion.safetensors
21+
COPY models/sd_xl_offset_example-lora_1.0.safetensors /workspace/repositories/Fooocus/models/loras/sd_xl_offset_example-lora_1.0.safetensors
22+
COPY models/sdxl_lcm_lora.safetensors /workspace/repositories/Fooocus/models/loras/sdxl_lcm_lora.safetensors
23+
COPY models/fooocus_inpaint_head.pth /workspace/repositories/Fooocus/models/inpaint/fooocus_inpaint_head.pth
24+
COPY models/inpaint.fooocus.patch /workspace/repositories/Fooocus/models/inpaint/inpaint.fooocus.patch
25+
COPY models/inpaint_v25.fooocus.patch /workspace/repositories/Fooocus/models/inpaint/inpaint_v25.fooocus.patch
26+
COPY models/inpaint_v26.fooocus.patch /workspace/repositories/Fooocus/models/inpaint/inpaint_v26.fooocus.patch
27+
COPY models/control-lora-canny-rank128.safetensors /workspace/repositories/Fooocus/models/controlnet/control-lora-canny-rank128.safetensors
28+
COPY models/fooocus_xl_cpds_128.safetensors /workspace/repositories/Fooocus/models/controlnet/fooocus_xl_cpds_128.safetensors
29+
COPY models/fooocus_ip_negative.safetensors /workspace/repositories/Fooocus/models/controlnet/fooocus_ip_negative.safetensors
30+
COPY models/ip-adapter-plus_sdxl_vit-h.bin /workspace/repositories/Fooocus/models/controlnet/ip-adapter-plus_sdxl_vit-h.bin
31+
COPY models/ip-adapter-plus-face_sdxl_vit-h.bin /workspace/repositories/Fooocus/models/controlnet/ip-adapter-plus-face_sdxl_vit-h.bin
32+
COPY models/fooocus_upscaler_s409985e5.bin /workspace/repositories/Fooocus/models/upscale_models/fooocus_upscaler_s409985e5.bin
33+
COPY models/clip_vision_vit_h.safetensors /workspace/repositories/Fooocus/models/clip_vision/clip_vision_vit_h.safetensors
34+
COPY models/xlvaeapp.pth /workspace/repositories/Fooocus/models/vae_approx/xlvaeapp.pth
35+
COPY models/vaeapp_sd15.pt /workspace/repositories/Fooocus/models/vae_approx/vaeapp_sd15.pth
36+
COPY models/xl-to-v1_interposer-v3.1.safetensors /workspace/repositories/Fooocus/models/vae_approx/xl-to-v1_interposer-v3.1.safetensors
37+
COPY models/fooocus_expansion.bin /workspace/repositories/Fooocus/models/prompt_expansion/fooocus_expansion/pytorch_model.bin
38+
COPY models/detection_Resnet50_Final.pth /workspace/repositories/Fooocus/models/controlnet/detection_Resnet50_Final.pth
39+
COPY models/parsing_parsenet.pth /workspace/repositories/Fooocus/models/controlnet/parsing_parsenet.pth
40+
COPY models/model_base_caption_capfilt_large.pth /workspace/repositories/Fooocus/models/clip_vision/model_base_caption_capfilt_large.pth
41+
42+
# ---------------------------------------------------------------------------- #
43+
# Part 2: Build the final image #
44+
# ---------------------------------------------------------------------------- #
45+
FROM python:3.10.13-slim as build_final_image
46+
ENV DEBIAN_FRONTEND=noninteractive \
47+
PIP_PREFER_BINARY=1 \
48+
LD_PRELOAD=libtcmalloc.so \
49+
PYTHONUNBUFFERED=1
50+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
51+
RUN export TORCH_COMMAND='pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/rocm5.6'
952

10-
# Update and upgrade the system packages (Worker Template)
53+
# Update and upgrade the system packages
1154
RUN apt-get update && \
12-
apt-get upgrade -y && \
1355
apt install -y \
14-
fonts-dejavu-core rsync git jq moreutils aria2 wget libgoogle-perftools-dev procps && \
56+
fonts-dejavu-core rsync git jq moreutils aria2 wget libgoogle-perftools-dev procps libgl1 libglib2.0-0 && \
1557
apt-get autoremove -y && rm -rf /var/lib/apt/lists/* && apt-get clean -y
1658

17-
# Install Python dependencies (Worker Template)
59+
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip \
60+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
61+
62+
# Copy downloaded data to the final image
63+
COPY --from=download /workspace/ /workspace/
64+
# Change Fooocus configs
65+
COPY src/config.txt /workspace/repositories/Fooocus/config.txt
66+
COPY src/default.json /workspace/repositories/Fooocus/presets/default.json
67+
68+
# Install Python dependencies
1869
COPY builder/requirements.txt /requirements.txt
19-
RUN pip install --upgrade pip && \
70+
RUN --mount=type=cache,target=/root/.cache/pip \
71+
pip install --upgrade pip && \
2072
pip install --upgrade -r /requirements.txt --no-cache-dir && \
2173
rm /requirements.txt
2274

23-
# Add src files (Worker Template)
2475
ADD src .
2576

26-
# Cleanup section (Worker Template)
77+
# Cleanup
2778
RUN apt-get autoremove -y && \
2879
apt-get clean -y && \
2980
rm -rf /var/lib/apt/lists/*
3081

31-
# Remove the empty workspace directory, link to runpod network volume
32-
RUN rm -rf /workspace && \
33-
ln -s /runpod-volume /workspace
34-
35-
ADD src .
36-
RUN chmod +x /start.sh
82+
RUN chmod +x /start.sh
83+
CMD /start.sh

README.md

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
![Static Badge](https://img.shields.io/badge/API_version-0.3.29-blue) ![Static Badge](https://img.shields.io/badge/API_coverage-100%25-vividgreen) ![Static Badge](https://img.shields.io/badge/API_tests-passed-vividgreen) ![Static Badge](https://img.shields.io/badge/Known_bugs-1-red) ![Static Badge](https://img.shields.io/badge/Fooocus_version-2.0.78-lightgrey)
1+
![Static Badge](https://img.shields.io/badge/API_version-0.3.30-blue) ![Static Badge](https://img.shields.io/badge/API_coverage-100%25-vividgreen) ![Static Badge](https://img.shields.io/badge/API_tests-passed-vividgreen) ![Static Badge](https://img.shields.io/badge/Known_bugs-0-vividgreen) ![Static Badge](https://img.shields.io/badge/Fooocus_version-2.1.862-lightgrey)
22

33
# RunPod-Fooocus-API
44

5-
This is a RunPod Fooocus-API worker that expects a **Fooocus-API `v0.3.29`** instance installed on a RunPod Network Volume.
6-
For ready-to-use serverless endpoint image with this repo's code use: [`3wad/runpod-fooocus-api:0.3.29`](https://hub.docker.com/r/3wad/runpod-fooocus-api/tags)
7-
8-
## How to prepare Network Volume
9-
- [**Create RunPod network volume:**](https://www.runpod.io/console/user/storage)
10-
17GB is just enough for the generic Foocus with Juggernaut and all controlnet models. You can increase its size any time if you need additional models, loras etc. But unfortunately, it cannot be reduced back without creating new one.
11-
- [**Create a custom Pod Template:**](https://www.runpod.io/console/user/templates) and use the `konieshadow/fooocus-api:v0.3.29` image. I went with 30GB disk sizes, mount path `/workspace`, and expose `http 8888` and `tcp 22`.
12-
- [**Run a GPU pod:**](https://www.runpod.io/console/gpu-secure-cloud) with network volume and custom fooocus-api template you've just created. You don't need a strong GPU pod, the installation is CPU and download-intensive, but be aware that some older-gen pods might not support the required CUDA versions. Let it download and install everything. After the Juggernaut model is downloaded, use the connect button to load into the Fooocus-API docs running on the pod's 8888 port. Here you should try all the API methods you plan to use. Not only to verify they work, but also because additional up-to-date models are downloaded once you run inpaint, outpaint, upscale, vary and img2img (canny, face swap etc.) endpoints for the first time.
13-
- After that you are ready to connect to the pod's console and use `cp -r /app/* /workspace/` to copy everything into the persistent network volume
14-
- Once everything is copied successfully, you can terminate the pod. You have the network volume ready.
15-
---
16-
- Now you can use our premade image: `3wad/runpod-fooocus-api:0.3.29` and skip the next step OR create your custom docker image from this repo that will run on the actual serverless API. Feel free to adjust the code to your needs.
17-
- *If you built your own image, upload it to the Docker Hub.*
18-
- [**Create a custom Serverless Pod Template:**](https://www.runpod.io/console/serverless/user/templates) using the Docker Hub image you've just uploaded (or our premade one). Active container disk should be slightly bigger than the size of that docker image. In the case of our prebuild one, it's currently about 13.7GB
19-
- [**Create a new Serverless API Endpoint:**](https://www.runpod.io/console/serverless) Make sure to choose your (or our) Docker Hub image and not the `konieshadow/fooocus-api` from the step 2. In Advanced settings choose your created network volume.
20-
- Other settings are your choice, but I personally found that using 4090/L4 GPUs + Flashboot is the most cost-effective one. In frequent use, the 4090 is able to return a txt2img in ~8s including cold start, making it **~25x** cheaper to run Fooocus on RunPod than for example using DALLE-3 API. **(01/24 prices: 0,0016usd/img vs 0,04usd/img), This fact can of course vary based on datacenter locations and GPU availability.*
5+
This repository consists of two branches:
6+
[NetworkVolume](https://github.com/davefojtik/RunPod-Fooocus-API/tree/NetworkVolume) and [Standalone](https://github.com/davefojtik/RunPod-Fooocus-API/tree/Standalone)
7+
8+
![image](https://github.com/davefojtik/RunPod-Fooocus-API/assets/66263283/88d74dd7-2dcd-44a8-af01-f1ce29bfb713)
9+
10+
11+
The **NetworkVolume** expects you to install and prepare your own `Fooocus-API v0.3.30` instance on the RunPod network volume, or to use our `3wad/runpod-fooocus-api:0.3.30-networksetup` image. This is ideal if you want to change models, loras or other contents on the fly. The downside of this solution is slower starts, especially when the endpoint is not used frequently. See [network-guide](https://github.com/davefojtik/RunPod-Fooocus-API/blob/NetworkVolume/docs/network-guide.md) for step by step instructions.
12+
13+
The **Standalone** branch is ready-to-use docker image with all the files and models already baked and installed into it. You can still customize it to use your own contents, but they can't be changed without rebuilding and redeploying the image. This is ideal if you want the fastest, cheapest possible endpoint for long-term usage without needs for frequent changes of models or loras. See [standalone-guide](https://github.com/davefojtik/RunPod-Fooocus-API/blob/Standalone/docs/standalone-guide.md) or simply use `3WaD/RunPod-Fooocus-API:v0.3.30-standalone` as the image for a quick "default" deploy on your RunPod serverless endpoint.
2114

2215
## How to send requests
23-
[request_examples.js](https://github.com/davefojtik/RunPod-Fooocus-API/blob/main/request_examples.js) contain example payloads for all endpoints on your serverless worker. But don't hesitate to ask in the [Discussions](https://github.com/davefojtik/RunPod-Fooocus-API/discussions) if you need more help.
16+
[request_examples.js](https://github.com/davefojtik/RunPod-Fooocus-API/blob/Standalone/docs/request_examples.js) contain example payloads for all endpoints on your serverless worker, regardless of the branch. But don't hesitate to ask if you need more help.
2417

2518
## Contributors Welcomed
26-
Feel free to do pull requests, fixes, improvements and suggestions to the code. I can spend only limited time on this as it's a side project for our community discord bot. So any cooperation will help manage this repo better.
19+
Feel free to do pull requests, fixes, improvements and suggestions to the code. I can spend only limited time on this as it's a side project for our community discord bot. So any cooperation will help manage this repo better.
20+
21+
## Updates
22+
The version of compatible Fooocus-API is always stated on the top of this readme. We're not always on the latest version automatically, as there can be breaking changes. The updates are being made only after troughrough tests on our community discord bot.

builder/clone.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -Eeuox pipefail
4+
5+
mkdir -p "$1"
6+
cd "$1"
7+
git init
8+
git remote add origin "$2"
9+
git fetch origin "$3" --depth=1
10+
git reset --hard "$3"

builder/requirements.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Custom dependencies
55
requests-toolbelt==1.0.0
6-
runpod==1.3.4
6+
runpod==1.6.0
77

88
# Pulled from https://github.com/konieshadow/Fooocus-API/blob/main/requirements.txt
99
torchsde==0.2.5
@@ -26,5 +26,4 @@ fastapi==0.103.1
2626
pydantic==2.4.2
2727
pydantic_core==2.10.1
2828
python-multipart==0.0.6
29-
uvicorn[standard]==0.23.2
30-
sqlalchemy
29+
uvicorn[standard]==0.23.2

0 commit comments

Comments
 (0)