Skip to content

Commit d660104

Browse files
tildebytelsteinmagnusviriJames Reynolds
authored
FEAT: add notebook for Windows for from-zero install and run (#164)
* Update README.md Those []() link pairs get me every time. * New issue template * Added issue templates * feat(install+run): add notebook for Windows for from-zero install... ...and run Tested with JupyterLab and VSCode Signed-off-by: Ben Alkov <[email protected]> Signed-off-by: Ben Alkov <[email protected]> Co-authored-by: Lincoln Stein <[email protected]> Co-authored-by: James Reynolds <[email protected]> Co-authored-by: James Reynolds <[email protected]>
1 parent 6566c22 commit d660104

File tree

2 files changed

+283
-5
lines changed

2 files changed

+283
-5
lines changed

README.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,30 @@ This will bring your local copy into sync with the remote one.
514514

515515
## Windows
516516

517+
### Notebook install (semi-automated)
518+
519+
We have a
520+
[Jupyter notebook](https://github.com/lstein/stable-diffusion/blob/main/Stable-Diffusion-local-Windows.ipynb)
521+
with cell-by-cell installation steps. It will download the code in this repo as
522+
one of the steps, so instead of cloning this repo, simply download the notebook
523+
from the link above and load it up in VSCode (with the
524+
appropriate extensions installed)/Jupyter/JupyterLab and start running the cells one-by-one.
525+
526+
Note that you will need NVIDIA drivers, Python 3.10, and Git installed
527+
beforehand - simplified
528+
[step-by-step instructions](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install)
529+
are available in the wiki (you'll only need steps 1, 2, & 3 ).
530+
531+
### Manual installs
532+
533+
#### pip
534+
535+
See
536+
[Easy-peasy Windows install](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install)
537+
in the wiki
538+
539+
#### Conda
540+
517541
1. Install Anaconda3 (miniconda3 version) from here: https://docs.anaconda.com/anaconda/install/windows/
518542

519543
2. Install Git from here: https://git-scm.com/download/win
@@ -739,13 +763,8 @@ be fast because all the dependencies are already loaded.
739763
Anyone who wishes to contribute to this project, whether
740764
documentation, features, bug fixes, code cleanup, testing, or code
741765
reviews, is very much encouraged to do so. If you are unfamiliar with
742-
<<<<<<< HEAD
743766
how to contribute to GitHub projects, here is a [Getting Started
744767
Guide](https://opensource.com/article/19/7/create-pull-request-github).
745-
=======
746-
how to contribute to GitHub projects, here is a (Getting Started
747-
Guide)[https://opensource.com/article/19/7/create-pull-request-github].
748-
>>>>>>> maddavid123-main
749768

750769
A full set of contribution guidelines, along with templates, are in
751770
progress, but for now the most important thing is to **make your pull
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Easy-peasy Windows install"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"Note that you will need NVIDIA drivers, Python 3.10, and Git installed\n",
15+
"beforehand - simplified\n",
16+
"[step-by-step instructions](https://github.com/lstein/stable-diffusion/wiki/Easy-peasy-Windows-install)\n",
17+
"are available in the wiki (you'll only need steps 1, 2, & 3 )"
18+
]
19+
},
20+
{
21+
"cell_type": "markdown",
22+
"metadata": {},
23+
"source": [
24+
"### 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"
25+
]
26+
},
27+
{
28+
"cell_type": "code",
29+
"execution_count": null,
30+
"metadata": {},
31+
"outputs": [],
32+
"source": [
33+
"%pip install pew"
34+
]
35+
},
36+
{
37+
"cell_type": "code",
38+
"execution_count": null,
39+
"metadata": {},
40+
"outputs": [],
41+
"source": [
42+
"%%cmd\n",
43+
"git clone https://github.com/lstein/stable-diffusion.git"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {},
50+
"outputs": [],
51+
"source": [
52+
"%cd stable-diffusion"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": null,
58+
"metadata": {},
59+
"outputs": [],
60+
"source": [
61+
"%%writefile requirements.txt\n",
62+
"albumentations==0.4.3\n",
63+
"einops==0.3.0\n",
64+
"huggingface-hub==0.8.1\n",
65+
"imageio-ffmpeg==0.4.2\n",
66+
"imageio==2.9.0\n",
67+
"kornia==0.6.0\n",
68+
"omegaconf==2.1.1\n",
69+
"opencv-python==4.6.0.66\n",
70+
"pillow==9.2.0\n",
71+
"pudb==2019.2\n",
72+
"pytorch-lightning==1.4.2\n",
73+
"streamlit==1.12.0\n",
74+
"# Regular \"taming-transformers\" doesn't seem to work\n",
75+
"taming-transformers-rom1504==0.0.6\n",
76+
"test-tube>=0.7.5\n",
77+
"torch-fidelity==0.3.0\n",
78+
"torchmetrics==0.6.0\n",
79+
"torchvision==0.12.0\n",
80+
"transformers==4.19.2\n",
81+
"git+https://github.com/openai/CLIP.git@main#egg=clip\n",
82+
"git+https://github.com/lstein/k-diffusion.git@master#egg=k-diffusion\n",
83+
"# No CUDA in PyPi builds\n",
84+
"torch@https://download.pytorch.org/whl/cu113/torch-1.11.0%2Bcu113-cp310-cp310-win_amd64.whl\n",
85+
"# No MKL in PyPi builds (faster, more robust than OpenBLAS)\n",
86+
"numpy@https://download.lfd.uci.edu/pythonlibs/archived/numpy-1.22.4+mkl-cp310-cp310-win_amd64.whl\n",
87+
"-e .\n"
88+
]
89+
},
90+
{
91+
"cell_type": "code",
92+
"execution_count": null,
93+
"metadata": {},
94+
"outputs": [],
95+
"source": [
96+
"%%cmd\n",
97+
"pew new --python 3.10 -r requirements.txt --dont-activate ldm"
98+
]
99+
},
100+
{
101+
"cell_type": "markdown",
102+
"metadata": {},
103+
"source": [
104+
"# Switch the notebook kernel to the new 'ldm' environment!\n",
105+
"\n",
106+
"## VSCode: restart VSCode and come back to this cell\n",
107+
"\n",
108+
"1. Ctrl+Shift+P\n",
109+
"1. Type \"Select Interpreter\" and select \"Jupyter: Select Interpreter to Start Jupyter Server\"\n",
110+
"1. VSCode will say that it needs to install packages. Click the \"Install\" button.\n",
111+
"1. Once the install is finished, do 1 & 2 again\n",
112+
"1. Pick 'ldm'\n",
113+
"1. Run the following cell"
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": null,
119+
"metadata": {},
120+
"outputs": [],
121+
"source": [
122+
"%cd stable-diffusion"
123+
]
124+
},
125+
{
126+
"cell_type": "markdown",
127+
"metadata": {},
128+
"source": [
129+
"\n",
130+
"## Jupyter/JupyterLab\n",
131+
"\n",
132+
"1. Run the cell below\n",
133+
"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"
134+
]
135+
},
136+
{
137+
"cell_type": "markdown",
138+
"metadata": {},
139+
"source": [
140+
"#### DO NOT RUN THE FOLLOWING CELL IF YOU ARE USING VSCODE!!"
141+
]
142+
},
143+
{
144+
"cell_type": "code",
145+
"execution_count": null,
146+
"metadata": {},
147+
"outputs": [],
148+
"source": [
149+
"# DO NOT RUN THIS CELL IF YOU ARE USING VSCODE!!\n",
150+
"%%cmd\n",
151+
"pew workon ldm\n",
152+
"pip3 install ipykernel\n",
153+
"python -m ipykernel install --name=ldm"
154+
]
155+
},
156+
{
157+
"cell_type": "markdown",
158+
"metadata": {},
159+
"source": [
160+
"#### When running the next cell, Jupyter/JupyterLab users might get a warning saying \"IProgress not found\". This can be ignored."
161+
]
162+
},
163+
{
164+
"cell_type": "code",
165+
"execution_count": null,
166+
"metadata": {},
167+
"outputs": [],
168+
"source": [
169+
"%run \"scripts/preload_models.py\""
170+
]
171+
},
172+
{
173+
"cell_type": "code",
174+
"execution_count": null,
175+
"metadata": {},
176+
"outputs": [],
177+
"source": [
178+
"%%cmd\n",
179+
"mkdir \"models/ldm/stable-diffusion-v1\""
180+
]
181+
},
182+
{
183+
"cell_type": "markdown",
184+
"metadata": {},
185+
"source": [
186+
"### Now copy the SD model you downloaded from Hugging Face into the above new directory, and (if necessary) rename it to 'model.ckpt'"
187+
]
188+
},
189+
{
190+
"cell_type": "markdown",
191+
"metadata": {},
192+
"source": [
193+
"### Now go create some magic!\n",
194+
"\n",
195+
"VSCode\n",
196+
"\n",
197+
"- 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",
198+
"- 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",
199+
"\n",
200+
"Jupyter/JupyterLab\n",
201+
"\n",
202+
"- The input box for the 'dream' prompt will appear below. Type in your commands and hit 'ENTER'.\n",
203+
"- 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)."
204+
]
205+
},
206+
{
207+
"cell_type": "code",
208+
"execution_count": null,
209+
"metadata": {},
210+
"outputs": [],
211+
"source": [
212+
"%run \"scripts/dream.py\""
213+
]
214+
},
215+
{
216+
"cell_type": "markdown",
217+
"metadata": {},
218+
"source": [
219+
"### Once this seems to be working well, you can try opening a terminal\n",
220+
"\n",
221+
"- VSCode: type ('CTRL+`')\n",
222+
"- Jupyter/JupyterLab: File|New Terminal\n",
223+
"- Or jump out of the notebook entirely, and open Powershell/Command Prompt\n",
224+
"\n",
225+
"Now:\n",
226+
"\n",
227+
"1. `cd` to wherever the 'stable-diffusion' directory is\n",
228+
"1. Run `pew workon ldm`\n",
229+
"1. Run `winpty python scripts\\dream.py`"
230+
]
231+
}
232+
],
233+
"metadata": {
234+
"kernelspec": {
235+
"display_name": "Python 3.10.6 ('ldm')",
236+
"language": "python",
237+
"name": "python3"
238+
},
239+
"language_info": {
240+
"codemirror_mode": {
241+
"name": "ipython",
242+
"version": 3
243+
},
244+
"file_extension": ".py",
245+
"mimetype": "text/x-python",
246+
"name": "python",
247+
"nbconvert_exporter": "python",
248+
"pygments_lexer": "ipython3",
249+
"version": "3.10.6"
250+
},
251+
"vscode": {
252+
"interpreter": {
253+
"hash": "a05e4574567b7bc2c98f7f9aa579f9ea5b8739b54844ab610ac85881c4be2659"
254+
}
255+
}
256+
},
257+
"nbformat": 4,
258+
"nbformat_minor": 4
259+
}

0 commit comments

Comments
 (0)