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
910d4f61
Commit
910d4f61
authored
Jul 10, 2023
by
AUTOMATIC1111
Committed by
GitHub
Jul 10, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11720 from akx/closing
Use closing() with processing classes everywhere
parents
bcb6ad5f
44c27ebc
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
19 deletions
+24
-19
modules/hypernetworks/hypernetwork.py
modules/hypernetworks/hypernetwork.py
+4
-2
modules/img2img.py
modules/img2img.py
+10
-10
modules/textual_inversion/textual_inversion.py
modules/textual_inversion/textual_inversion.py
+4
-2
modules/txt2img.py
modules/txt2img.py
+6
-5
No files found.
modules/hypernetworks/hypernetwork.py
View file @
910d4f61
...
@@ -3,6 +3,7 @@ import glob
...
@@ -3,6 +3,7 @@ import glob
import
html
import
html
import
os
import
os
import
inspect
import
inspect
from
contextlib
import
closing
import
modules.textual_inversion.dataset
import
modules.textual_inversion.dataset
import
torch
import
torch
...
@@ -711,8 +712,9 @@ def train_hypernetwork(id_task, hypernetwork_name, learn_rate, batch_size, gradi
...
@@ -711,8 +712,9 @@ def train_hypernetwork(id_task, hypernetwork_name, learn_rate, batch_size, gradi
preview_text
=
p
.
prompt
preview_text
=
p
.
prompt
processed
=
processing
.
process_images
(
p
)
with
closing
(
p
):
image
=
processed
.
images
[
0
]
if
len
(
processed
.
images
)
>
0
else
None
processed
=
processing
.
process_images
(
p
)
image
=
processed
.
images
[
0
]
if
len
(
processed
.
images
)
>
0
else
None
if
unload
:
if
unload
:
shared
.
sd_model
.
cond_stage_model
.
to
(
devices
.
cpu
)
shared
.
sd_model
.
cond_stage_model
.
to
(
devices
.
cpu
)
...
...
modules/img2img.py
View file @
910d4f61
import
os
import
os
from
contextlib
import
closing
from
pathlib
import
Path
from
pathlib
import
Path
import
numpy
as
np
import
numpy
as
np
...
@@ -217,18 +218,17 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s
...
@@ -217,18 +218,17 @@ def img2img(id_task: str, mode: int, prompt: str, negative_prompt: str, prompt_s
if
mask
:
if
mask
:
p
.
extra_generation_params
[
"Mask blur"
]
=
mask_blur
p
.
extra_generation_params
[
"Mask blur"
]
=
mask_blur
if
is_batch
:
with
closing
(
p
):
assert
not
shared
.
cmd_opts
.
hide_ui_dir_config
,
"Launched with --hide-ui-dir-config, batch img2img disabled"
if
is_batch
:
assert
not
shared
.
cmd_opts
.
hide_ui_dir_config
,
"Launched with --hide-ui-dir-config, batch img2img disabled"
process_batch
(
p
,
img2img_batch_input_dir
,
img2img_batch_output_dir
,
img2img_batch_inpaint_mask_dir
,
args
,
to_scale
=
selected_scale_tab
==
1
,
scale_by
=
scale_by
,
use_png_info
=
img2img_batch_use_png_info
,
png_info_props
=
img2img_batch_png_info_props
,
png_info_dir
=
img2img_batch_png_info_dir
)
process_batch
(
p
,
img2img_batch_input_dir
,
img2img_batch_output_dir
,
img2img_batch_inpaint_mask_dir
,
args
,
to_scale
=
selected_scale_tab
==
1
,
scale_by
=
scale_by
,
use_png_info
=
img2img_batch_use_png_info
,
png_info_props
=
img2img_batch_png_info_props
,
png_info_dir
=
img2img_batch_png_info_dir
)
processed
=
Processed
(
p
,
[],
p
.
seed
,
""
)
processed
=
Processed
(
p
,
[],
p
.
seed
,
""
)
else
:
else
:
processed
=
modules
.
scripts
.
scripts_img2img
.
run
(
p
,
*
args
)
processed
=
modules
.
scripts
.
scripts_img2img
.
run
(
p
,
*
args
)
if
processed
is
None
:
if
processed
is
None
:
processed
=
process_images
(
p
)
processed
=
process_images
(
p
)
p
.
close
()
shared
.
total_tqdm
.
clear
()
shared
.
total_tqdm
.
clear
()
...
...
modules/textual_inversion/textual_inversion.py
View file @
910d4f61
import
os
import
os
from
collections
import
namedtuple
from
collections
import
namedtuple
from
contextlib
import
closing
import
torch
import
torch
import
tqdm
import
tqdm
...
@@ -584,8 +585,9 @@ def train_embedding(id_task, embedding_name, learn_rate, batch_size, gradient_st
...
@@ -584,8 +585,9 @@ def train_embedding(id_task, embedding_name, learn_rate, batch_size, gradient_st
preview_text
=
p
.
prompt
preview_text
=
p
.
prompt
processed
=
processing
.
process_images
(
p
)
with
closing
(
p
):
image
=
processed
.
images
[
0
]
if
len
(
processed
.
images
)
>
0
else
None
processed
=
processing
.
process_images
(
p
)
image
=
processed
.
images
[
0
]
if
len
(
processed
.
images
)
>
0
else
None
if
unload
:
if
unload
:
shared
.
sd_model
.
first_stage_model
.
to
(
devices
.
cpu
)
shared
.
sd_model
.
first_stage_model
.
to
(
devices
.
cpu
)
...
...
modules/txt2img.py
View file @
910d4f61
from
contextlib
import
closing
import
modules.scripts
import
modules.scripts
from
modules
import
sd_samplers
,
processing
from
modules
import
sd_samplers
,
processing
from
modules.generation_parameters_copypaste
import
create_override_settings_dict
from
modules.generation_parameters_copypaste
import
create_override_settings_dict
...
@@ -53,12 +55,11 @@ def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, step
...
@@ -53,12 +55,11 @@ def txt2img(id_task: str, prompt: str, negative_prompt: str, prompt_styles, step
if
cmd_opts
.
enable_console_prompts
:
if
cmd_opts
.
enable_console_prompts
:
print
(
f
"
\n
txt2img: {prompt}"
,
file
=
shared
.
progress_print_out
)
print
(
f
"
\n
txt2img: {prompt}"
,
file
=
shared
.
progress_print_out
)
processed
=
modules
.
scripts
.
scripts_txt2img
.
run
(
p
,
*
args
)
with
closing
(
p
):
processed
=
modules
.
scripts
.
scripts_txt2img
.
run
(
p
,
*
args
)
if
processed
is
None
:
processed
=
processing
.
process_images
(
p
)
p
.
close
()
if
processed
is
None
:
processed
=
processing
.
process_images
(
p
)
shared
.
total_tqdm
.
clear
()
shared
.
total_tqdm
.
clear
()
...
...
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