Skip to content

Commit 9ca4913

Browse files
committed
v0.4.0.6-NetworkVolume
Update Release compatible with Fooocus-API v0.4.0.6 Changelog: - Fixed preview_stream and inpaint_preset for V1 endpoints - Updated and refractored code - Updated docs and added license See also [Fooocus-API changelog](https://github.com/mrhan1993/Fooocus-API/releases) to find out what's new in the API code and [Fooocus changelog](https://github.com/lllyasviel/Fooocus/releases) to see what's new in the included Fooocus version. This release is breaking some speed records on both cached and non-cached runs, surely give it it a try!
1 parent 32bcf42 commit 9ca4913

File tree

9 files changed

+766
-219
lines changed

9 files changed

+766
-219
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
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)
1+
![github-header](https://github.com/qodeindustries/Quinn-AI/assets/66263283/bf8149b2-cdc3-4a59-96fb-1d272221ef70)
2+
![Static Badge](https://img.shields.io/badge/API_version-0.4.0.6-blue) ![Static Badge](https://img.shields.io/badge/Fooocus_version-2.3.1-blue) ![Static Badge](https://img.shields.io/badge/API_coverage-100%25-vividgreen) ![Static Badge](https://img.shields.io/badge/API_tests-passed-vividgreen)
23

3-
# RunPod-Fooocus-API
4+
[Fooocus-API](https://github.com/mrhan1993/Fooocus-API) RunPod serverless worker implementation
5+
___
6+
Repository consists of two branches:
7+
[NetworkVolume](https://github.com/davefojtik/RunPod-Fooocus-API/tree/NetworkVolume) and [Standalone](https://github.com/davefojtik/RunPod-Fooocus-API/tree/Standalone)
48

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+
The **NetworkVolume** expects you to install and prepare your own instance on the RunPod network volume, or to use our `3wad/runpod-fooocus-api:0.4.0.6-networksetup` image for it. This is ideal if you want to change models, loras or other contents on the fly, let your users upload them, or persist generated image files. The downside of this solution is slower starts because everything has to be loaded over the datacenter's network. See [network-guide](https://github.com/davefojtik/RunPod-Fooocus-API/blob/NetworkVolume/docs/network-guide.md) for step-by-step instructions.
910

10-
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.
12-
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.
11+
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 its contents. See [standalone-guide](https://github.com/davefojtik/RunPod-Fooocus-API/blob/Standalone/docs/standalone-guide.md) or simply use `3WaD/runpod-fooocus-api:0.4.0.6-standalone` as the image for a quick deploy with the default Juggernaut V8 on your RunPod serverless endpoint.
1412

1513
## How to send requests
1614
[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.
1715

1816
## Contributors Welcomed
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.
17+
Feel free to make pull requests, fixes, improvements and suggestions to the code. Any cooperation on keeping this repo up-to-date and free of bugs is highly welcomed.
2018

2119
## Updates
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.
20+
We're not always on the latest version automatically, as there can be breaking changes or major bugs. The updates are being made only after thorough tests by our community of Discord users generating images with the AI agent using this repo as it's tool. And only if we see that the new version performs better and stable.
21+
___
22+
> *Disclaimer: This repo is in no way affiliated with RunPod Inc. All logos and names are owned by the authors. This is an unofficial community implementation*

builder/requirements.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pygit2==1.12.2
2222
opencv-contrib-python==4.8.0.74
2323
onnxruntime==1.16.3
2424
timm==0.9.2
25-
fastapi==0.103.1
25+
fastapi>=0.103.1
2626
pydantic==2.4.2
2727
pydantic_core==2.10.1
2828
python-multipart==0.0.6
@@ -31,4 +31,6 @@ colorlog
3131
requests
3232
numpy
3333
sqlalchemy
34-
packaging
34+
packaging
35+
rich
36+
chardet

docs/network-guide.md

Lines changed: 5 additions & 5 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/blob/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.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*
5-
- [**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.
4+
- [**Create a custom CPU Pod Template:**](https://www.runpod.io/console/user/templates) use the `3wad/runpod-fooocus-api:0.4.0.6-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*
5+
- [**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 terminate the pod and move to the serverless setup steps.
66
---
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.
7+
- Now you can use our premade image: `3wad/runpod-fooocus-api:0.4.0.6-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.33-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:0.4.0.6-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](https://github.com/davefojtik/RunPod-Fooocus-API/blob/NetworkVolume/docs/request_examples.js) for how to make requests to this endpoint from your app.

docs/request_examples.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ queryjob =
237237
}
238238
}
239239
// returns: {"delayTime": 0, "executionTime": 0,"id": "runpod-job-id","output": {"job_id": "fooocus-job-id", "job_type": "Text to Image", "job_stage": "WAITING", "job_progress": 0, "job_status": "string", "job_step_preview": "string", "job_result": [{"base64": "string","url": "string","seed": "string","finish_reason": "SUCCESS"}]},"status": "COMPLETED"}
240+
// NOTE: This endpoint, while working, does not make sense to be used on serverless. RunPod does not know which worker to send this request into.
241+
// YOU CAN USE ASYNC PREVIEW SENDING INSTEAD, SEE SECTION 3: CUSTOM PARAMS
240242

241243
// ----------------
242244
// **************************
@@ -248,6 +250,7 @@ jobqueue =
248250
}
249251
}
250252
// returns: {"delayTime": 0, "executionTime": 0,"id": "runpod-job-id","output": {"finished_size": 99,"last_job_id": "last-fooocus-job-id", "running_size": 0},"status": "COMPLETED"}
253+
// NOTE: This endpoint, while working, does not make sense to be used on serverless. RunPod does not know which worker to send this request into.
251254

252255
// ----------------
253256
// **************************
@@ -259,6 +262,7 @@ jobhistory =
259262
}
260263
}
261264
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':{"queue": [],"history": []}, "status":"COMPLETED"}
265+
// NOTE: This endpoint, while working, does not make sense to be used on serverless. RunPod does not know which worker to send this request into.
262266

263267
// ----------------
264268
// **************************
@@ -270,6 +274,7 @@ stop =
270274
}
271275
}
272276
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':{"msg": "success"}, "status":"COMPLETED"}
277+
// NOTE: This endpoint, while working, does not make sense to be used on serverless. RunPod does not know which worker to send this request into.
273278

274279
// ----------------
275280
// **************************
@@ -295,18 +300,6 @@ models =
295300
}
296301
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':{"model_filenames": ["string"],"lora_filenames": ["string"]}, "status":"COMPLETED"}
297302

298-
// ----------------
299-
// **************************
300-
models_refresh =
301-
// **************************
302-
{
303-
"input":{
304-
"api_name":"models-refresh",
305-
}
306-
}
307-
// WARNING! This endpoint is deprecated! Features are merged into all-models endpoint. This endpoint will be removed in next releases!
308-
// returns: {"delayTime": 0, "executionTime": 0, "id":"runpod-job-id", 'output':{"model_filenames": ["string"],"lora_filenames": ["string"]}, "status":"COMPLETED"}
309-
310303
// ----------------
311304
// **************************
312305
styles =
@@ -334,8 +327,9 @@ v1 =
334327
"outpaint_selections":"Top,Bottom,Left,Right", // This param is special. It's expecting "Python Literals seperated by commas". That's why it's not a stringified array in this case.
335328
"outpaint_distance_left": "-1",
336329
"require_base64": "true",
337-
"style_selections": "[\"Fooocus V2\", \"Fooocus Enhance\", \"Fooocus Sharp\"]",
338-
"advanced_params": "{\"adaptive_cfg\":7}"
330+
"style_selections": "['Fooocus V2', 'Fooocus Enhance', 'Fooocus Sharp']",
331+
"advanced_params": "{'adaptive_cfg':'7'}",
332+
"preview_headers": "{\"Cookie\":\"foo=bar\"}"
339333
}
340334
}
341335

@@ -351,19 +345,25 @@ v2 =
351345
"style_selections": ["Fooocus V2", "Fooocus Enhance", "Fooocus Sharp"],
352346
"advanced_params": {
353347
"adaptive_cfg":7
354-
}
348+
},
349+
"preview_headers": {"Cookie":"foo=bar"}
355350
}
356351
}
357352

353+
// To see the full Fooocus-API params documentation, please refer to:
354+
// https://github.com/mrhan1993/Fooocus-API/blob/a50ed2f7db116f49e168c634ce4fa639ca42dda7/docs/api_doc_en.md
355+
356+
358357
// ----------------------------------------------------
359358
// 3: Custom params
360359
// ----------------------------------------------------
361-
// To overcome some differences which arise from running Fooocus on RunPod serverless
360+
// To overcome some differences which arise from running this on RunPod serverless
362361
// we have to add several custom parameters to our payloads that are not part of the original Fooocus-API
363362

364363
"api_name" // "string" - Chooses what Fooocus-API endpoint we're actually calling
365364
"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
366365
"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
367366
"preview_headers" // "object" - Optional param when using preview_url, sets custom headers to send with the preview request (for tokens, auth etc.)
367+
// preview_headers should be json containing header and it's value, in V1 endpoints format them like this: "{\"Cookie\":\"foo=bar\"}"
368368
"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'
369369
"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: 0 additions & 121 deletions
This file was deleted.

0 commit comments

Comments
 (0)