Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
3a5196de
Commit
3a5196de
authored
Jan 21, 2024
by
AUTOMATIC1111
Committed by
GitHub
Jan 21, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14663 from aalbacetef/feature/add-model-to-log-file
feature/add-model-to-log-file
parents
f939bce8
4aa99f77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
4 deletions
+50
-4
modules/ui_common.py
modules/ui_common.py
+50
-4
No files found.
modules/ui_common.py
View file @
3a5196de
import
csv
import
dataclasses
import
dataclasses
import
json
import
json
import
html
import
html
...
@@ -36,8 +37,33 @@ def plaintext_to_html(text, classname=None):
...
@@ -36,8 +37,33 @@ def plaintext_to_html(text, classname=None):
return
f
"<p class='{classname}'>{content}</p>"
if
classname
else
f
"<p>{content}</p>"
return
f
"<p class='{classname}'>{content}</p>"
if
classname
else
f
"<p>{content}</p>"
def
update_logfile
(
logfile_path
,
fields
):
"""Update a logfile from old format to new format to maintain CSV integrity."""
with
open
(
logfile_path
,
"r"
,
encoding
=
"utf8"
,
newline
=
""
)
as
file
:
reader
=
csv
.
reader
(
file
)
rows
=
list
(
reader
)
# blank file: leave it as is
if
not
rows
:
return
# file is already synced, do nothing
if
len
(
rows
[
0
])
==
len
(
fields
):
return
rows
[
0
]
=
fields
# append new fields to each row as empty values
for
row
in
rows
[
1
:]:
while
len
(
row
)
<
len
(
fields
):
row
.
append
(
""
)
with
open
(
logfile_path
,
"w"
,
encoding
=
"utf8"
,
newline
=
""
)
as
file
:
writer
=
csv
.
writer
(
file
)
writer
.
writerows
(
rows
)
def
save_files
(
js_data
,
images
,
do_make_zip
,
index
):
def
save_files
(
js_data
,
images
,
do_make_zip
,
index
):
import
csv
filenames
=
[]
filenames
=
[]
fullfns
=
[]
fullfns
=
[]
parsed_infotexts
=
[]
parsed_infotexts
=
[]
...
@@ -63,11 +89,31 @@ def save_files(js_data, images, do_make_zip, index):
...
@@ -63,11 +89,31 @@ def save_files(js_data, images, do_make_zip, index):
os
.
makedirs
(
shared
.
opts
.
outdir_save
,
exist_ok
=
True
)
os
.
makedirs
(
shared
.
opts
.
outdir_save
,
exist_ok
=
True
)
with
open
(
os
.
path
.
join
(
shared
.
opts
.
outdir_save
,
"log.csv"
),
"a"
,
encoding
=
"utf8"
,
newline
=
''
)
as
file
:
fields
=
[
"prompt"
,
"seed"
,
"width"
,
"height"
,
"sampler"
,
"cfgs"
,
"steps"
,
"filename"
,
"negative_prompt"
,
"sd_model_name"
,
"sd_model_hash"
,
]
logfile_path
=
os
.
path
.
join
(
shared
.
opts
.
outdir_save
,
"log.csv"
)
# NOTE: ensure csv integrity when fields are added by
# updating headers and padding with delimeters where needed
if
os
.
path
.
exists
(
logfile_path
):
update_logfile
(
logfile_path
,
fields
)
with
open
(
logfile_path
,
"a"
,
encoding
=
"utf8"
,
newline
=
''
)
as
file
:
at_start
=
file
.
tell
()
==
0
at_start
=
file
.
tell
()
==
0
writer
=
csv
.
writer
(
file
)
writer
=
csv
.
writer
(
file
)
if
at_start
:
if
at_start
:
writer
.
writerow
(
[
"prompt"
,
"seed"
,
"width"
,
"height"
,
"sampler"
,
"cfgs"
,
"steps"
,
"filename"
,
"negative_prompt"
]
)
writer
.
writerow
(
fields
)
for
image_index
,
filedata
in
enumerate
(
images
,
start_index
):
for
image_index
,
filedata
in
enumerate
(
images
,
start_index
):
image
=
image_from_url_text
(
filedata
)
image
=
image_from_url_text
(
filedata
)
...
@@ -87,7 +133,7 @@ def save_files(js_data, images, do_make_zip, index):
...
@@ -87,7 +133,7 @@ def save_files(js_data, images, do_make_zip, index):
filenames
.
append
(
os
.
path
.
basename
(
txt_fullfn
))
filenames
.
append
(
os
.
path
.
basename
(
txt_fullfn
))
fullfns
.
append
(
txt_fullfn
)
fullfns
.
append
(
txt_fullfn
)
writer
.
writerow
([
parsed_infotexts
[
0
][
'Prompt'
],
parsed_infotexts
[
0
][
'Seed'
],
data
[
"width"
],
data
[
"height"
],
data
[
"sampler_name"
],
data
[
"cfg_scale"
],
data
[
"steps"
],
filenames
[
0
],
parsed_infotexts
[
0
][
'Negative prompt'
]])
writer
.
writerow
([
parsed_infotexts
[
0
][
'Prompt'
],
parsed_infotexts
[
0
][
'Seed'
],
data
[
"width"
],
data
[
"height"
],
data
[
"sampler_name"
],
data
[
"cfg_scale"
],
data
[
"steps"
],
filenames
[
0
],
parsed_infotexts
[
0
][
'Negative prompt'
]
,
data
[
"sd_model_name"
],
data
[
"sd_model_hash"
]
])
# Make Zip
# Make Zip
if
do_make_zip
:
if
do_make_zip
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment