adieyal / sd-dynamic-prompts

A custom script for AUTOMATIC1111/stable-diffusion-webui to implement a tiny template language for random prompt generation
MIT License
2.03k stars 262 forks source link

Error saving prompts to file #78

Closed keenerb closed 1 year ago

keenerb commented 1 year ago

Describe the bug Write Prompts to File option errors out on long prompts

Version used What version of the extension are you using? You can see it next to Dynamic Prompt v[VERSION] in the scripts dropdown. This version does not appear under Scripts dropdown. It's current version as of a "git pull" today.

To Reproduce Use this prompt (which is artifically copied/pasted to be longer), or a similar very long prompt:

(photo realistic), (highest quality), ages-18-45, body-all, celebs-monolid-kdrama, lighting-accented, expression-all,location-stark,(photo realistic), (highest quality), ages-18-45, body-all, celebs-monolid-kdrama, lighting-accented, expression-all,location-stark,(photo realistic), (highest quality), ages-18-45, body-all, celebs-monolid-kdrama, lighting-accented, expression-all,location-stark

Results in

Failed to write prompts to file: [Errno 2] No such file or directory: 'outputs\txt2img-images\photo-realistic-highest-quality-ages-18-45-body-all-celebs-monolid-kdrama-lighting-accented-expression-all__location-starkphoto-realistic-highest-quality-ages-18-45-body-all-celebs-monolid-kdrama-lighting-accented-expression-all__location-starkphoto-realistic-highest-quality-ages-18-45-body-all-celebs-monolid-kdrama-lighting-accented-expression-all__location-stark.txt'

Shorter prompts work fine. "redhead girl location-pretty" creates a text file successfully.

Also mention which checkboxes have been set.

Write prompts to file is only checkbox other than "enable dynamic prompts"

Expected behaviour I expect a file to be created with the output of the current prompt

Additional context COnsidering WebUI already has a feature that writes the "real" prompt alongside the generated image, it would be nice to have the script log the "pre-parsed" wildcard version of the prompt; i.e. log "redhead girl location-pretty" rather than "redhead girl forest", so that I could go back and review previous wildcard prompts and update them more easily.

keenerb commented 1 year ago

I modified dynamic_prompting.py and changed this bit to truncate file name at 50 chars.

    try:
        if write_prompts:
            prompt_filename = get_unique_path(
                Path(p.outpath_samples), slugify(original_prompt[0:50])
adieyal commented 1 year ago

Could you please test v0.29.6 - the maximum file length is now capped at 50 characters