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
82380d9a
Commit
82380d9a
authored
Oct 05, 2022
by
Jairo Correa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removing parts no longer needed to fix vram
parent
1f50971f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
15 deletions
+9
-15
devices.py
modules/devices.py
+1
-2
processing.py
modules/processing.py
+8
-13
No files found.
modules/devices.py
View file @
82380d9a
import
contextlib
import
torch
import
gc
from
modules
import
errors
...
...
@@ -20,8 +19,8 @@ def get_optimal_device():
return
cpu
def
torch_gc
():
gc
.
collect
()
if
torch
.
cuda
.
is_available
():
torch
.
cuda
.
empty_cache
()
torch
.
cuda
.
ipc_collect
()
...
...
modules/processing.py
View file @
82380d9a
...
...
@@ -345,8 +345,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
if
state
.
job_count
==
-
1
:
state
.
job_count
=
p
.
n_iter
for
n
in
range
(
p
.
n_iter
):
with
torch
.
no_grad
(),
precision_scope
(
"cuda"
),
ema_scope
():
for
n
in
range
(
p
.
n_iter
):
if
state
.
interrupted
:
break
...
...
@@ -395,22 +394,19 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
import
modules.safety
as
safety
x_samples_ddim
=
modules
.
safety
.
censor_batch
(
x_samples_ddim
)
for
i
,
x_sample
in
enumerate
(
x_samples_ddim
):
with
torch
.
no_grad
(),
precision_scope
(
"cuda"
),
ema_scope
():
for
i
,
x_sample
in
enumerate
(
x_samples_ddim
):
x_sample
=
255.
*
np
.
moveaxis
(
x_sample
.
cpu
()
.
numpy
(),
0
,
2
)
x_sample
=
x_sample
.
astype
(
np
.
uint8
)
if
p
.
restore_faces
:
with
torch
.
no_grad
(),
precision_scope
(
"cuda"
),
ema_scope
():
if
p
.
restore_faces
:
if
opts
.
save
and
not
p
.
do_not_save_samples
and
opts
.
save_images_before_face_restoration
:
images
.
save_image
(
Image
.
fromarray
(
x_sample
),
p
.
outpath_samples
,
""
,
seeds
[
i
],
prompts
[
i
],
opts
.
samples_format
,
info
=
infotext
(
n
,
i
),
p
=
p
,
suffix
=
"-before-face-restoration"
)
x_sample
=
modules
.
face_restoration
.
restore_faces
(
x_sample
)
devices
.
torch_gc
()
devices
.
torch_gc
()
x_sample
=
modules
.
face_restoration
.
restore_faces
(
x_sample
)
devices
.
torch_gc
()
with
torch
.
no_grad
(),
precision_scope
(
"cuda"
),
ema_scope
():
image
=
Image
.
fromarray
(
x_sample
)
if
p
.
color_corrections
is
not
None
and
i
<
len
(
p
.
color_corrections
):
...
...
@@ -438,13 +434,12 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
infotexts
.
append
(
infotext
(
n
,
i
))
output_images
.
append
(
image
)
del
x_samples_ddim
del
x_samples_ddim
devices
.
torch_gc
()
devices
.
torch_gc
()
state
.
nextjob
()
state
.
nextjob
()
with
torch
.
no_grad
(),
precision_scope
(
"cuda"
),
ema_scope
():
p
.
color_corrections
=
None
index_of_first_image
=
0
...
...
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