diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..9cb67cabd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +models/ +Dockerfile +README.md +LICENSE +assets/ +*.egg-info \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..cb5718768 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +models/ldm/text2img-large/ +outputs/ +src/ +__pycache__/ +*.egg-info diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..91985b519 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +FROM nvcr.io/nvidia/pytorch:22.04-py3 +MAINTAINER Peter Willemsen + +RUN conda + +RUN mkdir -p /opt/ldm_package +COPY ./setup.py /opt/ldm_package +COPY ./ldm /opt/ldm_package/ldm +COPY ./configs /opt/ldm_package/configs +COPY environment.yaml /opt/ldm_package + +# For the ldm-dev user +RUN chmod 777 -R /opt/ldm_package + +WORKDIR /opt/ldm + +# Add dev user +RUN useradd -ms /bin/bash ldm-dev && \ + usermod -aG sudo ldm-dev && \ + echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +USER ldm-dev + +RUN conda env create -f /opt/ldm_package/environment.yaml +RUN pip3 install -e /opt/ldm_package +RUN conda run -n ldm pip install pytorch-lightning==1.5 + +ENTRYPOINT ["conda", "run", "-n", "ldm"] \ No newline at end of file diff --git a/README.md b/README.md index 3738ddee5..03e854032 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,19 @@ Furthermore, increasing `ddim_steps` generally also gives higher quality samples Fast sampling (i.e. low values of `ddim_steps`) while retaining good quality can be achieved by using `--ddim_eta 0.0`. Faster sampling (i.e. even lower values of `ddim_steps`) while retaining good quality can be achieved by using `--ddim_eta 0.0` and `--plms` (see [Pseudo Numerical Methods for Diffusion Models on Manifolds](https://arxiv.org/abs/2202.09778)). +## Installing on Docker + +- Build the image: `docker build . --tag latent-diffusion` +- For text-to-image, download the pre-trained weights (5.7GB): + ``` + mkdir -p models/ldm/text2img-large/ + wget -O models/ldm/text2img-large/model.ckpt https://ommer-lab.com/files/latent-diffusion/nitro/txt2img-f8-large/model.ckpt + ``` +- Sample with (Make sure to call in the directory of this repo): + ``` + docker run --name=tmp-diffusion --rm --gpus all -it -v "$(pwd):/opt/ldm" latent-diffusion python /opt/ldm/scripts/txt2img.py --prompt "A large blue whale on a freight ship, vector art" --ddim_eta 0.0 --n_samples 4 --n_iter 4 --scale 5.0 --ddim_steps 50 + ``` + #### Beyond 256² For certain inputs, simply running the model in a convolutional fashion on larger features than it was trained on