File size: 9,778 Bytes
ff50340
 
 
 
 
 
b5eaf37
ff50340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bbed12c
f02dff4
ff50340
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d07de3e
 
ff50340
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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 torchvision==0.15.2 torchaudio==2.0.2
RUN pip install -q 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", "gradio_pasd.py"]