From c22c3dec562821e646fa0ec9a56d5969f4011479 Mon Sep 17 00:00:00 2001 From: greentext2 <112735219+greentext2@users.noreply.github.com> Date: Sat, 3 Sep 2022 13:38:57 -0500 Subject: [PATCH 1/4] Update README.md with new Anaconda install steps (#347) pip3 version did not work for me and this is the recommended way to install Anaconda now it seems --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 68902491401..a171a2bea7f 100644 --- a/README.md +++ b/README.md @@ -427,10 +427,12 @@ There are separate installation walkthroughs for [Linux](#linux), [Windows](#win - Python (version 3.8.5 recommended; higher may work) - git -2. Install the Python Anaconda environment manager using pip3. +2. Install the Python Anaconda environment manager. ``` -~$ pip3 install anaconda +~$ wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh +~$ chmod +x Anaconda3-2022.05-Linux-x86_64.sh +~$ ./Anaconda3-2022.05-Linux-x86_64.sh ``` After installing anaconda, you should log out of your system and log back in. If the installation From 751283a2de81bee4bb571fbabe4adb19f1d85b97 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Sat, 3 Sep 2022 23:34:20 -0700 Subject: [PATCH 2/4] fix img2img variations/MPS (#353) * fix img2img variations * fix assert for variation_amount --- ldm/simplet2i.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index c32f57c3886..3b4cf6c54dd 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -286,7 +286,7 @@ def process_image(image,seed): 0.0 <= variation_amount <= 1.0 ), '-v --variation_amount must be in [0.0, 1.0]' - if len(with_variations) > 0 or variation_amount > 1.0: + if len(with_variations) > 0 or variation_amount > 0.0: assert seed is not None,\ 'seed must be specified when using with_variations' if variation_amount == 0.0: @@ -336,6 +336,7 @@ def process_image(image,seed): callback=step_callback, ) else: + init_latent = None make_image = self._txt2img( prompt, steps=steps, @@ -351,11 +352,11 @@ def process_image(image,seed): if variation_amount > 0 or len(with_variations) > 0: # use fixed initial noise plus random noise per iteration seed_everything(seed) - initial_noise = self._get_noise(init_img,width,height) + initial_noise = self._get_noise(init_latent,width,height) for v_seed, v_weight in with_variations: seed = v_seed seed_everything(seed) - next_noise = self._get_noise(init_img,width,height) + next_noise = self._get_noise(init_latent,width,height) initial_noise = self.slerp(v_weight, initial_noise, next_noise) if variation_amount > 0: random.seed() # reset RNG to an actually random state, so we can get a random seed for variations @@ -367,7 +368,7 @@ def process_image(image,seed): x_T = None if variation_amount > 0: seed_everything(seed) - target_noise = self._get_noise(init_img,width,height) + target_noise = self._get_noise(init_latent,width,height) x_T = self.slerp(variation_amount, initial_noise, target_noise) elif initial_noise is not None: # i.e. we specified particular variations @@ -375,7 +376,7 @@ def process_image(image,seed): else: seed_everything(seed) if self.device.type == 'mps': - x_T = self._get_noise(init_img,width,height) + x_T = self._get_noise(init_latent,width,height) # make_image will do the equivalent of get_noise itself print(f' DEBUG: seed at make_image() invocation time ={seed}') image = make_image(x_T) @@ -606,8 +607,8 @@ def load_model(self): return self.model # returns a tensor filled with random numbers from a normal distribution - def _get_noise(self,init_img,width,height): - if init_img: + def _get_noise(self,init_latent,width,height): + if init_latent is not None: if self.device.type == 'mps': return torch.randn_like(init_latent, device='cpu').to(self.device) else: From 91e826e5f425333674d1e3bec1fa1ac63cfb382d Mon Sep 17 00:00:00 2001 From: Sebastian Aigner Date: Sun, 4 Sep 2022 10:22:54 +0200 Subject: [PATCH 3/4] Add CORS headers to dream server to ease integration with third-party web interfaces --- ldm/dream/server.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ldm/dream/server.py b/ldm/dream/server.py index f592457e4c8..bba537d6adf 100644 --- a/ldm/dream/server.py +++ b/ldm/dream/server.py @@ -16,6 +16,8 @@ class DreamServer(BaseHTTPRequestHandler): def do_GET(self): if self.path == "/": self.send_response(200) + self.send_header("Access-Control-Allow-Origin", "*") + self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") self.send_header("Content-type", "text/html") self.end_headers() with open("./static/dream_web/index.html", "rb") as content: @@ -33,6 +35,8 @@ def do_GET(self): elif self.path == "/cancel": self.canceled.set() self.send_response(200) + self.send_header("Access-Control-Allow-Origin", "*") + self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") self.send_header("Content-type", "application/json") self.end_headers() self.wfile.write(bytes('{}', 'utf8')) @@ -55,6 +59,8 @@ def do_GET(self): def do_POST(self): self.send_response(200) + self.send_header("Access-Control-Allow-Origin", "*") + self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") self.send_header("Content-type", "application/json") self.end_headers() @@ -196,6 +202,11 @@ def image_progress(sample, step): print(f"Canceled.") return + def do_OPTIONS(self): + self.send_response(200) + self.send_header("Access-Control-Allow-Origin", "*") + self.send_header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept") + self.end_headers() class ThreadingDreamServer(ThreadingHTTPServer): def __init__(self, server_address): From fd7a72e147393f32fc40d8f5918ea9bf1401e723 Mon Sep 17 00:00:00 2001 From: Lincoln Stein Date: Sun, 4 Sep 2022 08:23:11 -0400 Subject: [PATCH 4/4] remove debugging message --- ldm/simplet2i.py | 1 - 1 file changed, 1 deletion(-) diff --git a/ldm/simplet2i.py b/ldm/simplet2i.py index ed5f83ef826..1f1f43054ea 100644 --- a/ldm/simplet2i.py +++ b/ldm/simplet2i.py @@ -388,7 +388,6 @@ def process_image(image,seed): if self.device.type == 'mps': x_T = self._get_noise(init_latent,width,height) # make_image will do the equivalent of get_noise itself - print(f' DEBUG: seed at make_image() invocation time ={seed}') image = make_image(x_T) results.append([image, seed]) if image_callback is not None: