stable-diffusion-webui
stable-diffusion-webui copied to clipboard
Add feature, Customizable [datetime] Format and Timezone for image filename
allows the user to customize the Format and Timezone of [datetime]
Syntex
[datetime]
[datetime<format>]
[datetime<format><time zone>]
[datetime<><time zone>]
e.g.
[datetime]
20221022203816
[datetime<%Y_%m_%d %H-%M-%S><Asia/Tokyo>]
2022_10_22 20-38-16
a demo script can be found hear https://gist.github.com/w-e-w/ba208f745107316e0c084027e0c40a1f
this is a backwards compatible implementation
the original [datetime] behavior is preserved
test to be working, and did not find issue
using this as the pattern
[datetime<%Y_%m_%d %H-%M-%S.%f><Asia/Tokyo>]_[steps]=[cfg]=[prompt]=[prompt_no_styles]=[prompt_spaces]=[width]=[height]=[styles]=[sampler]=[seed]=[model_hash]=[prompt_words]=[date]=[datetime]=[job_timestamp]
resulting output
01034-2022_10_23 00-22-41.414133_3=7=(1girl),_(sitting)=(1girl), (sitting)=(1girl), (sitting)=64=64=None=Euler a=85172513=925997e9=1girl sitting=2022-10-23=20221023002241=20221023002232.png
01033-2022_10_23 00-22-41.406134_3=7=(1girl),_(sitting)=(1girl), (sitting)=(1girl), (sitting)=64=64=None=Euler a=85172512=925997e9=1girl sitting=2022-10-23=20221023002241=20221023002232.png
01032-2022_10_23 00-22-41.398135_3=7=(1girl),_(sitting)=(1girl), (sitting)=(1girl), (sitting)=64=64=None=Euler a=85172511=925997e9=1girl sitting=2022-10-23=20221023002241=20221023002232.png
01031-2022_10_23 00-22-41.379153_3=7=(1girl),_(sitting)=(1girl), (sitting)=(1girl), (sitting)=64=64=None=Euler a=85172510=925997e9=1girl sitting=2022-10-23=20221023002241=20221023002232.png
I used every pattern in the decorator and the output seems correct
notable changes
due to the formatting of datetime is case sensitive
I have to rework apply_filename_pattern() so that it does not require the input pattern lowercase
originally due to the use of str.replace() and if "sub str" in "str" being case sensitive
the input pattern converted to do case before being input
due to time formatting, there is the need of preserving the Case of the pattern
so I replaced all str.replace() and `if "sub str" to its regular expression case insensitive equivalent
Further for proposal if this code is accepted
this is partially brought about by Feature #3322 I myself and many others might wish to use a time-based file name Prefix system
my reason being it would make sorting of images across different instances of stable-diffusion-webui much easier
I use Google Colab and My own computer to run webui
due to the way that the current naming system works
there's a numbering prefex in the image file name 01234-seed-......png
it is derived from the largest image numbering in the output folder
this means that images created from different instances of webui will not be related
as such it it is very troublesome to store thes images generated from different places together together
if I were to store the image in the same directory, I would get unrelated images interlaced between each other
and due to how currently the webui works the numbering Cannot be disabled by the user
I understand look need of a number system that ensures that file names will not be repeated
this is why I'm wish to propose a time based prefix system so that image is generated from different instances could be chronologically ordered
note: one could use the file creation dates modification date to order the images, but these dates can be unreliable
if you're willing to accept the proposal
I will be willing to work on it my intention is that
The user will have to enable such it, the current behavior is not changed
my current idea is to have some value in the config that user can adjust the padding of the numbering a padding a negative will disable the numbering system
additional file pattern [index<int>] that file decoration pattern
this number serves a similar purpose as the current numbering
the only difference is that the user can decide the location
if this were implemented, I would use a file pattern like
[datetime<%Y_%m_%d %H-%M-%S><Asia/Tokyo>]-[index]=[seed]=[prompt_words]
result will be
01046-2022_10_23 00-32-29-1=2287592556=1girl sitting.png
unrelated question I have made it PR #3218 fix img2img color correction only applying to the first image of a batch the code was approved by AUTOMATIC1111 but hasn't yet be merged and there's also no comments I'm left hanging wondering what's up am I doing something wrong or are you guys just still validating if it actually works?
what is the best way to have a discussion this repo is too crowded?
additional proposal
I don't think using square brackets for file decoration patterns is a good idea
as [ ] square brackets are legal characters for windows filename
I believe using < > is better
e.g.
[seed]
<seed>
yes, I am I'm aware tat switching from [] to <> will cause a breaking change
to be honest, probably not worth the change
so this is just a suggestion
in practice a file datetime pattern using %f Microsecond as a decimal number, zero-padded to 6 digits
is basically enough to guarantee a file named is unique
[Datetime<%Y_%m_%d %H-%M-%S.%f><Asia/Tokyo>]
01004-2022_10_23 01-46-18.764579.png
01005-2022_10_23 01-46-19.095578.png
01006-2022_10_23 01-46-19.103577.png
01007-2022_10_23 01-46-19.142579.png
01008-2022_10_23 01-46-19.222578.png
01009-2022_10_23 01-46-19.265577.png
01010-2022_10_23 01-46-19.273577.png
01011-2022_10_23 01-46-20.061579.png
these images are generated in a single batch of size 8
using the minimal resolution of 64x64
the UI is able to save the images without issue even under these condition
this PR will have a slight merge conflict with PR #3397 add unixtime support on filename
due to the modification done to apply_filename_pattern()