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
e808096c
Commit
e808096c
authored
Oct 02, 2022
by
DepFA
Committed by
GitHub
Oct 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct indent
parent
2deea867
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
36 deletions
+37
-36
modules/scripts.py
modules/scripts.py
+25
-23
modules/ui.py
modules/ui.py
+12
-13
No files found.
modules/scripts.py
View file @
e808096c
...
@@ -163,37 +163,39 @@ class ScriptRunner:
...
@@ -163,37 +163,39 @@ class ScriptRunner:
return
processed
return
processed
def
reload_sources
(
self
):
def
reload_sources
(
self
):
for
si
,
script
in
list
(
enumerate
(
self
.
scripts
)):
for
si
,
script
in
list
(
enumerate
(
self
.
scripts
)):
with
open
(
script
.
filename
,
"r"
,
encoding
=
"utf8"
)
as
file
:
with
open
(
script
.
filename
,
"r"
,
encoding
=
"utf8"
)
as
file
:
args_from
=
script
.
args_from
args_from
=
script
.
args_from
args_to
=
script
.
args_to
args_to
=
script
.
args_to
filename
=
script
.
filename
filename
=
script
.
filename
text
=
file
.
read
()
text
=
file
.
read
()
from
types
import
ModuleType
from
types
import
ModuleType
compiled
=
compile
(
text
,
filename
,
'exec'
)
module
=
ModuleType
(
script
.
filename
)
exec
(
compiled
,
module
.
__dict__
)
for
key
,
script_class
in
module
.
__dict__
.
items
():
compiled
=
compile
(
text
,
filename
,
'exec'
)
if
type
(
script_class
)
==
type
and
issubclass
(
script_class
,
Script
):
module
=
ModuleType
(
script
.
filename
)
self
.
scripts
[
si
]
=
script_class
()
exec
(
compiled
,
module
.
__dict__
)
self
.
scripts
[
si
]
.
filename
=
filename
self
.
scripts
[
si
]
.
args_from
=
args_from
for
key
,
script_class
in
module
.
__dict__
.
items
():
self
.
scripts
[
si
]
.
args_to
=
args_to
if
type
(
script_class
)
==
type
and
issubclass
(
script_class
,
Script
):
self
.
scripts
[
si
]
=
script_class
()
self
.
scripts
[
si
]
.
filename
=
filename
self
.
scripts
[
si
]
.
args_from
=
args_from
self
.
scripts
[
si
]
.
args_to
=
args_to
scripts_txt2img
=
ScriptRunner
()
scripts_txt2img
=
ScriptRunner
()
scripts_img2img
=
ScriptRunner
()
scripts_img2img
=
ScriptRunner
()
def
reload_script_body_only
():
def
reload_script_body_only
():
scripts_txt2img
.
reload_sources
()
scripts_txt2img
.
reload_sources
()
scripts_img2img
.
reload_sources
()
scripts_img2img
.
reload_sources
()
def
reload_scripts
(
basedir
):
def
reload_scripts
(
basedir
):
global
scripts_txt2img
,
scripts_img2img
global
scripts_txt2img
,
scripts_img2img
scripts_data
.
clear
()
scripts_data
.
clear
()
load_scripts
(
basedir
)
load_scripts
(
basedir
)
scripts_txt2img
=
ScriptRunner
()
scripts_txt2img
=
ScriptRunner
()
scripts_img2img
=
ScriptRunner
()
scripts_img2img
=
ScriptRunner
()
modules/ui.py
View file @
e808096c
...
@@ -1003,12 +1003,12 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
...
@@ -1003,12 +1003,12 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
)
)
with
gr
.
Row
():
with
gr
.
Row
():
reload_script_bodies
=
gr
.
Button
(
value
=
'Reload custom script bodies (No ui updates, No restart)'
,
variant
=
'secondary'
)
reload_script_bodies
=
gr
.
Button
(
value
=
'Reload custom script bodies (No ui updates, No restart)'
,
variant
=
'secondary'
)
restart_gradio
=
gr
.
Button
(
value
=
'Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)'
,
variant
=
'primary'
)
restart_gradio
=
gr
.
Button
(
value
=
'Restart Gradio and Refresh components (Custom Scripts, ui.py, js and css only)'
,
variant
=
'primary'
)
def
reload_scripts
():
def
reload_scripts
():
modules
.
scripts
.
reload_script_body_only
()
modules
.
scripts
.
reload_script_body_only
()
reload_script_bodies
.
click
(
reload_script_bodies
.
click
(
fn
=
reload_scripts
,
fn
=
reload_scripts
,
...
@@ -1018,7 +1018,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
...
@@ -1018,7 +1018,7 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo, run_modelmerger):
)
)
def
request_restart
():
def
request_restart
():
settings_interface
.
gradio_ref
.
do_restart
=
True
settings_interface
.
gradio_ref
.
do_restart
=
True
restart_gradio
.
click
(
restart_gradio
.
click
(
fn
=
request_restart
,
fn
=
request_restart
,
...
@@ -1234,12 +1234,11 @@ for filename in sorted(os.listdir(jsdir)):
...
@@ -1234,12 +1234,11 @@ for filename in sorted(os.listdir(jsdir)):
if
'gradio_routes_templates_response'
not
in
globals
():
if
'gradio_routes_templates_response'
not
in
globals
():
def
template_response
(
*
args
,
**
kwargs
):
def
template_response
(
*
args
,
**
kwargs
):
res
=
gradio_routes_templates_response
(
*
args
,
**
kwargs
)
res
=
gradio_routes_templates_response
(
*
args
,
**
kwargs
)
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{javascript}</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'{javascript}</head>'
.
encode
(
"utf8"
))
res
.
init_headers
()
res
.
init_headers
()
return
res
return
res
gradio_routes_templates_response
=
gradio
.
routes
.
templates
.
TemplateResponse
gradio_routes_templates_response
=
gradio
.
routes
.
templates
.
TemplateResponse
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
gradio
.
routes
.
templates
.
TemplateResponse
=
template_response
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