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
ac02216e
Commit
ac02216e
authored
Dec 02, 2023
by
AUTOMATIC1111
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alternate implementation for unet forward replacement that does not depend on hijack being applied
parent
af5f0734
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
8 deletions
+13
-8
modules/sd_hijack.py
modules/sd_hijack.py
+5
-2
modules/sd_unet.py
modules/sd_unet.py
+8
-6
No files found.
modules/sd_hijack.py
View file @
ac02216e
...
...
@@ -38,8 +38,11 @@ ldm.models.diffusion.ddpm.print = shared.ldm_print
optimizers
=
[]
current_optimizer
:
sd_hijack_optimizations
.
SdOptimization
=
None
ldm_original_forward
=
patches
.
patch
(
__file__
,
ldm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
,
"forward"
,
sd_unet
.
UNetModel_forward
)
sgm_original_forward
=
patches
.
patch
(
__file__
,
sgm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
,
"forward"
,
sd_unet
.
UNetModel_forward
)
ldm_patched_forward
=
sd_unet
.
create_unet_forward
(
ldm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
.
forward
)
ldm_original_forward
=
patches
.
patch
(
__file__
,
ldm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
,
"forward"
,
ldm_patched_forward
)
sgm_patched_forward
=
sd_unet
.
create_unet_forward
(
sgm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
.
forward
)
sgm_original_forward
=
patches
.
patch
(
__file__
,
sgm
.
modules
.
diffusionmodules
.
openaimodel
.
UNetModel
,
"forward"
,
sgm_patched_forward
)
def
list_optimizers
():
...
...
modules/sd_unet.py
View file @
ac02216e
...
...
@@ -5,8 +5,7 @@ from modules import script_callbacks, shared, devices
unet_options
=
[]
current_unet_option
=
None
current_unet
=
None
original_forward
=
None
original_forward
=
None
# not used, only left temporarily for compatibility
def
list_unets
():
new_unets
=
script_callbacks
.
list_unets_callback
()
...
...
@@ -84,9 +83,12 @@ class SdUnet(torch.nn.Module):
pass
def
UNetModel_forward
(
self
,
x
,
timesteps
=
None
,
context
=
None
,
*
args
,
**
kwargs
):
if
current_unet
is
not
None
:
return
current_unet
.
forward
(
x
,
timesteps
,
context
,
*
args
,
**
kwargs
)
def
create_unet_forward
(
original_forward
):
def
UNetModel_forward
(
self
,
x
,
timesteps
=
None
,
context
=
None
,
*
args
,
**
kwargs
):
if
current_unet
is
not
None
:
return
current_unet
.
forward
(
x
,
timesteps
,
context
,
*
args
,
**
kwargs
)
return
original_forward
(
self
,
x
,
timesteps
,
context
,
*
args
,
**
kwargs
)
return
original_forward
(
self
,
x
,
timesteps
,
context
,
*
args
,
**
kwargs
)
return
UNetModel_forward
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