Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions ldm/dream/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def parse_cmd(self,cmd_string):
try:
elements = shlex.split(command)
except ValueError:
import sys, traceback
print(traceback.format_exc(), file=sys.stderr)
return
switches = ['']
Expand Down Expand Up @@ -266,6 +267,17 @@ def _create_arg_parser(self):
default='stable-diffusion-1.4',
help='Indicates which diffusion model to load. (currently "stable-diffusion-1.4" (default) or "laion400m")',
)
model_group.add_argument(
'--sampler',
'-A',
'-m',
dest='sampler_name',
type=str,
choices=SAMPLER_CHOICES,
metavar='SAMPLER_NAME',
help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
default='k_lms',
)
model_group.add_argument(
'-F',
'--full_precision',
Expand Down Expand Up @@ -386,14 +398,12 @@ def _create_dream_cmd_parser(self):
'--width',
type=int,
help='Image width, multiple of 64',
default=512
)
render_group.add_argument(
'-H',
'--height',
type=int,
help='Image height, multiple of 64',
default=512,
)
render_group.add_argument(
'-C',
Expand Down Expand Up @@ -429,7 +439,6 @@ def _create_dream_cmd_parser(self):
choices=SAMPLER_CHOICES,
metavar='SAMPLER_NAME',
help=f'Switch to a different sampler. Supported samplers: {", ".join(SAMPLER_CHOICES)}',
default='k_lms',
)
render_group.add_argument(
'-t',
Expand Down
10 changes: 5 additions & 5 deletions scripts/dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def main_loop(gen, opt, infile):
if command.startswith(('#', '//')):
continue

if command.startswith('q '):
if len(command.strip()) == 1 and command.startswith('q'):
done = True
break

Expand All @@ -138,7 +138,7 @@ def main_loop(gen, opt, infile):
parser.print_help()
continue
if len(opt.prompt) == 0:
print('Try again with a prompt!')
print('\nTry again with a prompt!')
continue

# retrieve previous value!
Expand Down Expand Up @@ -191,22 +191,22 @@ def main_loop(gen, opt, infile):
if not os.path.exists(opt.outdir):
os.makedirs(opt.outdir)
current_outdir = opt.outdir
elif prompt_as_dir:
elif opt.prompt_as_dir:
# sanitize the prompt to a valid folder name
subdir = path_filter.sub('_', opt.prompt)[:name_max].rstrip(' .')

# truncate path to maximum allowed length
# 27 is the length of '######.##########.##.png', plus two separators and a NUL
subdir = subdir[:(path_max - 27 - len(os.path.abspath(opt.outdir)))]
current_outdir = os.path.join(outdir, subdir)
current_outdir = os.path.join(opt.outdir, subdir)

print('Writing files to directory: "' + current_outdir + '"')

# make sure the output directory exists
if not os.path.exists(current_outdir):
os.makedirs(current_outdir)
else:
current_outdir = outdir
current_outdir = opt.outdir

# Here is where the images are actually generated!
last_results = []
Expand Down