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
8683427b
Commit
8683427b
authored
Jan 18, 2023
by
Vladimir Repin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Process interrogation on all img2img subtabs
parent
3a0d6b77
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
7 deletions
+50
-7
ui.js
javascript/ui.js
+7
-0
ui.py
modules/ui.py
+43
-7
No files found.
javascript/ui.js
View file @
8683427b
...
...
@@ -109,6 +109,13 @@ function get_extras_tab_index(){
return
[
get_tab_index
(
'mode_extras'
),
get_tab_index
(
'extras_resize_mode'
),
...
args
]
}
function
get_img2img_tab_index
()
{
let
res
=
args_to_array
(
arguments
)
res
.
splice
(
-
2
)
res
[
0
]
=
get_tab_index
(
'mode_img2img'
)
return
res
}
function
create_submit_args
(
args
){
res
=
[]
for
(
var
i
=
0
;
i
<
args
.
length
;
i
++
){
...
...
modules/ui.py
View file @
8683427b
...
...
@@ -204,9 +204,31 @@ def apply_styles(prompt, prompt_neg, style1_name, style2_name):
return
[
gr
.
Textbox
.
update
(
value
=
prompt
),
gr
.
Textbox
.
update
(
value
=
prompt_neg
),
gr
.
Dropdown
.
update
(
value
=
"None"
),
gr
.
Dropdown
.
update
(
value
=
"None"
)]
def
process_interrogate
(
interrogation_function
,
mode
,
ii_input_dir
,
ii_output_dir
,
*
ii_singles
):
if
mode
in
{
0
,
1
,
3
,
4
}:
return
[
interrogation_function
(
ii_singles
[
mode
]),
None
]
elif
mode
==
2
:
return
[
interrogation_function
(
ii_singles
[
mode
][
"image"
]),
None
]
elif
mode
==
5
:
assert
not
shared
.
cmd_opts
.
hide_ui_dir_config
,
"Launched with --hide-ui-dir-config, batch img2img disabled"
images
=
shared
.
listfiles
(
ii_input_dir
)
print
(
f
"Will process {len(images)} images."
)
if
ii_output_dir
!=
""
:
os
.
makedirs
(
ii_output_dir
,
exist_ok
=
True
)
else
:
ii_output_dir
=
ii_input_dir
for
image
in
images
:
img
=
Image
.
open
(
image
)
filename
=
os
.
path
.
basename
(
image
)
left
,
_
=
os
.
path
.
splitext
(
filename
)
print
(
interrogation_function
(
img
),
file
=
open
(
os
.
path
.
join
(
ii_output_dir
,
left
+
".txt"
),
'a'
))
return
[
gr_show
(
True
),
None
]
def
interrogate
(
image
):
prompt
=
shared
.
interrogator
.
interrogate
(
image
.
convert
(
"RGB"
))
return
gr_show
(
True
)
if
prompt
is
None
else
prompt
...
...
@@ -983,19 +1005,33 @@ def create_ui():
show_progress
=
False
,
)
interrogate_args
=
dict
(
_js
=
"get_img2img_tab_index"
,
inputs
=
[
dummy_component
,
img2img_batch_input_dir
,
img2img_batch_output_dir
,
init_img
,
sketch
,
init_img_with_mask
,
inpaint_color_sketch
,
init_img_inpaint
,
],
outputs
=
[
img2img_prompt
,
dummy_component
],
show_progress
=
False
,
)
img2img_prompt
.
submit
(
**
img2img_args
)
submit
.
click
(
**
img2img_args
)
img2img_interrogate
.
click
(
fn
=
interrogate
,
inputs
=
[
init_img
],
outputs
=
[
img2img_prompt
],
fn
=
lambda
*
args
:
process_interrogate
(
interrogate
,
*
args
),
**
interrogate_args
,
)
img2img_deepbooru
.
click
(
fn
=
interrogate_deepbooru
,
inputs
=
[
init_img
],
outputs
=
[
img2img_prompt
],
fn
=
lambda
*
args
:
process_interrogate
(
interrogate_deepbooru
,
*
args
),
**
interrogate_args
,
)
prompts
=
[(
txt2img_prompt
,
txt2img_negative_prompt
),
(
img2img_prompt
,
img2img_negative_prompt
)]
...
...
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