diff --git a/README.md b/README.md index ce661ec9ba..23ae91e1cb 100644 --- a/README.md +++ b/README.md @@ -514,6 +514,30 @@ This will bring your local copy into sync with the remote one. ## Windows +### Notebook install (semi-automated) + +We have a +[Jupyter notebook](https://github.com/lstein/stable-diffusion/blob/main/Stable-Diffusion-local-Windows.ipynb) +with cell-by-cell installation steps. It will download the code in this repo as +one of the steps, so instead of cloning this repo, simply download the notebook +from the link above and load it up in VSCode (with the +appropriate extensions installed)/Jupyter/JupyterLab and start running the cells one-by-one. + +Note that you will need NVIDIA drivers, Python 3.10, and Git installed +beforehand - simplified +[step-by-step instructions](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install) +are available in the wiki (you'll only need steps 1, 2, & 3 ). + +### Manual installs + +#### pip + +See +[Easy-peasy Windows install](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install) +in the wiki + +#### Conda + 1. Install Anaconda3 (miniconda3 version) from here: https://docs.anaconda.com/anaconda/install/windows/ 2. Install Git from here: https://git-scm.com/download/win @@ -739,13 +763,8 @@ be fast because all the dependencies are already loaded. Anyone who wishes to contribute to this project, whether documentation, features, bug fixes, code cleanup, testing, or code reviews, is very much encouraged to do so. If you are unfamiliar with -<<<<<<< HEAD how to contribute to GitHub projects, here is a [Getting Started Guide](https://opensource.com/article/19/7/create-pull-request-github). -======= -how to contribute to GitHub projects, here is a (Getting Started -Guide)[https://opensource.com/article/19/7/create-pull-request-github]. ->>>>>>> maddavid123-main A full set of contribution guidelines, along with templates, are in progress, but for now the most important thing is to **make your pull diff --git a/Stable-Diffusion-local-Windows.ipynb b/Stable-Diffusion-local-Windows.ipynb new file mode 100644 index 0000000000..f4cea1503d --- /dev/null +++ b/Stable-Diffusion-local-Windows.ipynb @@ -0,0 +1,259 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Easy-peasy Windows install" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that you will need NVIDIA drivers, Python 3.10, and Git installed\n", + "beforehand - simplified\n", + "[step-by-step instructions](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install)\n", + "are available in the wiki (you'll only need steps 1, 2, & 3 )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Run each cell in turn. In VSCode, either hit SHIFT-ENTER, or click on the little ▶️ to the left of the cell. In Jupyter/JupyterLab, you **must** hit SHIFT-ENTER" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%pip install pew" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%cmd\n", + "git clone https://github.com/lstein/stable-diffusion.git" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%cd stable-diffusion" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%writefile requirements.txt\n", + "albumentations==0.4.3\n", + "einops==0.3.0\n", + "huggingface-hub==0.8.1\n", + "imageio-ffmpeg==0.4.2\n", + "imageio==2.9.0\n", + "kornia==0.6.0\n", + "omegaconf==2.1.1\n", + "opencv-python==4.6.0.66\n", + "pillow==9.2.0\n", + "pudb==2019.2\n", + "pytorch-lightning==1.4.2\n", + "streamlit==1.12.0\n", + "# Regular \"taming-transformers\" doesn't seem to work\n", + "taming-transformers-rom1504==0.0.6\n", + "test-tube>=0.7.5\n", + "torch-fidelity==0.3.0\n", + "torchmetrics==0.6.0\n", + "torchvision==0.12.0\n", + "transformers==4.19.2\n", + "git+https://github.com/openai/CLIP.git@main#egg=clip\n", + "git+https://github.com/lstein/k-diffusion.git@master#egg=k-diffusion\n", + "# No CUDA in PyPi builds\n", + "torch@https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp310-cp310-win_amd64.whl\n", + "# No MKL in PyPi builds (faster, more robust than OpenBLAS)\n", + "numpy@https://download.lfd.uci.edu/pythonlibs/archived/numpy-1.22.4+mkl-cp310-cp310-win_amd64.whl\n", + "-e .\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%cmd\n", + "pew new --python 3.10 -r requirements.txt --dont-activate ldm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Switch the notebook kernel to the new 'ldm' environment!\n", + "\n", + "## VSCode: restart VSCode and come back to this cell\n", + "\n", + "1. Ctrl+Shift+P\n", + "1. Type \"Select Interpreter\" and select \"Jupyter: Select Interpreter to Start Jupyter Server\"\n", + "1. VSCode will say that it needs to install packages. Click the \"Install\" button.\n", + "1. Once the install is finished, do 1 & 2 again\n", + "1. Pick 'ldm'\n", + "1. Run the following cell" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%cd stable-diffusion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## Jupyter/JupyterLab\n", + "\n", + "1. Run the cell below\n", + "1. Click on the toolbar where it says \"(ipyknel)\" ↗️. You should get a pop-up asking you to \"Select Kernel\". Pick 'ldm' from the drop-down.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### DO NOT RUN THE FOLLOWING CELL IF YOU ARE USING VSCODE!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# DO NOT RUN THIS CELL IF YOU ARE USING VSCODE!!\n", + "%%cmd\n", + "pew workon ldm\n", + "pip3 install ipykernel\n", + "python -m ipykernel install --name=ldm" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### When running the next cell, Jupyter/JupyterLab users might get a warning saying \"IProgress not found\". This can be ignored." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%run \"scripts/preload_models.py\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%cmd\n", + "mkdir \"models/ldm/stable-diffusion-v1\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Now copy the SD model you downloaded from Hugging Face into the above new directory, and (if necessary) rename it to 'model.ckpt'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Now go create some magic!\n", + "\n", + "VSCode\n", + "\n", + "- The actual input box for the 'dream' prompt will appear at the very top of the VSCode window. Type in your commands and hit 'ENTER'.\n", + "- To quit, hit the 'Interrupt' button in the toolbar up there ⬆️ a couple of times, then hit ENTER (you'll probably see a terrifying traceback from Python - just ignore it).\n", + "\n", + "Jupyter/JupyterLab\n", + "\n", + "- The input box for the 'dream' prompt will appear below. Type in your commands and hit 'ENTER'.\n", + "- To quit, hit the interrupt button (⏹️) in the toolbar up there ⬆️ a couple of times, then hit ENTER (you'll probably see a terrifying traceback from Python - just ignore it)." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%run \"scripts/dream.py\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Once this seems to be working well, you can try opening a terminal\n", + "\n", + "- VSCode: type ('CTRL+`')\n", + "- Jupyter/JupyterLab: File|New Terminal\n", + "- Or jump out of the notebook entirely, and open Powershell/Command Prompt\n", + "\n", + "Now:\n", + "\n", + "1. `cd` to wherever the 'stable-diffusion' directory is\n", + "1. Run `pew workon ldm`\n", + "1. Run `winpty python scripts\\dream.py`" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3.10.6 ('ldm')", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.6" + }, + "vscode": { + "interpreter": { + "hash": "a05e4574567b7bc2c98f7f9aa579f9ea5b8739b54844ab610ac85881c4be2659" + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}