forked from rohitgandikota/erasing
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathDockerfile_train
69 lines (57 loc) · 4.16 KB
/
Dockerfile_train
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
# Use the specified base image
FROM runpod/stable-diffusion:web-automatic-6.0.0
RUN \
pip3 install imageio moviepy opencv-python ftfy datasets scikit-image && \
pip3 install git+https://github.com/openai/CLIP.git --no-deps
# Clone the required repositories and install dependencies
RUN git clone https://github.com/CompVis/stable-diffusion.git /conceptmod && \
git clone https://github.com/ntc-ai/conceptmod /conceptmod_tmp && \
rsync -avh --force /conceptmod_tmp/* /conceptmod && \
rm -rf /conceptmod_tmp && \
cd /conceptmod && \
git clone https://github.com/THUDM/ImageReward
COPY smile.safetensors /stable-diffusion-webui/models/Lora/smile.safetensors
RUN echo 'echo "Installing dependencies..."' > ~/.bashrc
RUN git clone https://github.com/kohya-ss/sd-scripts.git /sd-scripts && \
cd /sd-scripts && \
python3.10 -m venv lora && \
source lora/bin/activate && \
pip install --upgrade pip && \
pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu117/torch_stable.html && \
pip install -r requirements.txt
RUN git clone https://github.com/CompVis/taming-transformers.git /taming-transformers
RUN echo 'echo " - - - this may take a minute - - - "' >> /root/.bashrc
# Create the installdeps.sh script and add it to .bashrc
RUN echo 'pip install --upgrade pip' > /conceptmod/installdeps.sh && \
echo 'pip install omegaconf einops torchmetrics datasets torch torchvision numpy scipy scikit-image scikit-learn tqdm lmdb' >> /conceptmod/installdeps.sh && \
echo 'pip install imageio moviepy opencv-python ftfy datasets scikit-image' >> /conceptmod/installdeps.sh && \
echo 'pip install kornia' >> /conceptmod/installdeps.sh && \
echo 'pip install git+https://github.com/openai/CLIP.git@main#egg=clip' >> /conceptmod/installdeps.sh && \
echo 'cd /workspace/conceptmod/ImageReward' >> /conceptmod/installdeps.sh && \
echo 'python setup.py develop > /dev/null 2>&1' >> /conceptmod/installdeps.sh && \
echo 'cd /taming-transformers' >> /conceptmod/installdeps.sh && \
echo 'python setup.py develop > /dev/null 2>&1' >> /conceptmod/installdeps.sh && \
echo '(cd /workspace/conceptmod/sd-scripts && source lora/bin/activate && pip install --upgrade pip && pip install torch torchvision torchaudio -f https://download.pytorch.org/whl/cu117/torch_stable.html && pip install -r requirements.txt)' >> /conceptmod/installdeps.sh && \
echo 'cd /workspace/conceptmod' >> /conceptmod/installdeps.sh && \
echo '[[ $- != *i* ]] || [ -f "$HOME/.first_login_complete" ] && return' >> ~/.bashrc && \
echo 'rsync -a --remove-source-files /conceptmod/* /workspace/conceptmod/ && cd /workspace/conceptmod' >> ~/.bashrc && \
echo 'rsync -a --remove-source-files /sd-scripts/* /workspace/conceptmod/sd-scripts' >> ~/.bashrc && \
echo 'source /workspace/conceptmod/installdeps.sh > /dev/null 2>&1' >> ~/.bashrc && \
echo 'touch $HOME/.first_login_complete' >> ~/.bashrc
# echo 'ln -s /workspace/conceptmod/models /workspace/stable-diffusion-webui/models/Stable-diffusion/conceptmod' >> ~/.bashrc && \
RUN echo 'echo "Welcome to conceptmod. Train on a phrase or animate a lora."' >> /root/.bashrc
RUN echo 'echo ""' >> /root/.bashrc
RUN echo 'echo "Usage tutorial here: https://civitai.com/models/58873"' >> /root/.bashrc
RUN echo 'echo "Examples: https://civitai.com/tag/conceptmod?sort=Newest"' >> /root/.bashrc
RUN echo 'echo "Documentation: https://github.com/ntc-ai/conceptmod"' >> /root/.bashrc
RUN echo 'echo ""' >> /root/.bashrc
RUN echo 'echo "To train: python3 train-scripts/train-esd.py --prompt \"~laugh\" --train_method selfattn --ckpt_path /workspace/stable-diffusion-webui/models/Stable-diffusion/mycheckpoint.safetensors"' >> /root/.bashrc
RUN echo 'echo ""' >> /root/.bashrc
RUN echo 'echo "To animate: python3 lora_anim.py -s 0 -e 2 -l smile -lp \", smile\""' >> /root/.bashrc
# Update the relauncher.py script to add --api flag
RUN sed -i 's/launch_string = "\/workspace\/stable-diffusion-webui\/webui.sh -f"/launch_string = "\/workspace\/stable-diffusion-webui\/webui.sh -f --api"/' /stable-diffusion-webui/relauncher.py
EXPOSE 3000
# Set the working directory
WORKDIR /conceptmod
# Run the anim.sh script
CMD ["bash", "/start.sh"]