Skip to content

Commit

Permalink
small bug fixes in prompt generation
Browse files Browse the repository at this point in the history
- fixes no closing quote in pretty-printed dream_prompt string
- removes unecessary -f switch when txt2img used

In addition, this commit does an experimental commenting-out of the
random.seed() call in the variation-generating part of ldm.dream.generator.base.
This fixes the problem of two calls that use the same seed and -v0.1
generating different images (invoke-ai#641). However, it does not fix the issue
of two images generated using the same seed and -VXXXXXX being
different.
  • Loading branch information
lstein authored and afiaka87 committed Sep 19, 2022
1 parent a5d0612 commit 78d579f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions ldm/dream/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def dream_prompt_str(self,**kwargs):
a = vars(self)
a.update(kwargs)
switches = list()
switches.append(f'"{a["prompt"]}')
switches.append(f'"{a["prompt"]}"')
switches.append(f'-s {a["steps"]}')
switches.append(f'-W {a["width"]}')
switches.append(f'-H {a["height"]}')
Expand All @@ -152,15 +152,13 @@ def dream_prompt_str(self,**kwargs):
switches.append(f'-S {a["seed"]}')
if a['grid']:
switches.append('--grid')
if a['iterations'] and a['iterations']>0:
switches.append(f'-n {a["iterations"]}')
if a['seamless']:
switches.append('--seamless')
if a['init_img'] and len(a['init_img'])>0:
switches.append(f'-I {a["init_img"]}')
if a['fit']:
switches.append(f'--fit')
if a['strength'] and a['strength']>0:
if a['init_img'] and a['strength'] and a['strength']>0:
switches.append(f'-f {a["strength"]}')
if a['gfpgan_strength']:
switches.append(f'-G {a["gfpgan_strength"]}')
Expand Down
2 changes: 1 addition & 1 deletion ldm/dream/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def generate_initial_noise(self, seed, width, height):
next_noise = self.get_noise(width,height)
initial_noise = self.slerp(v_weight, initial_noise, next_noise)
if self.variation_amount > 0:
random.seed() # reset RNG to an actually random state, so we can get a random seed for variations
# random.seed() # reset RNG to an actually random state, so we can get a random seed for variations
seed = random.randrange(0,np.iinfo(np.uint32).max)
return (seed, initial_noise)
else:
Expand Down

0 comments on commit 78d579f

Please sign in to comment.