diff --git a/README.md b/README.md index 95e10c302..a67bd9f0f 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,14 @@ This repository provides multiple UIs for you to play around with stable diffusi | -------------------------------------------------------------------------------- | | ![](https://github.com/comfyanonymous/ComfyUI/raw/master/comfyui_screenshot.png) | +### [Fooocus](https://github.com/comfyanonymous/ComfyUI) + +[Full feature list here](https://github.com/lllyasviel/Fooocus#fooocus), Screenshot: + +| Simplified UI | +| -------------------------------------------------------------------------------- | +| ![](https://github.com/lllyasviel/Fooocus/assets/19834515/483fb86d-c9a2-4c20-997c-46dafc124f25) | + ## Contributing Contributions are welcome! **Create a discussion first of what the problem is and what you want to contribute (before you implement anything)** diff --git a/docker-compose.yml b/docker-compose.yml index a1cc6c265..c71318d8e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -71,3 +71,11 @@ services: deploy: {} environment: - CLI_ARGS=--cpu + + fooocus: &fooocus + <<: *base_service + profiles: ["fooocus"] + build: ./services/fooocus/ + image: sd-fooocus:3 + environment: + - CLI_ARGS= \ No newline at end of file diff --git a/services/comfy/Dockerfile b/services/comfy/Dockerfile index f813c6842..c784f1678 100644 --- a/services/comfy/Dockerfile +++ b/services/comfy/Dockerfile @@ -4,6 +4,15 @@ ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 RUN apt-get update && apt-get install -y git && apt-get clean +# add some packages for some custom nodes in comfyui +RUN apt-get install 'libglib2.0-0' -y +RUN apt-get update +RUN apt-get install 'libgl1-mesa-glx' -y +RUN apt-get install 'python-dev' -y + +# install pip package for codeformer face detection custom node +RUN pip install lpips + ENV ROOT=/stable-diffusion RUN --mount=type=cache,target=/root/.cache/pip \ git clone https://github.com/comfyanonymous/ComfyUI.git ${ROOT} && \ @@ -13,6 +22,15 @@ RUN --mount=type=cache,target=/root/.cache/pip \ pip install -r requirements.txt WORKDIR ${ROOT} + +ARG BRANCH=master SHA=c97be4db91d4a249c19afdf88fa1cf3268544e45 +RUN --mount=type=cache,target=/root/.cache/pip \ + git fetch && \ + git checkout ${BRANCH} && \ + git reset --hard ${SHA} && \ + pip install -r requirements.txt + +# add info COPY . /docker/ RUN chmod u+x /docker/entrypoint.sh && cp /docker/extra_model_paths.yaml ${ROOT} diff --git a/services/comfy/entrypoint.sh b/services/comfy/entrypoint.sh index b4299a717..e411fb5c9 100755 --- a/services/comfy/entrypoint.sh +++ b/services/comfy/entrypoint.sh @@ -10,6 +10,34 @@ MOUNTS["/root/.cache"]="/data/.cache" MOUNTS["${ROOT}/input"]="/data/config/comfy/input" MOUNTS["${ROOT}/output"]="/output/comfy" +# mount various locations for comfyui to keep custom nodes and models downloaded with comfyui manager +MOUNTS["${ROOT}/custom_nodes"]="/data/config/comfy/custom_nodes" + +MOUNTS["${ROOT}/models/checkpoints"]="/data/models/checkpoints" +#MOUNTS["${ROOT}/models/configs"]="/data/models/configs" +MOUNTS["${ROOT}/models/embeddings"]="/data/models/embeddings" +MOUNTS["${ROOT}/models/gligen"]="/data/models/gligen" +MOUNTS["${ROOT}/models/mmdets"]="/data/models/mmdets" +MOUNTS["${ROOT}/models/style_models"]="/data/models/style_models" +#MOUNTS["${ROOT}/models/vae"]="/data/models/vae" +#MOUNTS["${ROOT}/models/clip"]="/data/models/clip" +#MOUNTS["${ROOT}/models/controlnet"]="/data/models/controlnet" +MOUNTS["${ROOT}/models/facedetection"]="/data/models/facedetection" + +MOUNTS["${ROOT}/models/hypernetworks"]="/data/models/hypernetworks" + + +#MOUNTS["${ROOT}/models/onnx"]="/data/models/onnx" +#MOUNTS["${ROOT}/models/unet"]="/data/models/unet" +MOUNTS["${ROOT}/models/vae_approx"]="/data/models/vae-approx" +#MOUNTS["${ROOT}/models/clip_vision"]="/data/models/clip_vision" +#MOUNTS["${ROOT}/models/diffusers"]="/data/models/diffusers" +MOUNTS["${ROOT}/models/facerestore_models"]="/data/models/facerestore_models" +MOUNTS["${ROOT}/models/loras"]="/data/models/lora" +MOUNTS["${ROOT}/models/sams"]="/data/models/sams" +MOUNTS["${ROOT}/models/upscale_models"]="/data/models/upscale_models" + + for to_path in "${!MOUNTS[@]}"; do set -Eeuo pipefail from_path="${MOUNTS[${to_path}]}" diff --git a/services/comfy/extra_model_paths.yaml b/services/comfy/extra_model_paths.yaml index eb374eb30..c06cd46b6 100644 --- a/services/comfy/extra_model_paths.yaml +++ b/services/comfy/extra_model_paths.yaml @@ -4,7 +4,7 @@ a111: checkpoints: models/Stable-diffusion configs: models/Stable-diffusion vae: models/VAE - loras: models/Lora + #loras: models/Lora upscale_models: | models/RealESRGAN models/ESRGAN @@ -16,10 +16,24 @@ a111: clip: models/CLIPEncoder embeddings: embeddings - custom_nodes: config/comfy/custom_nodes + #custom_nodes: config/comfy/custom_nodes # TODO: I am unsure about these, need more testing # style_models: config/comfy/style_models # t2i_adapter: config/comfy/t2i_adapter # clip_vision: config/comfy/clip_vision # diffusers: config/comfy/diffusers + +# may not need these since I'm adding mounts instead + #facerestore_models: models/facerestore_models + #sams: models/sams + #unet: models/unet + #vae_approx: models/vae_approx + #face_restore: models/face_restore + #mmdets: models/mmdets + #style_models: models/style_models + #clip_vision: models/clip_vision + #diffusers: models/diffusers + #facedetection: models/facedetection + #onnx: models/onnx + #ultralytics: models/ultralytics \ No newline at end of file diff --git a/services/fooocus/Dockerfile b/services/fooocus/Dockerfile new file mode 100644 index 000000000..fc7de59ee --- /dev/null +++ b/services/fooocus/Dockerfile @@ -0,0 +1,47 @@ +FROM alpine:3.17 as xformers +RUN apk add --no-cache aria2 +RUN aria2c -x 5 --dir / --out wheel.whl 'https://github.com/AbdBarho/stable-diffusion-webui-docker/releases/download/6.0.0/xformers-0.0.21.dev544-cp310-cp310-manylinux2014_x86_64-pytorch201.whl' + +FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime + +ENV DEBIAN_FRONTEND=noninteractive PIP_PREFER_BINARY=1 + +RUN apt-get update && apt-get install -y git && apt-get clean + +# add in required packages +RUN apt-get install 'libglib2.0-0' -y +RUN apt-get install 'libgl1-mesa-glx' -y +RUN apt-get install 'python-dev' -y + +# set this to your target branch commit +ARG BRANCH=main SHA=d7439b2d6004d50a0fda19108603a8d1941a185e + +ENV ROOT=/stable-diffusion +RUN --mount=type=cache,target=/root/.cache/pip \ + git clone https://github.com/lllyasviel/Fooocus.git ${ROOT} && \ + cd ${ROOT} && \ + git checkout ${BRANCH} && \ + git reset --hard ${SHA} && \ + pip install -r requirements_versions.txt + + +RUN --mount=type=cache,target=/root/.cache/pip \ + --mount=type=bind,from=xformers,source=/wheel.whl,target=/xformers-0.0.21-cp310-cp310-linux_x86_64.whl \ + pip install /xformers-0.0.21-cp310-cp310-linux_x86_64.whl + +WORKDIR ${ROOT} + +RUN --mount=type=cache,target=/root/.cache/pip \ + git fetch && \ + git checkout ${BRANCH} && \ + git reset --hard ${SHA} && \ + pip install -r requirements_versions.txt + +# add info +COPY . /docker/ +RUN cp /docker/config.txt ${ROOT} +RUN chmod u+x /docker/entrypoint.sh + +EXPOSE 7860 +ENTRYPOINT ["/docker/entrypoint.sh"] +CMD python -u entry_with_update.py --listen --port 7860 ${CLI_ARGS} diff --git a/services/fooocus/config.txt b/services/fooocus/config.txt new file mode 100644 index 000000000..ddced7180 --- /dev/null +++ b/services/fooocus/config.txt @@ -0,0 +1,12 @@ +{ + "path_checkpoints": "/stable-diffusion/models/checkpoints", + "path_loras": "/stable-diffusion/models/loras", + "path_embeddings": "/stable-diffusion/models/embeddings", + "path_vae_approx": "/stable-diffusion/models/vae_approx", + "path_upscale_models": "/stable-diffusion/models/upscale_models", + "path_inpaint": "/stable-diffusion/models/inpaint", + "path_controlnet": "/stable-diffusion/models/controlnet", + "path_clip_vision": "/stable-diffusion/models/clip_vision", + "path_fooocus_expansion": "/stable-diffusion/models/prompt_expansion/fooocus_expansion", + "path_outputs": "/stable-diffusion/outputs" +} \ No newline at end of file diff --git a/services/fooocus/entrypoint.sh b/services/fooocus/entrypoint.sh new file mode 100644 index 000000000..cc0fa75b7 --- /dev/null +++ b/services/fooocus/entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -Eeuo pipefail + +mkdir -vp /data/config/fooocus/wildcards + +declare -A MOUNTS + +MOUNTS["${ROOT}/outputs"]="/output/fooocus" + +# ui specific mounts +MOUNTS["${ROOT}/models/checkpoints"]=/data/models/Stable-diffusion/ +MOUNTS["${ROOT}/models/loras"]=/data/models/Lora/ +MOUNTS["${ROOT}/models/embeddings"]=/data/models/embeddings/ +MOUNTS["${ROOT}/models/vae_approx"]=/data/models/VAE/ +MOUNTS["${ROOT}/models/upscale_models"]=/data/models/upscale_models/ +MOUNTS["${ROOT}/wildcards"]=/data/config/fooocus/wildcards + +for to_path in "${!MOUNTS[@]}"; do + set -Eeuo pipefail + from_path="${MOUNTS[${to_path}]}" + rm -rf "${to_path}" + mkdir -p "$(dirname "${to_path}")" + # ends with slash, make it! + if [[ "$from_path" == */ ]]; then + mkdir -vp "$from_path" + fi + + ln -sT "${from_path}" "${to_path}" + echo Mounted $(basename "${from_path}") +done + +exec "$@"