feat: adding filename format template

This commit is contained in:
plucked 2022-10-07 08:32:39 +00:00
parent 4f247a3672
commit 89c6c11214
2 changed files with 25 additions and 2 deletions

View File

@ -185,6 +185,7 @@ class Args(object):
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:
@ -559,6 +560,12 @@ class Args(object):
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)s.%(seed)s.png',
type=str,
help='Specify the template of the generated files names.',
)
render_group.add_argument(
'--grid',
'-g',
@ -757,7 +764,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 ={}

View File

@ -458,7 +458,23 @@ def prepare_image_metadata(
if postprocessed and opt.save_original:
filename = choose_postprocess_name(opt,prefix,seed)
else:
filename = f'{prefix}.{seed}.png'
filename = opt.fnformat % {
'prefix': prefix,
'seed': seed,
'steps': opt.steps,
'prompt': opt.prompt,
'width': opt.width,
'height': opt.height,
'cfg_scale': opt.cfg_scale,
'perlin': opt.perlin,
'threshold': opt.threshold,
'gfpgan_strength': opt.gfpgan_strength,
'outcrop': opt.outcrop,
'upscale': opt.upscale,
'embiggen': opt.embiggen,
'embiggen_tiles': opt.embiggen_tiles,
'out_direction': opt.out_direction
}
if opt.variation_amount > 0:
first_seed = first_seed or seed