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
a156c097
Commit
a156c097
authored
Oct 14, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'param-loading'
parents
e644b5a8
54e0051b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
1 deletion
+74
-1
javascript/dragdrop.js
javascript/dragdrop.js
+3
-0
javascript/imageParams.js
javascript/imageParams.js
+22
-0
modules/images.py
modules/images.py
+20
-0
modules/ui.py
modules/ui.py
+29
-1
No files found.
javascript/dragdrop.js
View file @
a156c097
...
@@ -53,6 +53,9 @@ window.document.addEventListener('dragover', e => {
...
@@ -53,6 +53,9 @@ window.document.addEventListener('dragover', e => {
window
.
document
.
addEventListener
(
'
drop
'
,
e
=>
{
window
.
document
.
addEventListener
(
'
drop
'
,
e
=>
{
const
target
=
e
.
composedPath
()[
0
];
const
target
=
e
.
composedPath
()[
0
];
if
(
target
.
placeholder
===
"
Prompt
"
)
{
return
;
}
const
imgWrap
=
target
.
closest
(
'
[data-testid="image"]
'
);
const
imgWrap
=
target
.
closest
(
'
[data-testid="image"]
'
);
if
(
!
imgWrap
)
{
if
(
!
imgWrap
)
{
return
;
return
;
...
...
javascript/imageParams.js
0 → 100644
View file @
a156c097
window
.
onload
=
(
function
(){
window
.
addEventListener
(
'
drop
'
,
e
=>
{
const
target
=
e
.
composedPath
()[
0
];
const
idx
=
selected_gallery_index
();
let
prompt_target
=
"
txt2img_prompt_image
"
;
if
(
idx
===
1
)
{
prompt_target
=
"
img2img_prompt_image
"
;
}
if
(
target
.
placeholder
===
"
Prompt
"
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
const
imgParent
=
gradioApp
().
getElementById
(
prompt_target
);
const
files
=
e
.
dataTransfer
.
files
;
const
fileInput
=
imgParent
.
querySelector
(
'
input[type="file"]
'
);
if
(
fileInput
)
{
fileInput
.
files
=
files
;
fileInput
.
dispatchEvent
(
new
Event
(
'
change
'
));
}
}
});
});
\ No newline at end of file
modules/images.py
View file @
a156c097
...
@@ -463,3 +463,23 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
...
@@ -463,3 +463,23 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
txt_fullfn
=
None
txt_fullfn
=
None
return
fullfn
,
txt_fullfn
return
fullfn
,
txt_fullfn
def
image_data
(
image_path
):
file
,
ext
=
os
.
path
.
splitext
(
image_path
.
name
)
data
=
{}
if
"png"
in
ext
:
image
=
Image
.
open
(
image_path
.
name
,
"r"
)
print
(
f
"Image data requested for {image_path.name} {image.format} of {type(image)}"
)
try
:
data
=
image
.
text
[
"parameters"
]
except
Exception
as
e
:
print
(
f
"Exception: {e}"
)
pass
print
(
f
"Image data: {data}"
)
if
"txt"
in
ext
:
myfile
=
open
(
image_path
.
name
,
'r'
)
data
=
myfile
.
read
()
myfile
.
close
()
return
data
,
None
modules/ui.py
View file @
a156c097
...
@@ -433,7 +433,6 @@ def create_toprow(is_img2img):
...
@@ -433,7 +433,6 @@ def create_toprow(is_img2img):
with
gr
.
Column
(
scale
=
80
):
with
gr
.
Column
(
scale
=
80
):
with
gr
.
Row
():
with
gr
.
Row
():
prompt
=
gr
.
Textbox
(
label
=
"Prompt"
,
elem_id
=
f
"{id_part}_prompt"
,
show_label
=
False
,
placeholder
=
"Prompt"
,
lines
=
2
)
prompt
=
gr
.
Textbox
(
label
=
"Prompt"
,
elem_id
=
f
"{id_part}_prompt"
,
show_label
=
False
,
placeholder
=
"Prompt"
,
lines
=
2
)
with
gr
.
Column
(
scale
=
1
,
elem_id
=
"roll_col"
):
with
gr
.
Column
(
scale
=
1
,
elem_id
=
"roll_col"
):
roll
=
gr
.
Button
(
value
=
art_symbol
,
elem_id
=
"roll"
,
visible
=
len
(
shared
.
artist_db
.
artists
)
>
0
)
roll
=
gr
.
Button
(
value
=
art_symbol
,
elem_id
=
"roll"
,
visible
=
len
(
shared
.
artist_db
.
artists
)
>
0
)
paste
=
gr
.
Button
(
value
=
paste_symbol
,
elem_id
=
"paste"
)
paste
=
gr
.
Button
(
value
=
paste_symbol
,
elem_id
=
"paste"
)
...
@@ -515,6 +514,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -515,6 +514,7 @@ def create_ui(wrap_gradio_gpu_call):
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
txt2img_interface
:
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
False
)
txt2img_prompt
,
roll
,
txt2img_prompt_style
,
txt2img_negative_prompt
,
txt2img_prompt_style2
,
submit
,
_
,
_
,
txt2img_prompt_style_apply
,
txt2img_save_style
,
paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
dummy_component
=
gr
.
Label
(
visible
=
False
)
txt_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt2img_prompt_image"
,
file_count
=
"single"
,
type
=
"file"
,
visible
=
False
)
with
gr
.
Row
(
elem_id
=
'txt2img_progress_row'
):
with
gr
.
Row
(
elem_id
=
'txt2img_progress_row'
):
with
gr
.
Column
(
scale
=
1
):
with
gr
.
Column
(
scale
=
1
):
...
@@ -618,6 +618,18 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -618,6 +618,18 @@ def create_ui(wrap_gradio_gpu_call):
txt2img_prompt
.
submit
(
**
txt2img_args
)
txt2img_prompt
.
submit
(
**
txt2img_args
)
submit
.
click
(
**
txt2img_args
)
submit
.
click
(
**
txt2img_args
)
txt_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
# _js = "get_extras_tab_index",
inputs
=
[
txt_prompt_img
],
outputs
=
[
txt2img_prompt
,
txt_prompt_img
]
)
enable_hr
.
change
(
enable_hr
.
change
(
fn
=
lambda
x
:
gr_show
(
x
),
fn
=
lambda
x
:
gr_show
(
x
),
inputs
=
[
enable_hr
],
inputs
=
[
enable_hr
],
...
@@ -680,6 +692,9 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -680,6 +692,9 @@ def create_ui(wrap_gradio_gpu_call):
img2img_prompt
,
roll
,
img2img_prompt_style
,
img2img_negative_prompt
,
img2img_prompt_style2
,
submit
,
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
True
)
img2img_prompt
,
roll
,
img2img_prompt_style
,
img2img_negative_prompt
,
img2img_prompt_style2
,
submit
,
img2img_interrogate
,
img2img_deepbooru
,
img2img_prompt_style_apply
,
img2img_save_style
,
paste
,
token_counter
,
token_button
=
create_toprow
(
is_img2img
=
True
)
with
gr
.
Row
(
elem_id
=
'img2img_progress_row'
):
with
gr
.
Row
(
elem_id
=
'img2img_progress_row'
):
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt_prompt_image"
,
file_count
=
"single"
,
type
=
"file"
,
visible
=
False
)
with
gr
.
Column
(
scale
=
1
):
with
gr
.
Column
(
scale
=
1
):
pass
pass
...
@@ -774,6 +789,18 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -774,6 +789,18 @@ def create_ui(wrap_gradio_gpu_call):
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
connect_reuse_seed
(
seed
,
reuse_seed
,
generation_info
,
dummy_component
,
is_subseed
=
False
)
connect_reuse_seed
(
subseed
,
reuse_subseed
,
generation_info
,
dummy_component
,
is_subseed
=
True
)
connect_reuse_seed
(
subseed
,
reuse_subseed
,
generation_info
,
dummy_component
,
is_subseed
=
True
)
img2img_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
# _js = "get_extras_tab_index",
inputs
=
[
txt_prompt_img
],
outputs
=
[
img2img_prompt
,
img2img_prompt_img
]
)
mask_mode
.
change
(
mask_mode
.
change
(
lambda
mode
,
img
:
{
lambda
mode
,
img
:
{
init_img_with_mask
:
gr_show
(
mode
==
0
),
init_img_with_mask
:
gr_show
(
mode
==
0
),
...
@@ -962,6 +989,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -962,6 +989,7 @@ def create_ui(wrap_gradio_gpu_call):
button_id
=
"hidden_element"
if
shared
.
cmd_opts
.
hide_ui_dir_config
else
''
button_id
=
"hidden_element"
if
shared
.
cmd_opts
.
hide_ui_dir_config
else
''
open_extras_folder
=
gr
.
Button
(
'Open output directory'
,
elem_id
=
button_id
)
open_extras_folder
=
gr
.
Button
(
'Open output directory'
,
elem_id
=
button_id
)
submit
.
click
(
submit
.
click
(
fn
=
wrap_gradio_gpu_call
(
modules
.
extras
.
run_extras
),
fn
=
wrap_gradio_gpu_call
(
modules
.
extras
.
run_extras
),
_js
=
"get_extras_tab_index"
,
_js
=
"get_extras_tab_index"
,
...
...
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