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
0aec19d7
Commit
0aec19d7
authored
Oct 14, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make pasting into img2img prompt work
make image params request not use temp files
parent
33ae6be5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
24 deletions
+21
-24
images.py
modules/images.py
+18
-18
ui.py
modules/ui.py
+3
-6
No files found.
modules/images.py
View file @
0aec19d7
import
datetime
import
datetime
import
io
import
math
import
math
import
os
import
os
from
collections
import
namedtuple
from
collections
import
namedtuple
...
@@ -465,21 +466,20 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
...
@@ -465,21 +466,20 @@ def save_image(image, path, basename, seed=None, prompt=None, extension='png', i
return
fullfn
,
txt_fullfn
return
fullfn
,
txt_fullfn
def
image_data
(
image_path
):
def
image_data
(
data
):
file
,
ext
=
os
.
path
.
splitext
(
image_path
.
name
)
try
:
data
=
{}
image
=
Image
.
open
(
io
.
BytesIO
(
data
))
if
"png"
in
ext
:
textinfo
=
image
.
text
[
"parameters"
]
image
=
Image
.
open
(
image_path
.
name
,
"r"
)
return
textinfo
,
None
print
(
f
"Image data requested for {image_path.name} {image.format} of {type(image)}"
)
except
Exception
:
try
:
pass
data
=
image
.
text
[
"parameters"
]
except
Exception
as
e
:
try
:
print
(
f
"Exception: {e}"
)
text
=
data
.
decode
(
'utf8'
)
pass
assert
len
(
text
)
<
10000
print
(
f
"Image data: {data}"
)
return
text
,
None
if
"txt"
in
ext
:
myfile
=
open
(
image_path
.
name
,
'r'
)
except
Exception
:
data
=
myfile
.
read
()
pass
myfile
.
close
()
return
''
,
None
return
data
,
None
modules/ui.py
View file @
0aec19d7
...
@@ -514,7 +514,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -514,7 +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
)
txt_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"txt2img_prompt_image"
,
file_count
=
"single"
,
type
=
"
bytes
"
,
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
):
...
@@ -620,7 +620,6 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -620,7 +620,6 @@ def create_ui(wrap_gradio_gpu_call):
txt_prompt_img
.
change
(
txt_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
fn
=
modules
.
images
.
image_data
,
# _js = "get_extras_tab_index",
inputs
=
[
inputs
=
[
txt_prompt_img
txt_prompt_img
],
],
...
@@ -692,8 +691,7 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -692,8 +691,7 @@ 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"
,
img2img_prompt_img
=
gr
.
File
(
label
=
""
,
elem_id
=
"img2img_prompt_image"
,
file_count
=
"single"
,
type
=
"bytes"
,
visible
=
False
)
visible
=
False
)
with
gr
.
Column
(
scale
=
1
):
with
gr
.
Column
(
scale
=
1
):
pass
pass
...
@@ -791,9 +789,8 @@ def create_ui(wrap_gradio_gpu_call):
...
@@ -791,9 +789,8 @@ def create_ui(wrap_gradio_gpu_call):
img2img_prompt_img
.
change
(
img2img_prompt_img
.
change
(
fn
=
modules
.
images
.
image_data
,
fn
=
modules
.
images
.
image_data
,
# _js = "get_extras_tab_index",
inputs
=
[
inputs
=
[
txt
_prompt_img
img2img
_prompt_img
],
],
outputs
=
[
outputs
=
[
img2img_prompt
,
img2img_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