Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
e49c4798
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
11 个月 前同步成功
通知
1766
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
e49c4798
编写于
3月 28, 2023
作者:
A
AUTOMATIC1111
提交者:
GitHub
3月 28, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9031 from AUTOMATIC1111/serve-css-as-files
serve css as independent files
上级
955df775
77f9db3b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
33 deletion
+41
-33
modules/ui.py
modules/ui.py
+41
-33
未找到文件。
modules/ui.py
浏览文件 @
e49c4798
...
...
@@ -70,17 +70,6 @@ def gr_show(visible=True):
sample_img2img
=
"assets/stable-samples/img2img/sketch-mountains-input.jpg"
sample_img2img
=
sample_img2img
if
os
.
path
.
exists
(
sample_img2img
)
else
None
css_hide_progressbar
=
"""
.wrap .m-12 svg { display:none!important; }
.wrap .m-12::before { content:"Loading..." }
.wrap .z-20 svg { display:none!important; }
.wrap .z-20::before { content:"Loading..." }
.wrap.cover-bg .z-20::before { content:"" }
.progress-bar { display:none!important; }
.meta-text { display:none!important; }
.meta-text-center { display:none!important; }
"""
# Using constants for these since the variation selector isn't visible.
# Important that they exactly match script.js for tooltip to work.
random_symbol
=
'
\U0001f3b2\ufe0f
'
# 🎲️
...
...
@@ -1566,22 +1555,6 @@ def create_ui():
(
train_interface
,
"Train"
,
"ti"
),
]
css
=
""
for
cssfile
in
modules
.
scripts
.
list_files_with_name
(
"style.css"
):
if
not
os
.
path
.
isfile
(
cssfile
):
continue
with
open
(
cssfile
,
"r"
,
encoding
=
"utf8"
)
as
file
:
css
+=
file
.
read
()
+
"
\n
"
if
os
.
path
.
exists
(
os
.
path
.
join
(
data_path
,
"user.css"
)):
with
open
(
os
.
path
.
join
(
data_path
,
"user.css"
),
"r"
,
encoding
=
"utf8"
)
as
file
:
css
+=
file
.
read
()
+
"
\n
"
if
not
cmd_opts
.
no_progressbar_hiding
:
css
+=
css_hide_progressbar
interfaces
+=
script_callbacks
.
ui_tabs_callback
()
interfaces
+=
[(
settings_interface
,
"Settings"
,
"settings"
)]
...
...
@@ -1592,7 +1565,7 @@ def create_ui():
for
_interface
,
label
,
_ifid
in
interfaces
:
shared
.
tab_names
.
append
(
label
)
with
gr
.
Blocks
(
css
=
css
,
analytics_enabled
=
False
,
title
=
"Stable Diffusion"
)
as
demo
:
with
gr
.
Blocks
(
analytics_enabled
=
False
,
title
=
"Stable Diffusion"
)
as
demo
:
with
gr
.
Row
(
elem_id
=
"quicksettings"
,
variant
=
"compact"
):
for
i
,
k
,
item
in
sorted
(
quicksettings_list
,
key
=
lambda
x
:
quicksettings_names
.
get
(
x
[
1
],
x
[
0
])):
component
=
create_setting_component
(
k
,
is_quicksettings
=
True
)
...
...
@@ -1777,25 +1750,60 @@ def create_ui():
return
demo
def
reload_javascript
():
def
webpath
(
fn
):
if
fn
.
startswith
(
script_path
):
web_path
=
os
.
path
.
relpath
(
fn
,
script_path
).
replace
(
'
\\
'
,
'/'
)
else
:
web_path
=
os
.
path
.
abspath
(
fn
)
return
f
'file=
{
web_path
}
?
{
os
.
path
.
getmtime
(
fn
)
}
'
def
javascript_html
():
script_js
=
os
.
path
.
join
(
script_path
,
"script.js"
)
head
=
f
'<script type="text/javascript" src="
file=
{
os
.
path
.
abspath
(
script_js
)
}
?
{
os
.
path
.
getmtime
(
script_js
)
}
"></script>
\n
'
head
=
f
'<script type="text/javascript" src="
{
webpath
(
script_js
)
}
"></script>
\n
'
inline
=
f
"
{
localization
.
localization_js
(
shared
.
opts
.
localization
)
}
;"
if
cmd_opts
.
theme
is
not
None
:
inline
+=
f
"set_theme('
{
cmd_opts
.
theme
}
');"
for
script
in
modules
.
scripts
.
list_scripts
(
"javascript"
,
".js"
):
head
+=
f
'<script type="text/javascript" src="
file=
{
script
.
path
}
?
{
os
.
path
.
getmtime
(
script
.
path
)
}
"></script>
\n
'
head
+=
f
'<script type="text/javascript" src="
{
webpath
(
script
.
path
)
}
"></script>
\n
'
for
script
in
modules
.
scripts
.
list_scripts
(
"javascript"
,
".mjs"
):
head
+=
f
'<script type="module" src="
file=
{
script
.
path
}
?
{
os
.
path
.
getmtime
(
script
.
path
)
}
"></script>
\n
'
head
+=
f
'<script type="module" src="
{
webpath
(
script
.
path
)
}
"></script>
\n
'
head
+=
f
'<script type="text/javascript">
{
inline
}
</script>
\n
'
return
head
def
css_html
():
head
=
""
def
stylesheet
(
fn
):
return
f
'<link rel="stylesheet" property="stylesheet" href="
{
webpath
(
fn
)
}
">'
for
cssfile
in
modules
.
scripts
.
list_files_with_name
(
"style.css"
):
if
not
os
.
path
.
isfile
(
cssfile
):
continue
head
+=
stylesheet
(
cssfile
)
if
os
.
path
.
exists
(
os
.
path
.
join
(
data_path
,
"user.css"
)):
head
+=
stylesheet
(
os
.
path
.
join
(
data_path
,
"user.css"
))
return
head
def
reload_javascript
():
js
=
javascript_html
()
css
=
css_html
()
def
template_response
(
*
args
,
**
kwargs
):
res
=
shared
.
GradioTemplateResponseOriginal
(
*
args
,
**
kwargs
)
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'
{
head
}
</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</head>'
,
f
'
{
js
}
</head>'
.
encode
(
"utf8"
))
res
.
body
=
res
.
body
.
replace
(
b
'</body>'
,
f
'
{
css
}
</body>'
.
encode
(
"utf8"
))
res
.
init_headers
()
return
res
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录