@@ -70,17 +70,6 @@ def gr_show(visible=True):
70
70
sample_img2img = "assets/stable-samples/img2img/sketch-mountains-input.jpg"
71
71
sample_img2img = sample_img2img if os .path .exists (sample_img2img ) else None
72
72
73
- css_hide_progressbar = """
74
- .wrap .m-12 svg { display:none!important; }
75
- .wrap .m-12::before { content:"Loading..." }
76
- .wrap .z-20 svg { display:none!important; }
77
- .wrap .z-20::before { content:"Loading..." }
78
- .wrap.cover-bg .z-20::before { content:"" }
79
- .progress-bar { display:none!important; }
80
- .meta-text { display:none!important; }
81
- .meta-text-center { display:none!important; }
82
- """
83
-
84
73
# Using constants for these since the variation selector isn't visible.
85
74
# Important that they exactly match script.js for tooltip to work.
86
75
random_symbol = '\U0001f3b2 \ufe0f ' # 🎲️
@@ -1566,22 +1555,6 @@ def request_restart():
1566
1555
(train_interface , "Train" , "ti" ),
1567
1556
]
1568
1557
1569
- css = ""
1570
-
1571
- for cssfile in modules .scripts .list_files_with_name ("style.css" ):
1572
- if not os .path .isfile (cssfile ):
1573
- continue
1574
-
1575
- with open (cssfile , "r" , encoding = "utf8" ) as file :
1576
- css += file .read () + "\n "
1577
-
1578
- if os .path .exists (os .path .join (data_path , "user.css" )):
1579
- with open (os .path .join (data_path , "user.css" ), "r" , encoding = "utf8" ) as file :
1580
- css += file .read () + "\n "
1581
-
1582
- if not cmd_opts .no_progressbar_hiding :
1583
- css += css_hide_progressbar
1584
-
1585
1558
interfaces += script_callbacks .ui_tabs_callback ()
1586
1559
interfaces += [(settings_interface , "Settings" , "settings" )]
1587
1560
@@ -1592,7 +1565,7 @@ def request_restart():
1592
1565
for _interface , label , _ifid in interfaces :
1593
1566
shared .tab_names .append (label )
1594
1567
1595
- with gr .Blocks (css = css , analytics_enabled = False , title = "Stable Diffusion" ) as demo :
1568
+ with gr .Blocks (analytics_enabled = False , title = "Stable Diffusion" ) as demo :
1596
1569
with gr .Row (elem_id = "quicksettings" , variant = "compact" ):
1597
1570
for i , k , item in sorted (quicksettings_list , key = lambda x : quicksettings_names .get (x [1 ], x [0 ])):
1598
1571
component = create_setting_component (k , is_quicksettings = True )
@@ -1777,25 +1750,60 @@ def check_dropdown(val):
1777
1750
return demo
1778
1751
1779
1752
1780
- def reload_javascript ():
1753
+ def webpath (fn ):
1754
+ if fn .startswith (script_path ):
1755
+ web_path = os .path .relpath (fn , script_path ).replace ('\\ ' , '/' )
1756
+ else :
1757
+ web_path = os .path .abspath (fn )
1758
+
1759
+ return f'file={ web_path } ?{ os .path .getmtime (fn )} '
1760
+
1761
+
1762
+ def javascript_html ():
1781
1763
script_js = os .path .join (script_path , "script.js" )
1782
- head = f'<script type="text/javascript" src="file= { os . path . abspath ( script_js ) } ? { os . path . getmtime (script_js )} "></script>\n '
1764
+ head = f'<script type="text/javascript" src="{ webpath (script_js )} "></script>\n '
1783
1765
1784
1766
inline = f"{ localization .localization_js (shared .opts .localization )} ;"
1785
1767
if cmd_opts .theme is not None :
1786
1768
inline += f"set_theme('{ cmd_opts .theme } ');"
1787
1769
1788
1770
for script in modules .scripts .list_scripts ("javascript" , ".js" ):
1789
- head += f'<script type="text/javascript" src="file= { script . path } ? { os . path . getmtime (script .path )} "></script>\n '
1771
+ head += f'<script type="text/javascript" src="{ webpath (script .path )} "></script>\n '
1790
1772
1791
1773
for script in modules .scripts .list_scripts ("javascript" , ".mjs" ):
1792
- head += f'<script type="module" src="file= { script . path } ? { os . path . getmtime (script .path )} "></script>\n '
1774
+ head += f'<script type="module" src="{ webpath (script .path )} "></script>\n '
1793
1775
1794
1776
head += f'<script type="text/javascript">{ inline } </script>\n '
1795
1777
1778
+ return head
1779
+
1780
+
1781
+ def css_html ():
1782
+ head = ""
1783
+
1784
+ def stylesheet (fn ):
1785
+ return f'<link rel="stylesheet" property="stylesheet" href="{ webpath (fn )} ">'
1786
+
1787
+ for cssfile in modules .scripts .list_files_with_name ("style.css" ):
1788
+ if not os .path .isfile (cssfile ):
1789
+ continue
1790
+
1791
+ head += stylesheet (cssfile )
1792
+
1793
+ if os .path .exists (os .path .join (data_path , "user.css" )):
1794
+ head += stylesheet (os .path .join (data_path , "user.css" ))
1795
+
1796
+ return head
1797
+
1798
+
1799
+ def reload_javascript ():
1800
+ js = javascript_html ()
1801
+ css = css_html ()
1802
+
1796
1803
def template_response (* args , ** kwargs ):
1797
1804
res = shared .GradioTemplateResponseOriginal (* args , ** kwargs )
1798
- res .body = res .body .replace (b'</head>' , f'{ head } </head>' .encode ("utf8" ))
1805
+ res .body = res .body .replace (b'</head>' , f'{ js } </head>' .encode ("utf8" ))
1806
+ res .body = res .body .replace (b'</body>' , f'{ css } </body>' .encode ("utf8" ))
1799
1807
res .init_headers ()
1800
1808
return res
1801
1809
0 commit comments