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

Commit bb6bbf0

Browse files
committed
v0.3.33-Standalone
Update Release compatible with Fooocus-API v0.3.33 Changelog: - Added preview streaming based on #11 - Added inpainting methods based on #13 - Updated and refractored code - Changed used model to Juggernaut V8 See docs/request_examples.js to learn how to use the new params
1 parent 648e3f7 commit bb6bbf0

9 files changed

Lines changed: 256 additions & 87 deletions

File tree

Dockerfile

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,21 @@ COPY builder/clone.sh /clone.sh
66

77
# Clone the repos
88
# Fooocus-API
9-
RUN . /clone.sh /workspace https://github.com/konieshadow/Fooocus-API.git 074a956d2fc6e12e9b669cfe6611fd576dd7e315
9+
RUN . /clone.sh /workspace https://github.com/mrhan1993/Fooocus-API.git 1c6eb9822564e43585591d137c4c117c5f100694
1010
# Fooocus
11-
RUN . /clone.sh /workspace/repositories/Fooocus https://github.com/lllyasviel/Fooocus.git 624f74a1ed78ea09467c856cef35aeee0af863f6
11+
RUN . /clone.sh /workspace/repositories/Fooocus https://github.com/lllyasviel/Fooocus.git e9bc5e50c6a9e9502e822d308cb370883c4ef202
1212

13+
# Separate model stage to maintain build cache #
14+
# -------------------------------------------------------------------- #
15+
# You can use links with RUN wget or COPY to load files from your PC
16+
FROM alpine:3.19.1 as models
1317
RUN apk add --no-cache wget
14-
# Models (You can use cloud links with RUN wget or COPY to load files from your PC)
18+
1519
#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
20+
#COPY your/path_relative_to_dockerfile/model.safetensors /workspace/repositories/Fooocus/models/checkpoints/destinationmodelname.safetensors
1821

19-
# These are all the models Fooocus needs by default
20-
COPY models/juggernautXL_version6Rundiffusion.safetensors /workspace/repositories/Fooocus/models/checkpoints/juggernautXL_version6Rundiffusion.safetensors
22+
# These are all the models Fooocus needs by default (you can download them also from https://huggingface.co/3WaD/RunPod-Fooocus-API/tree/main)
23+
COPY models/juggernautXL_v8Rundiffusion.safetensors /workspace/repositories/Fooocus/models/checkpoints/juggernautXL_v8Rundiffusion.safetensors
2124
COPY models/sd_xl_offset_example-lora_1.0.safetensors /workspace/repositories/Fooocus/models/loras/sd_xl_offset_example-lora_1.0.safetensors
2225
COPY models/sdxl_lcm_lora.safetensors /workspace/repositories/Fooocus/models/loras/sdxl_lcm_lora.safetensors
2326
COPY models/fooocus_inpaint_head.pth /workspace/repositories/Fooocus/models/inpaint/fooocus_inpaint_head.pth
@@ -42,13 +45,11 @@ COPY models/model_base_caption_capfilt_large.pth /workspace/repositories/Fooocus
4245
# ---------------------------------------------------------------------------- #
4346
# Part 2: Build the final image #
4447
# ---------------------------------------------------------------------------- #
45-
FROM python:3.10.13-slim as build_final_image
48+
FROM python:3.10.14-slim as build_final_image
4649
ENV DEBIAN_FRONTEND=noninteractive \
4750
PIP_PREFER_BINARY=1 \
48-
LD_PRELOAD=libtcmalloc.so \
4951
PYTHONUNBUFFERED=1
5052
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'
5253

5354
# Update and upgrade the system packages
5455
RUN apt-get update && \
@@ -61,6 +62,7 @@ RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip
6162

6263
# Copy downloaded data to the final image
6364
COPY --from=download /workspace/ /workspace/
65+
COPY --from=models /workspace/repositories/Fooocus/models /workspace/repositories/Fooocus/models
6466
# Change Fooocus configs
6567
COPY src/config.txt /workspace/repositories/Fooocus/config.txt
6668
COPY src/default.json /workspace/repositories/Fooocus/presets/default.json

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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)
1+
![Static Badge](https://img.shields.io/badge/API_version-0.3.33-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/Fooocus_version-2.3.0-lightgrey)
22

33
# RunPod-Fooocus-API
44

@@ -8,15 +8,15 @@ This repository consists of two branches:
88
![image](https://github.com/davefojtik/RunPod-Fooocus-API/assets/66263283/88d74dd7-2dcd-44a8-af01-f1ce29bfb713)
99

1010

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.
11+
The **NetworkVolume** expects you to install and prepare your own `Fooocus-API v0.3.33` instance on the RunPod network volume, or to use our `3wad/runpod-fooocus-api:0.3.33-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.
1212

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.
13+
The **Standalone** branch is a 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 content, but it 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 the need 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.33-standalone` as the image for a quick deploy with the default Juggernaut V8 on your RunPod serverless endpoint.
1414

1515
## How to send requests
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.
16+
[request_examples.js](https://github.com/davefojtik/RunPod-Fooocus-API/blob/NetworkVolume/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.
1717

1818
## Contributors Welcomed
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.
19+
Feel free to make pull requests, fixes, improvements and suggestions to the code. I can spend only limited time on this as it's only a side tool project for an AI Agent. So any cooperation will help manage this repo better.
2020

2121
## 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.
22+
The version of compatible Fooocus-API is always stated at 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 thorough tests on our community discord bot, and only if we see that the new version performs better or solves some problems.

builder/requirements.txt

Lines changed: 7 additions & 2 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.6.0
6+
runpod==1.6.2
77

88
# Pulled from https://github.com/konieshadow/Fooocus-API/blob/main/requirements.txt
99
torchsde==0.2.5
@@ -26,4 +26,9 @@ 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
29+
uvicorn[standard]==0.23.2
30+
colorlog
31+
requests
32+
numpy
33+
sqlalchemy
34+
packaging

docs/request_examples.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
1-
// ########################
21
// EXAMPLE REQUEST PAYLOADS
32
// ########################
43
// The requests can be done in several possible ways:
54
// - Send the payload (with require_base64:true on img endpoints) to https://api.runpod.ai/v2/$your-endpont-id/runsync, in this case your app will simply send a request and wait for the final response. (This works fine if the requests don't take too long and you don't have enough of them to be queued)
65
// - Send the payload (with require_base64:true on img endpoints) to https://api.runpod.ai/v2/$your-endpont-id/run, in this async case your app will send a request, immediately receive obj with runpod job id that you can then use to receive the final result on https://api.runpod.ai/v2/$your-endpoint-id/status/$id
76
// To get notified when the job is finished, you can either use the Fooocus-API webhook feature, or you can just periodically fetch the job's status endpoint
7+
// - Send the payload (with require_base64:true, async_process:true and preview_url:"https://your.app/endpoint") to https://api.runpod.ai/v2/$your-endpont-id/run, in this case your app's listening endpoint will receive POST requests with previews periodically and also the final img once it's finished.
88
// - You can also customize the handler.py and add your own logic at the end, for example to save the image files into some external storage.
99

10+
// Contents:
11+
// 1. Minimal required
12+
// 2. Full payload
13+
// 3. Custom params (async preview stream, ..)
14+
15+
1016
// ----------------------------------------------------
11-
// Part one: Minimal required
17+
// 1: Minimal required
1218
// ----------------------------------------------------
1319

1420
// **************************
@@ -298,6 +304,7 @@ models_refresh =
298304
"api_name":"models-refresh",
299305
}
300306
}
307+
// WARNING! This endpoint is deprecated! Features are merged into all-models endpoint. This endpoint will be removed in next releases!
301308
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':{"model_filenames": ["string"],"lora_filenames": ["string"]}, "status":"COMPLETED"}
302309

303310
// ----------------
@@ -312,10 +319,8 @@ styles =
312319
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':["string"], "status":"COMPLETED"}
313320

314321

315-
316-
317322
// ----------------------------------------------------
318-
// Part two: Full payload
323+
// 2: Full payload
319324
// ----------------------------------------------------
320325
// The basic idea of params on v1/v2 (multipart/form-data vs. application/json) endpoints is:
321326
// on v2 params can be standard json format, on v1 they have to be sent stringified.
@@ -348,4 +353,17 @@ v2 =
348353
"adaptive_cfg":7
349354
}
350355
}
351-
}
356+
}
357+
358+
// ----------------------------------------------------
359+
// 3: Custom params
360+
// ----------------------------------------------------
361+
// To overcome some differences which arise from running this on RunPod serverless
362+
// we have to add several custom parameters to our payloads that are not part of the original Fooocus-API
363+
364+
"api_name" // "string" - Chooses what Fooocus-API endpoint we're actually calling
365+
"preview_url" // "string" - If you use Fooocus-API "async_process:true" and want to get a stream of preview images, you should add your app's url endpoint where POST requests with previews will arrive
366+
"preview_interval" // "number" - Optional param when using preview_url, sets how often in seconds the preview is checked and sent to your app. If not set defaults to 1
367+
"preview_headers" // "object" - Optional param when using preview_url, sets custom headers to send with the preview request (for tokens, auth etc.)
368+
"inpaint_preset" // "string" - Custom fix for missing "Inpaint Method" selection in Fooocus-API. Can be one of: 'Improve Detail', 'Modify Content' or 'Inpaint or Outpaint'
369+
"clear_output" // "boolean" - Chooses if you want to keep the image files on network volume/worker local storage or not. Can be true or false. Default is true (not saving image files)

docs/standalone-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
## How to use standalone image
2-
- [**Create RunPod serverless endpoint:**](https://www.runpod.io/console/serverless) use `3wad/runpod-fooocus-api:0.3.30-standalone`
2+
- [**Create RunPod serverless endpoint:**](https://www.runpod.io/console/serverless) use `3wad/runpod-fooocus-api:0.3.33-standalone`
33
- Other settings are your choice, but I personally found that using 4090/L4 GPUs + Flashboot is the most cost-effective one.
44
- That's it! See the [request_examples]() for how to make requests to this endpoint from your app.
55

66
## How to customize standalone image
77
To modify default settings and model, see [config.txt](https://github.com/davefojtik/RunPod-Fooocus-API/Standalone/src/config.txt) and [default.json](https://github.com/davefojtik/RunPod-Fooocus-API/Standalone/src/default.json)
8-
To modify which models and files are being baked into the image, see [Dockerfile](https://github.com/davefojtik/RunPod-Fooocus-API/Standalone/Dockerfile)
8+
To modify which models and files are being baked into the image, see [Dockerfile](https://github.com/davefojtik/RunPod-Fooocus-API/Standalone/Dockerfile)

src/config.txt

Lines changed: 117 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,121 @@
1-
2-
"path_checkpoints": "\\workspace\\repositories\\Fooocus\\models\\checkpoints",
3-
"path_loras": "\\workspace\\repositories\\Fooocus\\models\\loras",
4-
"path_embeddings": "\\workspace\\repositories\\Fooocus\\models\\embeddings",
5-
"path_vae_approx": "\\workspace\\repositories\\Fooocus\\models\\vae_approx",
6-
"path_upscale_models": "\\workspace\\repositories\\Fooocus\\models\\upscale_models",
7-
"path_inpaint": "\\workspace\\repositories\\Fooocus\\models\\inpaint",
8-
"path_controlnet": "\\workspace\\repositories\\Fooocus\\models\\controlnet",
9-
"path_clip_vision": "\\workspace\\repositories\\Fooocus\\models\\clip_vision",
10-
"path_fooocus_expansion": "\\workspace\\repositories\\Fooocus\\models\\prompt_expansion\\fooocus_expansion",
11-
"path_outputs": "\\workspace\\repositories\\Fooocus\\outputs",
12-
"default_model": "juggernautXL_version6Rundiffusion.safetensors",
13-
"default_refiner": "None",
14-
"default_refiner_switch": 0.5,
15-
"default_loras": [
16-
[
17-
"sd_xl_offset_example-lora_1.0.safetensors",
18-
0.1
1+
{
2+
"path_checkpoints": [
3+
"/workspace/repositories/Fooocus/models/checkpoints"
194
],
20-
[
21-
"None",
22-
1.0
5+
"path_loras": [
6+
"/workspace/repositories/Fooocus/models/loras"
237
],
24-
[
25-
"None",
26-
1.0
8+
"path_embeddings": "/workspace/repositories/Fooocus/models/embeddings",
9+
"path_vae_approx": "/workspace/repositories/Fooocus/models/vae_approx",
10+
"path_upscale_models": "/workspace/repositories/Fooocus/models/upscale_models",
11+
"path_inpaint": "/workspace/repositories/Fooocus/models/inpaint",
12+
"path_controlnet": "/workspace/repositories/Fooocus/models/controlnet",
13+
"path_clip_vision": "/workspace/repositories/Fooocus/models/clip_vision",
14+
"path_fooocus_expansion": "/workspace/repositories/Fooocus/models/prompt_expansion/fooocus_expansion",
15+
"path_wildcards": "/workspace/repositories/Fooocus/wildcards",
16+
"path_outputs": "/workspace/repositories/Fooocus/outputs",
17+
"temp_path": "/tmp/fooocus",
18+
"temp_path_cleanup_on_launch": true,
19+
"default_model": "juggernautXL_v8Rundiffusion.safetensors",
20+
"previous_default_models": [
21+
"juggernautXL_version8Rundiffusion.safetensors",
22+
"juggernautXL_version7Rundiffusion.safetensors",
23+
"juggernautXL_v7Rundiffusion.safetensors",
24+
"juggernautXL_version6Rundiffusion.safetensors",
25+
"juggernautXL_v6Rundiffusion.safetensors"
2726
],
28-
[
29-
"None",
30-
1.0
27+
"default_refiner": "None",
28+
"default_refiner_switch": 0.5,
29+
"default_loras_min_weight": -2,
30+
"default_loras_max_weight": 2,
31+
"default_loras": [
32+
[
33+
true,
34+
"sd_xl_offset_example-lora_1.0.safetensors",
35+
0.1
36+
],
37+
[
38+
true,
39+
"None",
40+
1.0
41+
],
42+
[
43+
true,
44+
"None",
45+
1.0
46+
],
47+
[
48+
true,
49+
"None",
50+
1.0
51+
],
52+
[
53+
true,
54+
"None",
55+
1.0
56+
]
3157
],
32-
[
33-
"None",
34-
1.0
35-
]
36-
],
37-
"default_cfg_scale": 4.0,
38-
"default_sample_sharpness": 2.0,
39-
"default_sampler": "dpmpp_2m_sde_gpu",
40-
"default_scheduler": "karras",
41-
"default_styles": [
42-
"Fooocus V2",
43-
"Fooocus Enhance",
44-
"Fooocus Sharp"
45-
],
46-
"default_prompt_negative": "",
47-
"default_prompt": "",
48-
"default_performance": "Speed",
49-
"default_advanced_checkbox": false,
50-
"default_max_image_number": 32,
51-
"default_image_number": 1,
52-
"checkpoint_downloads": {},
53-
"lora_downloads": {},
54-
"embeddings_downloads": {}
58+
"default_max_lora_number": 5,
59+
"default_cfg_scale": 4.0,
60+
"default_sample_sharpness": 2.0,
61+
"default_sampler": "dpmpp_2m_sde_gpu",
62+
"default_scheduler": "karras",
63+
"default_styles": [
64+
"Fooocus V2",
65+
"Fooocus Enhance",
66+
"Fooocus Sharp"
67+
],
68+
"default_prompt_negative": "",
69+
"default_prompt": "",
70+
"default_performance": "Speed",
71+
"default_advanced_checkbox": false,
72+
"default_max_image_number": 32,
73+
"default_output_format": "png",
74+
"default_image_number": 2,
75+
"checkpoint_downloads": {},
76+
"lora_downloads": {},
77+
"embeddings_downloads": {},
78+
"available_aspect_ratios": [
79+
"704*1408",
80+
"704*1344",
81+
"768*1344",
82+
"768*1280",
83+
"832*1216",
84+
"832*1152",
85+
"896*1152",
86+
"896*1088",
87+
"960*1088",
88+
"960*1024",
89+
"1024*1024",
90+
"1024*960",
91+
"1088*960",
92+
"1088*896",
93+
"1152*896",
94+
"1152*832",
95+
"1216*832",
96+
"1280*768",
97+
"1344*768",
98+
"1344*704",
99+
"1408*704",
100+
"1472*704",
101+
"1536*640",
102+
"1600*640",
103+
"1664*576",
104+
"1728*576"
105+
],
106+
"default_aspect_ratio": "1152*896",
107+
"default_inpaint_engine_version": "v2.6",
108+
"default_cfg_tsnr": 7.0,
109+
"default_overwrite_step": -1,
110+
"default_overwrite_switch": -1,
111+
"example_inpaint_prompts": [
112+
"highly detailed face",
113+
"detailed girl face",
114+
"detailed man face",
115+
"detailed hand",
116+
"beautiful eyes"
117+
],
118+
"default_save_metadata_to_images": false,
119+
"default_metadata_scheme": "fooocus",
120+
"metadata_created_by": ""
121+
}

0 commit comments

Comments
 (0)