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
38a483f9
Commit
38a483f9
authored
Sep 02, 2022
by
AUTOMATIC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buttons for sending images to tabs
parent
78c3735f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
26 deletions
+89
-26
webui.py
webui.py
+89
-26
No files found.
webui.py
View file @
38a483f9
...
@@ -40,6 +40,9 @@ import signal
...
@@ -40,6 +40,9 @@ import signal
import
tqdm
import
tqdm
import
re
import
re
import
threading
import
threading
import
time
import
base64
import
io
import
k_diffusion.sampling
import
k_diffusion.sampling
from
ldm.util
import
instantiate_from_config
from
ldm.util
import
instantiate_from_config
...
@@ -1285,6 +1288,22 @@ def txt2img(prompt: str, negative_prompt: str, steps: int, sampler_index: int, u
...
@@ -1285,6 +1288,22 @@ def txt2img(prompt: str, negative_prompt: str, steps: int, sampler_index: int, u
return
processed
.
images
,
processed
.
js
(),
plaintext_to_html
(
processed
.
info
)
return
processed
.
images
,
processed
.
js
(),
plaintext_to_html
(
processed
.
info
)
def
image_from_url_text
(
filedata
):
if
filedata
.
startswith
(
"data:image/png;base64,"
):
filedata
=
filedata
[
len
(
"data:image/png;base64,"
):]
filedata
=
base64
.
decodebytes
(
filedata
.
encode
(
'utf-8'
))
image
=
Image
.
open
(
io
.
BytesIO
(
filedata
))
return
image
def
send_gradio_gallery_to_image
(
x
):
if
len
(
x
)
==
0
:
return
None
return
image_from_url_text
(
x
[
0
])
def
save_files
(
js_data
,
images
):
def
save_files
(
js_data
,
images
):
import
csv
import
csv
...
@@ -1295,9 +1314,6 @@ def save_files(js_data, images):
...
@@ -1295,9 +1314,6 @@ def save_files(js_data, images):
data
=
json
.
loads
(
js_data
)
data
=
json
.
loads
(
js_data
)
with
open
(
"log/log.csv"
,
"a"
,
encoding
=
"utf8"
,
newline
=
''
)
as
file
:
with
open
(
"log/log.csv"
,
"a"
,
encoding
=
"utf8"
,
newline
=
''
)
as
file
:
import
time
import
base64
at_start
=
file
.
tell
()
==
0
at_start
=
file
.
tell
()
==
0
writer
=
csv
.
writer
(
file
)
writer
=
csv
.
writer
(
file
)
if
at_start
:
if
at_start
:
...
@@ -1352,12 +1368,15 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
...
@@ -1352,12 +1368,15 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Group
():
with
gr
.
Group
():
gallery
=
gr
.
Gallery
(
label
=
'Output'
)
txt2img_
gallery
=
gr
.
Gallery
(
label
=
'Output'
)
with
gr
.
Group
():
with
gr
.
Group
():
with
gr
.
Row
():
with
gr
.
Row
():
interrupt
=
gr
.
Button
(
'Interrupt'
)
save
=
gr
.
Button
(
'Save'
)
save
=
gr
.
Button
(
'Save'
)
send_to_img2img
=
gr
.
Button
(
'Send to img2img'
)
send_to_inpaint
=
gr
.
Button
(
'Send to inpaint'
)
send_to_extras
=
gr
.
Button
(
'Send to extras'
)
interrupt
=
gr
.
Button
(
'Interrupt'
)
with
gr
.
Group
():
with
gr
.
Group
():
html_info
=
gr
.
HTML
()
html_info
=
gr
.
HTML
()
...
@@ -1381,7 +1400,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
...
@@ -1381,7 +1400,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
code
code
],
],
outputs
=
[
outputs
=
[
gallery
,
txt2img_
gallery
,
generation_info
,
generation_info
,
html_info
html_info
]
]
...
@@ -1400,7 +1419,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
...
@@ -1400,7 +1419,7 @@ with gr.Blocks(analytics_enabled=False) as txt2img_interface:
fn
=
wrap_gradio_call
(
save_files
),
fn
=
wrap_gradio_call
(
save_files
),
inputs
=
[
inputs
=
[
generation_info
,
generation_info
,
gallery
,
txt2img_
gallery
,
],
],
outputs
=
[
outputs
=
[
html_info
,
html_info
,
...
@@ -1742,12 +1761,13 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
...
@@ -1742,12 +1761,13 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Group
():
with
gr
.
Group
():
gallery
=
gr
.
Gallery
(
label
=
'Output'
)
img2img_
gallery
=
gr
.
Gallery
(
label
=
'Output'
)
with
gr
.
Group
():
with
gr
.
Group
():
with
gr
.
Row
():
with
gr
.
Row
():
interrupt
=
gr
.
Button
(
'Interrupt'
)
interrupt
=
gr
.
Button
(
'Interrupt'
)
save
=
gr
.
Button
(
'Save'
)
save
=
gr
.
Button
(
'Save'
)
img2img_send_to_extras
=
gr
.
Button
(
'Send to extras'
)
with
gr
.
Group
():
with
gr
.
Group
():
html_info
=
gr
.
HTML
()
html_info
=
gr
.
HTML
()
...
@@ -1815,7 +1835,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
...
@@ -1815,7 +1835,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
inpaint_full_res
,
inpaint_full_res
,
],
],
outputs
=
[
outputs
=
[
gallery
,
img2img_
gallery
,
generation_info
,
generation_info
,
html_info
html_info
]
]
...
@@ -1834,7 +1854,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
...
@@ -1834,7 +1854,7 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
fn
=
wrap_gradio_call
(
save_files
),
fn
=
wrap_gradio_call
(
save_files
),
inputs
=
[
inputs
=
[
generation_info
,
generation_info
,
gallery
,
img2img_
gallery
,
],
],
outputs
=
[
outputs
=
[
html_info
,
html_info
,
...
@@ -1843,6 +1863,19 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
...
@@ -1843,6 +1863,19 @@ with gr.Blocks(analytics_enabled=False) as img2img_interface:
]
]
)
)
send_to_img2img
.
click
(
fn
=
send_gradio_gallery_to_image
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
init_img
],
)
send_to_inpaint
.
click
(
fn
=
send_gradio_gallery_to_image
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
init_img_with_mask
],
)
def
upscale_with_realesrgan
(
image
,
RealESRGAN_upscaling
,
RealESRGAN_model_index
):
def
upscale_with_realesrgan
(
image
,
RealESRGAN_upscaling
,
RealESRGAN_model_index
):
info
=
realesrgan_models
[
RealESRGAN_model_index
]
info
=
realesrgan_models
[
RealESRGAN_model_index
]
...
@@ -1887,22 +1920,52 @@ def run_extras(image, GFPGAN_strength, RealESRGAN_upscaling, RealESRGAN_model_in
...
@@ -1887,22 +1920,52 @@ def run_extras(image, GFPGAN_strength, RealESRGAN_upscaling, RealESRGAN_model_in
return
image
,
''
,
''
return
image
,
''
,
''
extras_interface
=
gr
.
Interface
(
with
gr
.
Blocks
(
analytics_enabled
=
False
)
as
extras_interface
:
wrap_gradio_gpu_call
(
run_extras
),
with
gr
.
Row
()
.
style
(
equal_height
=
False
):
with
gr
.
Column
(
variant
=
'panel'
):
with
gr
.
Group
():
image
=
gr
.
Image
(
label
=
"Source"
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
)
gfpgan_strength
=
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"GFPGAN strength"
,
value
=
1
,
interactive
=
have_gfpgan
)
realesrgan_resize
=
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
4.0
,
step
=
0.05
,
label
=
"Real-ESRGAN upscaling"
,
value
=
2
,
interactive
=
have_realesrgan
)
realesrgan_model
=
gr
.
Radio
(
label
=
'Real-ESRGAN model'
,
choices
=
[
x
.
name
for
x
in
realesrgan_models
],
value
=
realesrgan_models
[
0
]
.
name
,
type
=
"index"
,
interactive
=
have_realesrgan
)
submit
=
gr
.
Button
(
'Generate'
,
elem_id
=
"extras_generate"
,
variant
=
'primary'
)
with
gr
.
Column
(
variant
=
'panel'
):
result_image
=
gr
.
Image
(
label
=
"Result"
)
html_info_x
=
gr
.
HTML
()
html_info
=
gr
.
HTML
()
extras_args
=
dict
(
fn
=
wrap_gradio_gpu_call
(
run_extras
),
inputs
=
[
inputs
=
[
gr
.
Image
(
label
=
"Source"
,
source
=
"upload"
,
interactive
=
True
,
type
=
"pil"
)
,
image
,
gr
.
Slider
(
minimum
=
0.0
,
maximum
=
1.0
,
step
=
0.001
,
label
=
"GFPGAN strength"
,
value
=
1
,
interactive
=
have_gfpgan
)
,
gfpgan_strength
,
gr
.
Slider
(
minimum
=
1.0
,
maximum
=
4.0
,
step
=
0.05
,
label
=
"Real-ESRGAN upscaling"
,
value
=
2
,
interactive
=
have_realesrgan
)
,
realesrgan_resize
,
gr
.
Radio
(
label
=
'Real-ESRGAN model'
,
choices
=
[
x
.
name
for
x
in
realesrgan_models
],
value
=
realesrgan_models
[
0
]
.
name
,
type
=
"index"
,
interactive
=
have_realesrgan
)
,
realesrgan_model
,
],
],
outputs
=
[
outputs
=
[
gr
.
Image
(
label
=
"Result"
),
result_image
,
gr
.
HTML
(),
html_info_x
,
gr
.
HTML
(),
html_info
,
],
]
allow_flagging
=
"never"
,
)
analytics_enabled
=
False
,
)
submit
.
click
(
**
extras_args
)
send_to_extras
.
click
(
fn
=
send_gradio_gallery_to_image
,
inputs
=
[
txt2img_gallery
],
outputs
=
[
image
],
)
img2img_send_to_extras
.
click
(
fn
=
send_gradio_gallery_to_image
,
inputs
=
[
img2img_gallery
],
outputs
=
[
image
],
)
def
run_pnginfo
(
image
):
def
run_pnginfo
(
image
):
...
...
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