Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,69 @@
|
|
| 1 |
-
|
| 2 |
-
import os
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
subprocess.call(['pip', 'install', 'pygit2==1.12.2'])
|
| 7 |
|
| 8 |
-
|
| 9 |
-
os.environ.pop('CUDA', None)
|
| 10 |
-
os.environ.pop('CUDA_VISIBLE_DEVICES', None)
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
os.chdir('Fooocus')
|
| 18 |
|
| 19 |
-
|
| 20 |
-
python_cmd = ['python', 'entry_with_update.py', '--share', '--always-high-vram']
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
|
|
|
|
| 2 |
|
| 3 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 4 |
+
TZ=America/Los_Angeles
|
|
|
|
| 5 |
|
| 6 |
+
ARG USE_PERSISTENT_DATA
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
RUN apt-get update && apt-get install -y \
|
| 9 |
+
git \
|
| 10 |
+
make build-essential libssl-dev zlib1g-dev \
|
| 11 |
+
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
|
| 12 |
+
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev git-lfs \
|
| 13 |
+
ffmpeg libsm6 libxext6 cmake libgl1-mesa-glx \
|
| 14 |
+
&& rm -rf /var/lib/apt/lists/* \
|
| 15 |
+
&& git lfs install
|
| 16 |
|
| 17 |
+
WORKDIR /code
|
|
|
|
| 18 |
|
| 19 |
+
COPY ./requirements.txt /code/requirements.txt
|
|
|
|
| 20 |
|
| 21 |
+
# User
|
| 22 |
+
RUN useradd -m -u 1000 user
|
| 23 |
+
USER user
|
| 24 |
+
ENV HOME=/home/user \
|
| 25 |
+
PATH=/home/user/.local/bin:$PATH
|
| 26 |
+
|
| 27 |
+
# Pyenv
|
| 28 |
+
RUN curl https://pyenv.run | bash
|
| 29 |
+
ENV PATH=$HOME/.pyenv/shims:$HOME/.pyenv/bin:$PATH
|
| 30 |
+
|
| 31 |
+
ARG PYTHON_VERSION=3.10.12
|
| 32 |
+
# Python
|
| 33 |
+
RUN pyenv install $PYTHON_VERSION && \
|
| 34 |
+
pyenv global $PYTHON_VERSION && \
|
| 35 |
+
pyenv rehash && \
|
| 36 |
+
pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
| 37 |
+
pip install --no-cache-dir \
|
| 38 |
+
datasets \
|
| 39 |
+
huggingface-hub "protobuf<4" "click<8.1"
|
| 40 |
+
|
| 41 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
| 42 |
+
|
| 43 |
+
# Set the working directory to /data if USE_PERSISTENT_DATA is set, otherwise set to $HOME/app
|
| 44 |
+
WORKDIR $HOME/app
|
| 45 |
+
|
| 46 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 47 |
+
|
| 48 |
+
RUN git clone https://github.com/lllyasviel/Fooocus . && \
|
| 49 |
+
# pin to a specific commit
|
| 50 |
+
git checkout bd4d40203c7e727fd06fc58ec122c25befcc5644 && \
|
| 51 |
+
pip install --no-cache-dir xformers==0.0.20 triton==2.0.0 torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118 && \
|
| 52 |
+
pip install --no-cache-dir -r requirements_versions.txt
|
| 53 |
+
|
| 54 |
+
# remove the next line if you're running on your own GPU, it set max images to 3 and disables the API
|
| 55 |
+
RUN sed -i "s|image_number = gr.Slider(label='Image Number', minimum=1, maximum=32|image_number = gr.Slider(label='Image Number', minimum=1, maximum=3|" webui.py && \
|
| 56 |
+
sed -i "s|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue()|shared.gradio_root = gr.Blocks(title='Fooocus ' + fooocus_version.version, css=modules.html.css).queue(concurrency_count=1,api_open=False)|" webui.py && \
|
| 57 |
+
sed -i "s|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share)|shared.gradio_root.launch(inbrowser=True, server_name=args.listen, server_port=args.port, share=args.share, show_api=False)|" webui.py
|
| 58 |
+
|
| 59 |
+
ENV HOME=/home/user \
|
| 60 |
+
PATH=/home/user/.local/bin:$PATH \
|
| 61 |
+
PYTHONPATH=$HOME/app \
|
| 62 |
+
PYTHONUNBUFFERED=1 \
|
| 63 |
+
GRADIO_ALLOW_FLAGGING=never \
|
| 64 |
+
GRADIO_NUM_PORTS=1 \
|
| 65 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
| 66 |
+
GRADIO_THEME=huggingface \
|
| 67 |
+
SYSTEM=spaces
|
| 68 |
+
|
| 69 |
+
CMD ["python", "entry_with_update.py", "--listen"]
|