PASD / Dockerfile
fffiloni's picture
Update Dockerfile
aeccc0d
FROM pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y git libgl1-mesa-glx libglib2.0-0
RUN apt-get update && apt-get install -y unzip build-essential aria2 cmake llvm
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
PYTHONPATH=$HOME/app \
PYTHONUNBUFFERED=1 \
GRADIO_ALLOW_FLAGGING=never \
GRADIO_NUM_PORTS=1 \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_THEME=huggingface \
GRADIO_SHARE=False \
SYSTEM=spaces
# Set the working directory to the user's home directory
WORKDIR $HOME/app
# Clone your repository or add your code to the container
RUN git clone -b main https://github.com/fffiloni/PASD $HOME/app
RUN pip install torchaudio
RUN pip install torch --upgrade
RUN pip install torchaudio --upgrade
RUN pip install torchvision
RUN pip install -q spaces gradio gradio_imageslider diffusers==0.21.4 accelerate basicsr ultralytics salesforce-lavis webdataset pytorch_lightning
RUN pip install -q https://download.pytorch.org/whl/cu121/xformers-0.0.22.post7-cp310-cp310-manylinux2014_x86_64.whl
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/akhaliq/RetinaFace-R50/resolve/main/RetinaFace-R50.pth -d $HOME/app/annotator/ckpts -o RetinaFace-R50.pth
# Define base model URL
ENV BaseModelUrl=https://huggingface.co/runwayml/stable-diffusion-v1-5
ENV BaseModelDir=$HOME/app/checkpoints/stable-diffusion-v1-5
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/model_index.json -d ${BaseModelDir} -o model_index.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/vae/diffusion_pytorch_model.bin -d ${BaseModelDir}/vae -o diffusion_pytorch_model.bin
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/vae/diffusion_pytorch_model.safetensors -d ${BaseModelDir}/vae -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/vae/config.json -d ${BaseModelDir}/vae -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/unet/diffusion_pytorch_model.bin -d ${BaseModelDir}/unet -o diffusion_pytorch_model.bin
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/unet/diffusion_pytorch_model.safetensors -d ${BaseModelDir}/unet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/unet/config.json -d ${BaseModelDir}/unet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/tokenizer/vocab.json -d ${BaseModelDir}/tokenizer -o vocab.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/tokenizer/tokenizer_config.json -d ${BaseModelDir}/tokenizer -o tokenizer_config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/tokenizer/special_tokens_map.json -d ${BaseModelDir}/tokenizer -o special_tokens_map.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/tokenizer/merges.txt -d ${BaseModelDir}/tokenizer -o merges.txt
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/text_encoder/pytorch_model.bin -d ${BaseModelDir}/text_encoder -o pytorch_model.bin
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/text_encoder/model.safetensors -d ${BaseModelDir}/text_encoder -o model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/text_encoder/config.json -d ${BaseModelDir}/text_encoder -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/scheduler/scheduler_config.json -d ${BaseModelDir}/scheduler -o scheduler_config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/safety_checker/pytorch_model.bin -d ${BaseModelDir}/safety_checker -o pytorch_model.bin
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/resolve/main/safety_checker/model.safetensors -d ${BaseModelDir}/safety_checker -o model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/safety_checker/config.json -d ${BaseModelDir}/safety_checker -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M ${BaseModelUrl}/raw/main/feature_extractor/preprocessor_config.json -d ${BaseModelDir}/feature_extractor -o preprocessor_config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/majicmixRealistic_v6.safetensors -d $HOME/app/checkpoints/personalized_models -o majicmixRealistic_v6.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd/checkpoint-100000/scaler.pt -d $HOME/app/runs/pasd/checkpoint-100000 -o scaler.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd/checkpoint-100000/unet/config.json -d $HOME/app/runs/pasd/checkpoint-100000/unet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd/checkpoint-100000/unet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd/checkpoint-100000/unet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd/checkpoint-100000/controlnet/config.json -d $HOME/app/runs/pasd/checkpoint-100000/controlnet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd/checkpoint-100000/controlnet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd/checkpoint-100000/controlnet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light/checkpoint-120000/scaler.pt -d $HOME/app/runs/pasd_light/checkpoint-120000 -o scaler.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_light/checkpoint-120000/unet/config.json -d $HOME/app/runs/pasd_light/checkpoint-120000/unet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light/checkpoint-120000/unet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_light/checkpoint-120000/unet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_light/checkpoint-120000/controlnet/config.json -d $HOME/app/runs/pasd_light/checkpoint-120000/controlnet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light/checkpoint-120000/controlnet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_light/checkpoint-120000/controlnet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light_rrdb/checkpoint-100000/scaler.pt -d $HOME/app/runs/pasd_light_rrdb/checkpoint-100000 -o scaler.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_light_rrdb/checkpoint-100000/unet/config.json -d $HOME/app/runs/pasd_light_rrdb/checkpoint-100000/unet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light_rrdb/checkpoint-100000/unet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_light_rrdb/checkpoint-100000/unet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_light_rrdb/checkpoint-100000/controlnet/config.json -d $HOME/app/runs/pasd_light_rrdb/checkpoint-100000/controlnet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_light_rrdb/checkpoint-100000/controlnet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_light_rrdb/checkpoint-100000/controlnet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_rrdb/checkpoint-100000/scaler.pt -d $HOME/app/runs/pasd_rrdb/checkpoint-100000 -o scaler.pth
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_rrdb/checkpoint-100000/unet/config.json -d $HOME/app/runs/pasd_rrdb/checkpoint-100000/unet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_rrdb/checkpoint-100000/unet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_rrdb/checkpoint-100000/unet -o diffusion_pytorch_model.safetensors
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/raw/main/pasd_rrdb/checkpoint-100000/controlnet/config.json -d $HOME/app/runs/pasd_rrdb/checkpoint-100000/controlnet -o config.json
RUN aria2c --console-log-level=error -c -x 16 -s 16 -k 1M https://huggingface.co/camenduru/PASD/resolve/main/pasd_rrdb/checkpoint-100000/controlnet/diffusion_pytorch_model.safetensors -d $HOME/app/runs/pasd_rrdb/checkpoint-100000/controlnet -o diffusion_pytorch_model.safetensors
# Set the environment variable to specify the GPU device
ENV CUDA_DEVICE_ORDER=PCI_BUS_ID
ENV CUDA_VISIBLE_DEVICES=0
COPY app.py .
# Run your app.py script
CMD ["python", "app.py"]