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
6c88eaed
Commit
6c88eaed
authored
Jan 12, 2023
by
space-nuko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add script callback for fixing infotext parameters
parent
d7aec59c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
generation_parameters_copypaste.py
modules/generation_parameters_copypaste.py
+2
-1
script_callbacks.py
modules/script_callbacks.py
+19
-1
No files found.
modules/generation_parameters_copypaste.py
View file @
6c88eaed
...
@@ -7,7 +7,7 @@ from pathlib import Path
...
@@ -7,7 +7,7 @@ from pathlib import Path
import
gradio
as
gr
import
gradio
as
gr
from
modules.shared
import
script_path
from
modules.shared
import
script_path
from
modules
import
shared
,
ui_tempdir
from
modules
import
shared
,
ui_tempdir
,
script_callbacks
import
tempfile
import
tempfile
from
PIL
import
Image
from
PIL
import
Image
...
@@ -298,6 +298,7 @@ def connect_paste(button, paste_fields, input_comp, jsfunc=None):
...
@@ -298,6 +298,7 @@ def connect_paste(button, paste_fields, input_comp, jsfunc=None):
prompt
=
file
.
read
()
prompt
=
file
.
read
()
params
=
parse_generation_parameters
(
prompt
)
params
=
parse_generation_parameters
(
prompt
)
script_callbacks
.
infotext_pasted_callback
(
prompt
,
params
)
res
=
[]
res
=
[]
for
output
,
key
in
paste_fields
:
for
output
,
key
in
paste_fields
:
...
...
modules/script_callbacks.py
View file @
6c88eaed
...
@@ -2,7 +2,7 @@ import sys
...
@@ -2,7 +2,7 @@ import sys
import
traceback
import
traceback
from
collections
import
namedtuple
from
collections
import
namedtuple
import
inspect
import
inspect
from
typing
import
Optional
from
typing
import
Optional
,
Dict
,
Any
from
fastapi
import
FastAPI
from
fastapi
import
FastAPI
from
gradio
import
Blocks
from
gradio
import
Blocks
...
@@ -71,6 +71,7 @@ callback_map = dict(
...
@@ -71,6 +71,7 @@ callback_map = dict(
callbacks_before_component
=
[],
callbacks_before_component
=
[],
callbacks_after_component
=
[],
callbacks_after_component
=
[],
callbacks_image_grid
=
[],
callbacks_image_grid
=
[],
callbacks_infotext_pasted
=
[],
callbacks_script_unloaded
=
[],
callbacks_script_unloaded
=
[],
)
)
...
@@ -172,6 +173,14 @@ def image_grid_callback(params: ImageGridLoopParams):
...
@@ -172,6 +173,14 @@ def image_grid_callback(params: ImageGridLoopParams):
report_exception
(
c
,
'image_grid'
)
report_exception
(
c
,
'image_grid'
)
def
infotext_pasted_callback
(
infotext
:
str
,
params
:
Dict
[
str
,
Any
]):
for
c
in
callback_map
[
'callbacks_infotext_pasted'
]:
try
:
c
.
callback
(
infotext
,
params
)
except
Exception
:
report_exception
(
c
,
'infotext_pasted'
)
def
script_unloaded_callback
():
def
script_unloaded_callback
():
for
c
in
reversed
(
callback_map
[
'callbacks_script_unloaded'
]):
for
c
in
reversed
(
callback_map
[
'callbacks_script_unloaded'
]):
try
:
try
:
...
@@ -290,6 +299,15 @@ def on_image_grid(callback):
...
@@ -290,6 +299,15 @@ def on_image_grid(callback):
add_callback
(
callback_map
[
'callbacks_image_grid'
],
callback
)
add_callback
(
callback_map
[
'callbacks_image_grid'
],
callback
)
def
on_infotext_pasted
(
callback
):
"""register a function to be called before applying an infotext.
The callback is called with two arguments:
- infotext: str - raw infotext.
- result: Dict[str, any] - parsed infotext parameters.
"""
add_callback
(
callback_map
[
'callbacks_infotext_pasted'
],
callback
)
def
on_script_unloaded
(
callback
):
def
on_script_unloaded
(
callback
):
"""register a function to be called before the script is unloaded. Any hooks/hijacks/monkeying about that
"""register a function to be called before the script is unloaded. Any hooks/hijacks/monkeying about that
the script did should be reverted here"""
the script did should be reverted here"""
...
...
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