Skip to content

Commit e7c90d9

Browse files
committed
v0.3.33-NetworkVolume
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 2673712 commit e7c90d9

11 files changed

+253
-86
lines changed

Dockerfile_NetworkEndpoint

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Base image
22
FROM runpod/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04
33

4-
ENV PIP_PREFER_BINARY=1 \
5-
LD_PRELOAD=libtcmalloc.so \
4+
ENV DEBIAN_FRONTEND=noninteractive \
5+
PIP_PREFER_BINARY=1 \
66
PYTHONUNBUFFERED=1
77
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
88

Dockerfile_NetworkSetup

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM alpine:latest
1+
FROM alpine:3.19.1
22
RUN apk add --no-cache git curl
33

44
COPY builder/clone.sh /clone.sh

README.md

Lines changed: 5 additions & 5 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
1616
[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/network-guide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
## How to prepare Network Volume
22
- [**Create RunPod network volume:**](https://www.runpod.io/console/user/storage)
33
20GB is just enough for the generic Foocus with Juggernaut and **all** controlnet models (you can save some space by not downloading those you don't plan to use - by modifying the [script](https://github.com/davefojtik/RunPod-Fooocus-API/NetworkVolume/src/networksetup.sh) and making your own setup image). You can increase its size any time if you need additional models, loras etc. But unfortunately, it cannot be reduced back without creating a new one.
4-
- [**Create a custom CPU Pod Template:**](https://www.runpod.io/console/user/templates) use the `3wad/runpod-fooocus-api:v0.3.30-networksetup` image, 20GB disk size and mount path `/workspace`.
4+
- [**Create a custom CPU Pod Template:**](https://www.runpod.io/console/user/templates) use the `3wad/runpod-fooocus-api:v0.3.33-networksetup` image, 20GB disk size and mount path `/workspace`. *Note: 20GB is max for CPU pods, if you need more space, you'll have to use GPU pod even for the installation*
55
- [**Run a CPU pod:**](https://www.runpod.io/console/pods) with **network volume** and runpod-fooocus-api template you've just created. Any CPU pod will do, the installation is just download-intensive. After a while, you should see a "Setup complete!" message in Pod logs. After that, you can move to the serverless setup steps.
66
---
7-
- Now you can use our premade image: `3wad/runpod-fooocus-api:0.3.30-networkendpoint` 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.
7+
- Now you can use our premade image: `3wad/runpod-fooocus-api:0.3.33-networkendpoint` 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.
88
- *If you built your own image, upload it to the Docker Hub.*
99
- [**Create a custom Serverless Pod Template:**](https://www.runpod.io/console/user/templates) using the Docker Hub image you've just uploaded (or our premade one).
10-
- [**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 `3wad/runpod-fooocus-api:v0.3.30-networksetup` from the step 2. In Advanced settings choose your created network volume.
10+
- [**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 `3wad/runpod-fooocus-api:v0.3.33-networksetup` from the step 2. In Advanced settings choose your created network volume.
1111
- Other settings are your choice, but I personally found that using 4090/L4 GPUs + Flashboot is the most cost-effective one.
12-
- That's it! See the [request_examples]() for how to make requests to this endpoint from your app.
12+
- That's it! See the [request_examples]() for how to make requests to this endpoint from your app.

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 Fooocus 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)

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+
}

src/default.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
{
2-
"default_model": "juggernautXL_version6Rundiffusion.safetensors",
2+
"default_model": "juggernautXL_v8Rundiffusion.safetensors",
33
"default_refiner": "None",
44
"default_refiner_switch": 0.5,
55
"default_loras": [
66
[
7+
true,
78
"sd_xl_offset_example-lora_1.0.safetensors",
89
0.1
910
],
1011
[
12+
true,
1113
"None",
1214
1.0
1315
],
1416
[
17+
true,
1518
"None",
1619
1.0
1720
],
1821
[
22+
true,
1923
"None",
2024
1.0
2125
],
2226
[
27+
true,
2328
"None",
2429
1.0
2530
]
@@ -34,9 +39,17 @@
3439
"default_styles": [
3540
"Fooocus V2",
3641
"Fooocus Enhance",
37-
"Fooocus Sharp"],
42+
"Fooocus Sharp"
43+
],
3844
"default_aspect_ratio": "1152*896",
3945
"checkpoint_downloads": {},
4046
"embeddings_downloads": {},
41-
"lora_downloads": {}
47+
"lora_downloads": {},
48+
"previous_default_models": [
49+
"juggernautXL_version8Rundiffusion.safetensors",
50+
"juggernautXL_version7Rundiffusion.safetensors",
51+
"juggernautXL_v7Rundiffusion.safetensors",
52+
"juggernautXL_version6Rundiffusion.safetensors",
53+
"juggernautXL_v6Rundiffusion.safetensors"
54+
]
4255
}

0 commit comments

Comments
 (0)