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
14 changes: 14 additions & 0 deletions docs/features/OTHER.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ combination of integers and floating point numbers, and they do not need to add

---

## Filename Format

The argument `--fnformat` allows to specify the filename of the image. Supported wildcards are all arguments what can be set such as
`perlin`, `seed`, `threshold`, `height`, `width`, `gfpgan_strength`, `sampler_name`, `steps`, `model`, `upscale`, `prompt`, `cfg_scale`, `prefix`.

The following prompt
```bash
dream> a red car --steps 25 -C 9.8 --perlin 0.1 --fnformat {prompt}_steps.{steps}_cfg.{cfg_scale}_perlin.{perlin}.png
```

generates a file with the name: `outputs/img-samples/a red car_steps.25_cfg.9.8_perlin.0.1.png`

---

## Thresholding and Perlin Noise Initialization Options

Two new options are the thresholding (`--threshold`) and the perlin noise initialization (`--perlin`) options. Thresholding limits the range of the latent values during optimization, which helps combat oversaturation with higher CFG scale values. Perlin noise initialization starts with a percentage (a value ranging from 0 to 1) of perlin noise mixed into the initial noise. Both features allow for more variations and options in the course of generating images.
Expand Down
9 changes: 8 additions & 1 deletion ldm/dream/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def dream_prompt_str(self,**kwargs):
switches.append(f'-W {a["width"]}')
switches.append(f'-H {a["height"]}')
switches.append(f'-C {a["cfg_scale"]}')
switches.append(f'--fnformat {a["fnformat"]}')
if a['perlin'] > 0:
switches.append(f'--perlin {a["perlin"]}')
if a['threshold'] > 0:
Expand Down Expand Up @@ -590,6 +591,12 @@ def _create_dream_cmd_parser(self):
type=float,
help='Perlin noise scale (0.0 - 1.0) - add perlin noise to the initialization instead of the usual gaussian noise.',
)
render_group.add_argument(
'--fnformat',
default='{prefix}.{seed}.png',
type=str,
help='Overwrite the filename format. You can use any argument as wildcard enclosed in curly braces. Default is {prefix}.{seed}.png',
)
render_group.add_argument(
'--grid',
'-g',
Expand Down Expand Up @@ -788,7 +795,7 @@ def metadata_dumps(opt,

# remove any image keys not mentioned in RFC #266
rfc266_img_fields = ['type','postprocessing','sampler','prompt','seed','variations','steps',
'cfg_scale','threshold','perlin','step_number','width','height','extra','strength']
'cfg_scale','threshold','perlin','fnformat','step_number','width','height','extra','strength']

rfc_dict ={}

Expand Down
12 changes: 11 additions & 1 deletion scripts/dream.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,17 @@ def prepare_image_metadata(
if postprocessed and opt.save_original:
filename = choose_postprocess_name(opt,prefix,seed)
else:
filename = f'{prefix}.{seed}.png'
wildcards = dict(opt.__dict__)
wildcards['prefix'] = prefix
wildcards['seed'] = seed
try:
filename = opt.fnformat.format(**wildcards)
except KeyError as e:
print(f'The filename format contains an unknown key \'{e.args[0]}\'. Will use \'{{prefix}}.{{seed}}.png\' instead')
filename = f'{prefix}.{seed}.png'
except IndexError as e:
print(f'The filename format is broken or complete. Will use \'{{prefix}}.{{seed}}.png\' instead')
filename = f'{prefix}.{seed}.png'

if opt.variation_amount > 0:
first_seed = first_seed or seed
Expand Down