mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Merge branch 'v2.3' into bugfix/batch-logfile-format
This commit is contained in:
commit
7377855c02
@ -30,14 +30,17 @@ class PngWriter:
|
|||||||
prefix = self._unused_prefix()
|
prefix = self._unused_prefix()
|
||||||
else:
|
else:
|
||||||
with open(next_prefix_file,'r') as file:
|
with open(next_prefix_file,'r') as file:
|
||||||
prefix=int(file.readline() or int(self._unused_prefix())-1)
|
prefix = 0
|
||||||
prefix+=1
|
try:
|
||||||
|
prefix=int(file.readline())
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
prefix=self._unused_prefix()
|
||||||
with open(next_prefix_file,'w') as file:
|
with open(next_prefix_file,'w') as file:
|
||||||
file.write(str(prefix))
|
file.write(str(prefix+1))
|
||||||
return f'{prefix:06}'
|
return f'{prefix:06}'
|
||||||
|
|
||||||
# gives the next unique prefix in outdir
|
# gives the next unique prefix in outdir
|
||||||
def _unused_prefix(self):
|
def _unused_prefix(self)->int:
|
||||||
# sort reverse alphabetically until we find max+1
|
# sort reverse alphabetically until we find max+1
|
||||||
dirlist = sorted(os.listdir(self.outdir), reverse=True)
|
dirlist = sorted(os.listdir(self.outdir), reverse=True)
|
||||||
# find the first filename that matches our pattern or return 000000.0.png
|
# find the first filename that matches our pattern or return 000000.0.png
|
||||||
@ -45,8 +48,7 @@ class PngWriter:
|
|||||||
(f for f in dirlist if re.match('^(\d+)\..*\.png', f)),
|
(f for f in dirlist if re.match('^(\d+)\..*\.png', f)),
|
||||||
'0000000.0.png',
|
'0000000.0.png',
|
||||||
)
|
)
|
||||||
basecount = int(existing_name.split('.', 1)[0]) + 1
|
return int(existing_name.split('.', 1)[0]) + 1
|
||||||
return f'{basecount:06}'
|
|
||||||
|
|
||||||
# saves image named _image_ to outdir/name, writing metadata from prompt
|
# saves image named _image_ to outdir/name, writing metadata from prompt
|
||||||
# returns full path of output
|
# returns full path of output
|
||||||
|
Loading…
x
Reference in New Issue
Block a user