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
77dcb216
Commit
77dcb216
authored
Sep 17, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
2f18823e
d94b4147
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
136 additions
and
16 deletions
+136
-16
extras.py
modules/extras.py
+3
-2
processing.py
modules/processing.py
+8
-1
script.js
script.js
+63
-2
prompts_from_file.py
scripts/prompts_from_file.py
+25
-11
style.css
style.css
+37
-0
No files found.
modules/extras.py
View file @
77dcb216
...
@@ -111,8 +111,9 @@ def run_pnginfo(image):
...
@@ -111,8 +111,9 @@ def run_pnginfo(image):
items
[
'exif comment'
]
=
exif_comment
items
[
'exif comment'
]
=
exif_comment
for
field
in
[
'jfif'
,
'jfif_version'
,
'jfif_unit'
,
'jfif_density'
,
'dpi'
,
'exif'
]:
for
field
in
[
'jfif'
,
'jfif_version'
,
'jfif_unit'
,
'jfif_density'
,
'dpi'
,
'exif'
,
del
items
[
field
]
'loop'
,
'background'
,
'timestamp'
,
'duration'
]:
items
.
pop
(
field
,
None
)
info
=
''
info
=
''
...
...
modules/processing.py
View file @
77dcb216
...
@@ -188,7 +188,11 @@ def fix_seed(p):
...
@@ -188,7 +188,11 @@ def fix_seed(p):
def
process_images
(
p
:
StableDiffusionProcessing
)
->
Processed
:
def
process_images
(
p
:
StableDiffusionProcessing
)
->
Processed
:
"""this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch"""
"""this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch"""
assert
p
.
prompt
is
not
None
if
type
(
p
.
prompt
)
==
list
:
assert
(
len
(
p
.
prompt
)
>
0
)
else
:
assert
p
.
prompt
is
not
None
devices
.
torch_gc
()
devices
.
torch_gc
()
fix_seed
(
p
)
fix_seed
(
p
)
...
@@ -265,6 +269,9 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
...
@@ -265,6 +269,9 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
seeds
=
all_seeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
seeds
=
all_seeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
subseeds
=
all_subseeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
subseeds
=
all_subseeds
[
n
*
p
.
batch_size
:(
n
+
1
)
*
p
.
batch_size
]
if
(
len
(
prompts
)
==
0
):
break
#uc = p.sd_model.get_learned_conditioning(len(prompts) * [p.negative_prompt])
#uc = p.sd_model.get_learned_conditioning(len(prompts) * [p.negative_prompt])
#c = p.sd_model.get_learned_conditioning(prompts)
#c = p.sd_model.get_learned_conditioning(prompts)
uc
=
prompt_parser
.
get_learned_conditioning
(
len
(
prompts
)
*
[
p
.
negative_prompt
],
p
.
steps
)
uc
=
prompt_parser
.
get_learned_conditioning
(
len
(
prompts
)
*
[
p
.
negative_prompt
],
p
.
steps
)
...
...
script.js
View file @
77dcb216
...
@@ -76,6 +76,41 @@ function gradioApp(){
...
@@ -76,6 +76,41 @@ function gradioApp(){
global_progressbar
=
null
global_progressbar
=
null
function
closeModal
()
{
gradioApp
().
getElementById
(
"lightboxModal"
).
style
.
display
=
"none"
;
}
function
showModal
(
elem
)
{
gradioApp
().
getElementById
(
"modalImage"
).
src
=
elem
.
src
gradioApp
().
getElementById
(
"lightboxModal"
).
style
.
display
=
"block"
;
}
function
showGalleryImage
(){
setTimeout
(
function
()
{
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'img.w-full.object-contain'
)
if
(
fullImg_preview
!=
null
){
fullImg_preview
.
forEach
(
function
function_name
(
e
)
{
if
(
e
&&
e
.
parentElement
.
tagName
==
'DIV'
){
e
.
style
.
cursor
=
'pointer'
elemfunc
=
function
(
elem
){
elem
.
onclick
=
function
(){
showModal
(
elem
)};
}
elemfunc
(
e
)
}
});
}
},
100
);
}
function
galleryImageHandler
(
e
){
if
(
e
&&
e
.
parentElement
.
tagName
==
'BUTTON'
){
e
.
onclick
=
showGalleryImage
;
}
}
function
addTitles
(
root
){
function
addTitles
(
root
){
root
.
querySelectorAll
(
'span, button, select'
).
forEach
(
function
(
span
){
root
.
querySelectorAll
(
'span, button, select'
).
forEach
(
function
(
span
){
tooltip
=
titles
[
span
.
textContent
];
tooltip
=
titles
[
span
.
textContent
];
...
@@ -117,13 +152,18 @@ function addTitles(root){
...
@@ -117,13 +152,18 @@ function addTitles(root){
img2img_preview
.
style
.
width
=
img2img_gallery
.
clientWidth
+
"px"
img2img_preview
.
style
.
width
=
img2img_gallery
.
clientWidth
+
"px"
img2img_preview
.
style
.
height
=
img2img_gallery
.
clientHeight
+
"px"
img2img_preview
.
style
.
height
=
img2img_gallery
.
clientHeight
+
"px"
}
}
window
.
setTimeout
(
requestProgress
,
500
)
window
.
setTimeout
(
requestProgress
,
500
)
});
});
mutationObserver
.
observe
(
progressbar
,
{
childList
:
true
,
subtree
:
true
})
mutationObserver
.
observe
(
progressbar
,
{
childList
:
true
,
subtree
:
true
})
}
}
fullImg_preview
=
gradioApp
().
querySelectorAll
(
'img.w-full'
)
if
(
fullImg_preview
!=
null
){
fullImg_preview
.
forEach
(
galleryImageHandler
);
}
}
}
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
document
.
addEventListener
(
"DOMContentLoaded"
,
function
()
{
...
@@ -131,6 +171,27 @@ document.addEventListener("DOMContentLoaded", function() {
...
@@ -131,6 +171,27 @@ document.addEventListener("DOMContentLoaded", function() {
addTitles
(
gradioApp
());
addTitles
(
gradioApp
());
});
});
mutationObserver
.
observe
(
gradioApp
(),
{
childList
:
true
,
subtree
:
true
})
mutationObserver
.
observe
(
gradioApp
(),
{
childList
:
true
,
subtree
:
true
})
const
modalFragment
=
document
.
createDocumentFragment
();
const
modal
=
document
.
createElement
(
'div'
)
modal
.
onclick
=
closeModal
;
const
modalClose
=
document
.
createElement
(
'span'
)
modalClose
.
className
=
'modalClose cursor'
;
modalClose
.
innerHTML
=
'×'
modalClose
.
onclick
=
closeModal
;
modal
.
id
=
"lightboxModal"
;
modal
.
appendChild
(
modalClose
)
const
modalImage
=
document
.
createElement
(
'img'
)
modalImage
.
id
=
'modalImage'
;
modalImage
.
onclick
=
closeModal
;
modal
.
appendChild
(
modalImage
)
gradioApp
().
getRootNode
().
appendChild
(
modal
)
document
.
body
.
appendChild
(
modalFragment
);
});
});
function
selected_gallery_index
(){
function
selected_gallery_index
(){
...
...
scripts/prompts_from_file.py
View file @
77dcb216
...
@@ -13,28 +13,42 @@ from modules.shared import opts, cmd_opts, state
...
@@ -13,28 +13,42 @@ from modules.shared import opts, cmd_opts, state
class
Script
(
scripts
.
Script
):
class
Script
(
scripts
.
Script
):
def
title
(
self
):
def
title
(
self
):
return
"Prompts from file"
return
"Prompts from file
or textbox
"
def
ui
(
self
,
is_img2img
):
def
ui
(
self
,
is_img2img
):
# This checkbox would look nicer as two tabs, but there are two problems:
# 1) There is a bug in Gradio 3.3 that prevents visibility from working on Tabs
# 2) Even with Gradio 3.3.1, returning a control (like Tabs) that can't be used as input
# causes a AttributeError: 'Tabs' object has no attribute 'preprocess' assert,
# due to the way Script assumes all controls returned can be used as inputs.
# Therefore, there's no good way to use grouping components right now,
# so we will use a checkbox! :)
checkbox_txt
=
gr
.
Checkbox
(
label
=
"Show Textbox"
,
value
=
False
)
file
=
gr
.
File
(
label
=
"File with inputs"
,
type
=
'bytes'
)
file
=
gr
.
File
(
label
=
"File with inputs"
,
type
=
'bytes'
)
prompt_txt
=
gr
.
TextArea
(
label
=
"Prompts"
)
return
[
file
]
checkbox_txt
.
change
(
fn
=
lambda
x
:
[
gr
.
File
.
update
(
visible
=
not
x
),
gr
.
TextArea
.
update
(
visible
=
x
)],
inputs
=
[
checkbox_txt
],
outputs
=
[
file
,
prompt_txt
])
return
[
checkbox_txt
,
file
,
prompt_txt
]
def
run
(
self
,
p
,
data
:
bytes
):
lines
=
[
x
.
strip
()
for
x
in
data
.
decode
(
'utf8'
,
errors
=
'ignore'
)
.
split
(
"
\n
"
)]
def
run
(
self
,
p
,
checkbox_txt
,
data
:
bytes
,
prompt_txt
:
str
):
if
(
checkbox_txt
):
lines
=
[
x
.
strip
()
for
x
in
prompt_txt
.
splitlines
()]
else
:
lines
=
[
x
.
strip
()
for
x
in
data
.
decode
(
'utf8'
,
errors
=
'ignore'
)
.
split
(
"
\n
"
)]
lines
=
[
x
for
x
in
lines
if
len
(
x
)
>
0
]
lines
=
[
x
for
x
in
lines
if
len
(
x
)
>
0
]
batch_count
=
math
.
ceil
(
len
(
lines
)
/
p
.
batch_size
)
img_count
=
len
(
lines
)
*
p
.
n_iter
print
(
f
"Will process {len(lines) * p.n_iter} images in {batch_count * p.n_iter} batches."
)
batch_count
=
math
.
ceil
(
img_count
/
p
.
batch_size
)
loop_count
=
math
.
ceil
(
batch_count
/
p
.
n_iter
)
print
(
f
"Will process {img_count} images in {batch_count} batches."
)
p
.
do_not_save_grid
=
True
p
.
do_not_save_grid
=
True
state
.
job_count
=
batch_count
state
.
job_count
=
batch_count
images
=
[]
images
=
[]
for
batch_no
in
range
(
batch
_count
):
for
loop_no
in
range
(
loop
_count
):
state
.
job
=
f
"{
batch_no + 1} out of {batch_count * p.n_iter
}"
state
.
job
=
f
"{
loop_no + 1} out of {loop_count
}"
p
.
prompt
=
lines
[
batch_no
*
p
.
batch_size
:(
batch
_no
+
1
)
*
p
.
batch_size
]
*
p
.
n_iter
p
.
prompt
=
lines
[
loop_no
*
p
.
batch_size
:(
loop
_no
+
1
)
*
p
.
batch_size
]
*
p
.
n_iter
proc
=
process_images
(
p
)
proc
=
process_images
(
p
)
images
+=
proc
.
images
images
+=
proc
.
images
...
...
style.css
View file @
77dcb216
...
@@ -196,3 +196,40 @@ input[type="range"]{
...
@@ -196,3 +196,40 @@ input[type="range"]{
border-radius
:
8px
;
border-radius
:
8px
;
}
}
#lightboxModal
{
display
:
none
;
position
:
fixed
;
z-index
:
900
;
padding-top
:
100px
;
left
:
0
;
top
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
auto
;
background-color
:
rgba
(
20
,
20
,
20
,
0.95
);
}
.modalClose
{
color
:
white
;
position
:
absolute
;
top
:
10px
;
right
:
25px
;
font-size
:
35px
;
font-weight
:
bold
;
}
.modalClose
:hover
,
.modalClose
:focus
{
color
:
#999
;
text-decoration
:
none
;
cursor
:
pointer
;
}
#modalImage
{
display
:
block
;
margin-left
:
auto
;
margin-right
:
auto
;
margin-top
:
auto
;
width
:
auto
;
}
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