2022-09-11 14:47:54 +00:00
|
|
|
FROM arm64v8/debian
|
|
|
|
|
|
|
|
ARG gsd
|
|
|
|
ENV GITHUB_STABLE_DIFFUSION $gsd
|
|
|
|
ARG sdreq="requirements-linux-arm64.txt"
|
|
|
|
ENV SD_REQ $sdreq
|
|
|
|
|
|
|
|
WORKDIR /
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# TODO: Optimize image size
|
|
|
|
|
2022-09-11 14:47:54 +00:00
|
|
|
COPY entrypoint.sh anaconda.sh .
|
|
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# Update and apt 446 MB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN apt update && apt upgrade -y \
|
|
|
|
&& apt install -y \
|
|
|
|
git \
|
|
|
|
pip \
|
|
|
|
python3 \
|
|
|
|
wget
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# install Anaconda or Miniconda 610 MB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN bash anaconda.sh -b -u -p /anaconda && /anaconda/bin/conda init bash
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# SD repo 105 MB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN git clone $GITHUB_STABLE_DIFFUSION
|
|
|
|
|
|
|
|
WORKDIR /stable-diffusion
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# SD env 2.3 GB !!!
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN PIP_EXISTS_ACTION="w" \
|
|
|
|
# restrict the Conda environment to only use ARM packages. M1/M2 is ARM-based. You could also conda install nomkl.
|
|
|
|
&& CONDA_SUBDIR="osx-arm64" \
|
|
|
|
# Create the environment, activate it, install requirements.
|
|
|
|
&& source ~/.bashrc && conda create -y --name ldm && conda activate ldm \
|
|
|
|
&& pip3 install -r $SD_REQ \
|
|
|
|
&& mkdir models/ldm/stable-diffusion-v1
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# Face restoration prerequisites 200 MB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN apt install -y libgl1-mesa-glx libglib2.0-0
|
|
|
|
|
|
|
|
WORKDIR /
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# Face restoreation repo 12 MB
|
|
|
|
# by default expected in a sibling directory to stable-diffusion
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN git clone https://github.com/TencentARC/GFPGAN.git
|
|
|
|
|
|
|
|
WORKDIR /GFPGAN
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# Face restoration env 608 MB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN pip3 install basicsr facexlib \
|
|
|
|
&& pip3 install -r requirements.txt \
|
|
|
|
&& python3 setup.py develop \
|
|
|
|
# to enhance the background (non-face) regions and do upscaling
|
|
|
|
&& pip3 install realesrgan \
|
|
|
|
# pre-trained model needed for face restoration
|
|
|
|
&& wget https://github.com/TencentARC/GFPGAN/releases/download/v1.3.0/GFPGANv1.3.pth -P experiments/pretrained_models
|
|
|
|
|
|
|
|
WORKDIR /stable-diffusion
|
|
|
|
|
2022-09-11 16:03:33 +00:00
|
|
|
# Preload models 2 GB
|
2022-09-11 14:47:54 +00:00
|
|
|
RUN python3 scripts/preload_models.py
|
|
|
|
|
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|