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
2b1bae0d
Commit
2b1bae0d
authored
Jul 15, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add textual inversion hashes to infotext
parent
12763540
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
8 deletions
+33
-8
modules/processing.py
modules/processing.py
+4
-3
modules/sd_hijack.py
modules/sd_hijack.py
+4
-1
modules/sd_hijack_clip.py
modules/sd_hijack_clip.py
+12
-3
modules/shared.py
modules/shared.py
+1
-0
modules/textual_inversion/textual_inversion.py
modules/textual_inversion/textual_inversion.py
+8
-1
style.css
style.css
+4
-0
No files found.
modules/processing.py
View file @
2b1bae0d
...
...
@@ -732,9 +732,10 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
p
.
setup_conds
()
if
len
(
model_hijack
.
comments
)
>
0
:
for
comment
in
model_hijack
.
comments
:
comments
[
comment
]
=
1
for
comment
in
model_hijack
.
comments
:
comments
[
comment
]
=
1
p
.
extra_generation_params
.
update
(
model_hijack
.
extra_generation_params
)
if
p
.
n_iter
>
1
:
shared
.
state
.
job
=
f
"Batch {n+1} out of {p.n_iter}"
...
...
modules/sd_hijack.py
View file @
2b1bae0d
...
...
@@ -147,7 +147,6 @@ def undo_weighted_forward(sd_model):
class
StableDiffusionModelHijack
:
fixes
=
None
comments
=
[]
layers
=
None
circular_enabled
=
False
clip
=
None
...
...
@@ -156,6 +155,9 @@ class StableDiffusionModelHijack:
embedding_db
=
modules
.
textual_inversion
.
textual_inversion
.
EmbeddingDatabase
()
def
__init__
(
self
):
self
.
extra_generation_params
=
{}
self
.
comments
=
[]
self
.
embedding_db
.
add_embedding_dir
(
cmd_opts
.
embeddings_dir
)
def
apply_optimizations
(
self
,
option
=
None
):
...
...
@@ -236,6 +238,7 @@ class StableDiffusionModelHijack:
def
clear_comments
(
self
):
self
.
comments
=
[]
self
.
extra_generation_params
=
{}
def
get_prompt_lengths
(
self
,
text
):
if
self
.
clip
is
None
:
...
...
modules/sd_hijack_clip.py
View file @
2b1bae0d
...
...
@@ -229,9 +229,18 @@ class FrozenCLIPEmbedderWithCustomWordsBase(torch.nn.Module):
z
=
self
.
process_tokens
(
tokens
,
multipliers
)
zs
.
append
(
z
)
if
len
(
used_embeddings
)
>
0
:
embeddings_list
=
", "
.
join
([
f
'{name} [{embedding.checksum()}]'
for
name
,
embedding
in
used_embeddings
.
items
()])
self
.
hijack
.
comments
.
append
(
f
"Used embeddings: {embeddings_list}"
)
if
opts
.
textual_inversion_add_hashes_to_infotext
and
used_embeddings
:
hashes
=
[]
for
name
,
embedding
in
used_embeddings
.
items
():
shorthash
=
embedding
.
shorthash
if
not
shorthash
:
continue
name
=
name
.
replace
(
":"
,
""
)
.
replace
(
","
,
""
)
hashes
.
append
(
f
"{name}: {shorthash}"
)
if
hashes
:
self
.
hijack
.
extra_generation_params
[
"TI hashes"
]
=
", "
.
join
(
hashes
)
return
torch
.
hstack
(
zs
)
...
...
modules/shared.py
View file @
2b1bae0d
...
...
@@ -472,6 +472,7 @@ options_templates.update(options_section(('extra_networks', "Extra Networks"), {
"extra_networks_card_height"
:
OptionInfo
(
0
,
"Card height for Extra Networks"
)
.
info
(
"in pixels"
),
"extra_networks_add_text_separator"
:
OptionInfo
(
" "
,
"Extra networks separator"
)
.
info
(
"extra text to add before <...> when adding extra network to prompt"
),
"ui_extra_networks_tab_reorder"
:
OptionInfo
(
""
,
"Extra networks tab order"
)
.
needs_restart
(),
"textual_inversion_add_hashes_to_infotext"
:
OptionInfo
(
True
,
"Add Textual Inversion hashes to infotext"
),
"sd_hypernetwork"
:
OptionInfo
(
"None"
,
"Add hypernetwork to prompt"
,
gr
.
Dropdown
,
lambda
:
{
"choices"
:
[
"None"
,
*
hypernetworks
]},
refresh
=
reload_hypernetworks
),
}))
...
...
modules/textual_inversion/textual_inversion.py
View file @
2b1bae0d
...
...
@@ -13,7 +13,7 @@ import numpy as np
from
PIL
import
Image
,
PngImagePlugin
from
torch.utils.tensorboard
import
SummaryWriter
from
modules
import
shared
,
devices
,
sd_hijack
,
processing
,
sd_models
,
images
,
sd_samplers
,
sd_hijack_checkpoint
,
errors
from
modules
import
shared
,
devices
,
sd_hijack
,
processing
,
sd_models
,
images
,
sd_samplers
,
sd_hijack_checkpoint
,
errors
,
hashes
import
modules.textual_inversion.dataset
from
modules.textual_inversion.learn_schedule
import
LearnRateScheduler
...
...
@@ -49,6 +49,8 @@ class Embedding:
self
.
sd_checkpoint_name
=
None
self
.
optimizer_state_dict
=
None
self
.
filename
=
None
self
.
hash
=
None
self
.
shorthash
=
None
def
save
(
self
,
filename
):
embedding_data
=
{
...
...
@@ -82,6 +84,10 @@ class Embedding:
self
.
cached_checksum
=
f
'{const_hash(self.vec.reshape(-1) * 100) & 0xffff:04x}'
return
self
.
cached_checksum
def
set_hash
(
self
,
v
):
self
.
hash
=
v
self
.
shorthash
=
self
.
hash
[
0
:
12
]
class
DirWithTextualInversionEmbeddings
:
def
__init__
(
self
,
path
):
...
...
@@ -199,6 +205,7 @@ class EmbeddingDatabase:
embedding
.
vectors
=
vec
.
shape
[
0
]
embedding
.
shape
=
vec
.
shape
[
-
1
]
embedding
.
filename
=
path
embedding
.
set_hash
(
hashes
.
sha256
(
embedding
.
filename
,
"textual_inversion/"
+
name
)
or
''
)
if
self
.
expected_shape
==
-
1
or
self
.
expected_shape
==
embedding
.
shape
:
self
.
register_embedding
(
embedding
,
shared
.
sd_model
)
...
...
style.css
View file @
2b1bae0d
...
...
@@ -231,6 +231,10 @@ button.custom-button{
padding-top
:
0.5em
;
}
.html-log
.comments
:empty
{
padding-top
:
0
;
}
.html-log
.performance
{
font-size
:
0.85em
;
color
:
#444
;
...
...
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