Skip to content

Commit 79d906c

Browse files
committed
- rewrite Dockerfile
- fix default_aspect_ratio - change default_loras, default_cfg_scale
1 parent 5acf0c8 commit 79d906c

File tree

5 files changed

+31
-17
lines changed

5 files changed

+31
-17
lines changed

Dockerfile

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
FROM nvidia/cuda:12.2.0-runtime-ubuntu22.04
1+
FROM pytorch/pytorch:2.1.0-cuda12.1-cudnn8-runtime
22

3-
ARG DEBIAN_FRONTEND=noninteractive
43
ENV TZ=Asia/Shanghai
54

6-
RUN apt-get update && \
7-
apt-get install --no-install-recommends -y python3 python3-pip python3-virtualenv && \
8-
apt-get install --no-install-recommends -y libopencv-dev python3-opencv && \
9-
rm -rf /var/lib/apt/lists/*
5+
WORKDIR /app
106

11-
ENV VIRTUAL_ENV=/opt/venv
12-
RUN virtualenv $VIRTUAL_ENV
13-
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
7+
COPY . /app
148

15-
RUN pip install packaging
9+
RUN pip install --no-cache-dir -r requirements.txt
1610

17-
WORKDIR /app
11+
RUN pip install --no-cache-dir opencv-python-headless
1812

19-
COPY . /app/
13+
EXPOSE 8888
2014

21-
CMD python3 main.py --host 0.0.0.0 --port 8888
15+
CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "8888", "--skip-pip"]

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ It will be persistent the dependent repositories and pip cache.
171171

172172
You can add `-e PIP_INDEX_URL={pypi-mirror-url}` to docker run command to change pip index url.
173173

174+
> From version 0.4.0.0, Full environment include in docker image, mapping `models` or project root if you needed
175+
> For example:
176+
> ```
177+
> docker run -d --gpus all \
178+
> -v /Fooocus-API:/app \
179+
> -p 8888:8888 konieshadow/fooocus-api
180+
>```
181+
174182
# cmd flags
175183
176184
- `-h, --help` show this help message and exit

README_zh.md

+8
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ docker run -d --gpus=all \
169169

170170
你还可以添加 `-e PIP_INDEX_URL={pypi-mirror-url}` 选项来更换 pip 源
171171

172+
> 0.4.0.0 版本开始,镜像包含完整运行环境,因此只需要根据需要将 `models` 或者项目根目录进行映射即可
173+
> 比如:
174+
> ```
175+
> docker run -d --gpus all \
176+
> -v /Fooocus-API:/app \
177+
> -p 8888:8888 konieshadow/fooocus-api
178+
>```
179+
172180
# 命令行参数
173181
174182
- `-h, --help` 显示本帮助并退出

fooocusapi/models/common/requests.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
"""Common model for requests"""
22
from typing import List
3-
from pydantic import BaseModel, Field
4-
from pydantic import ValidationError
3+
from pydantic import (
4+
BaseModel,
5+
Field,
6+
ValidationError
7+
)
58

69
from modules.config import (
710
default_sampler,
@@ -21,6 +24,7 @@
2124
default_loras_model
2225
)
2326

27+
default_aspect_ratio = default_aspect_ratio.split(" ")[0].replace("×", "*")
2428

2529
class QueryJobRequest(BaseModel):
2630
"""Query job request"""

fooocusapi/parameters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
default_base_model_name = "juggernautXL_v8Rundiffusion.safetensors"
3636
default_refiner_model_name = "None"
3737
default_refiner_switch = 0.5
38-
default_loras = [["sd_xl_offset_example-lora_1.0.safetensors", 0.1]]
39-
default_cfg_scale = 4.0
38+
default_loras = [[True, "sd_xl_offset_example-lora_1.0.safetensors", 0.1]]
39+
default_cfg_scale = 7.0
4040
default_prompt_negative = ""
4141
default_aspect_ratio = "1152*896"
4242
default_sampler = "dpmpp_2m_sde_gpu"

0 commit comments

Comments
 (0)