Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
1bfec873
Commit
1bfec873
authored
Jan 25, 2023
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an experimental option to apply loras to outputs rather than inputs
parent
48a15821
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
lora.py
extensions-builtin/Lora/lora.py
+4
-1
lora_script.py
extensions-builtin/Lora/scripts/lora_script.py
+6
-1
No files found.
extensions-builtin/Lora/lora.py
View file @
1bfec873
...
...
@@ -166,7 +166,10 @@ def lora_forward(module, input, res):
for
lora
in
loaded_loras
:
module
=
lora
.
modules
.
get
(
lora_layer_name
,
None
)
if
module
is
not
None
:
res
=
res
+
module
.
up
(
module
.
down
(
input
))
*
lora
.
multiplier
*
(
module
.
alpha
/
module
.
up
.
weight
.
shape
[
1
]
if
module
.
alpha
else
1.0
)
if
shared
.
opts
.
lora_apply_to_outputs
and
res
.
shape
==
input
.
shape
:
res
=
res
+
module
.
up
(
module
.
down
(
res
))
*
lora
.
multiplier
*
(
module
.
alpha
/
module
.
up
.
weight
.
shape
[
1
]
if
module
.
alpha
else
1.0
)
else
:
res
=
res
+
module
.
up
(
module
.
down
(
input
))
*
lora
.
multiplier
*
(
module
.
alpha
/
module
.
up
.
weight
.
shape
[
1
]
if
module
.
alpha
else
1.0
)
return
res
...
...
extensions-builtin/Lora/scripts/lora_script.py
View file @
1bfec873
...
...
@@ -3,7 +3,7 @@ import torch
import
lora
import
extra_networks_lora
import
ui_extra_networks_lora
from
modules
import
script_callbacks
,
ui_extra_networks
,
extra_networks
from
modules
import
script_callbacks
,
ui_extra_networks
,
extra_networks
,
shared
def
unload
():
...
...
@@ -28,3 +28,8 @@ torch.nn.Conv2d.forward = lora.lora_Conv2d_forward
script_callbacks
.
on_model_loaded
(
lora
.
assign_lora_names_to_compvis_modules
)
script_callbacks
.
on_script_unloaded
(
unload
)
script_callbacks
.
on_before_ui
(
before_ui
)
shared
.
options_templates
.
update
(
shared
.
options_section
((
'extra_networks'
,
"Extra Networks"
),
{
"lora_apply_to_outputs"
:
shared
.
OptionInfo
(
False
,
"Apply Lora to outputs rather than inputs when possible (experimental)"
),
}))
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