Spaces:
Running on Zero
Running on Zero
UI: move slider JS to gr.Blocks(js=...) — gr.HTML sanitizes <script> tags
Browse files
app.py
CHANGED
|
@@ -872,71 +872,59 @@ CSS = """
|
|
| 872 |
"""
|
| 873 |
|
| 874 |
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
(
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
|
| 884 |
-
|
| 885 |
-
|
| 886 |
-
|
| 887 |
-
|
| 888 |
-
|
| 889 |
-
|
| 890 |
-
|
| 891 |
-
|
| 892 |
-
|
| 893 |
-
|
| 894 |
-
|
| 895 |
-
|
| 896 |
-
|
| 897 |
-
|
| 898 |
-
|
| 899 |
-
|
| 900 |
-
|
| 901 |
-
|
| 902 |
-
|
| 903 |
-
|
| 904 |
-
|
| 905 |
-
|
| 906 |
-
|
| 907 |
-
|
| 908 |
-
|
| 909 |
-
|
| 910 |
-
|
| 911 |
-
|
| 912 |
-
|
| 913 |
-
|
| 914 |
-
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
|
| 928 |
-
/* try immediately, then retry with observer until Gradio renders */
|
| 929 |
-
if (!styleSlider()) {
|
| 930 |
-
var obs = new MutationObserver(function() {
|
| 931 |
-
if (styleSlider()) obs.disconnect();
|
| 932 |
-
});
|
| 933 |
-
obs.observe(document.body, {childList: true, subtree: true});
|
| 934 |
-
setTimeout(function() { obs.disconnect(); }, 15000);
|
| 935 |
-
}
|
| 936 |
-
})();
|
| 937 |
-
</script>""",
|
| 938 |
-
visible=False,
|
| 939 |
-
)
|
| 940 |
gr.Markdown(model_title())
|
| 941 |
gr.Markdown("Run Wan 2.2 in just 4-8 steps, fp8 quantization & AoT compilation - compatible with 🧨 diffusers and ZeroGPU")
|
| 942 |
|
|
|
|
| 872 |
"""
|
| 873 |
|
| 874 |
|
| 875 |
+
THEME_JS = r"""
|
| 876 |
+
(function() {
|
| 877 |
+
function styleSlider() {
|
| 878 |
+
var inp = document.querySelector('#duration-slider input[data-testid="range-input"]')
|
| 879 |
+
|| document.querySelector('#duration-slider input[type="range"]');
|
| 880 |
+
if (!inp) return false;
|
| 881 |
+
var id = 'slider-theme-styles';
|
| 882 |
+
if (!document.getElementById(id)) {
|
| 883 |
+
var s = document.createElement('style');
|
| 884 |
+
s.id = id;
|
| 885 |
+
s.textContent = [
|
| 886 |
+
'#duration-slider input[type="range"]::-webkit-slider-thumb {',
|
| 887 |
+
' -webkit-appearance: none !important;',
|
| 888 |
+
' appearance: none !important;',
|
| 889 |
+
' width: 18px !important; height: 18px !important;',
|
| 890 |
+
' border-radius: 50% !important;',
|
| 891 |
+
' background: linear-gradient(135deg, #00e5c8, #6c5ce7) !important;',
|
| 892 |
+
' border: 2px solid rgba(255,255,255,0.3) !important;',
|
| 893 |
+
' box-shadow: 0 0 8px rgba(0,229,200,0.5) !important;',
|
| 894 |
+
' cursor: pointer !important; margin-top: -6px !important;',
|
| 895 |
+
'}',
|
| 896 |
+
'#duration-slider input[type="range"]::-webkit-slider-runnable-track {',
|
| 897 |
+
' background: linear-gradient(90deg, #00d4aa, #6c5ce7) !important;',
|
| 898 |
+
' height: 6px !important; border-radius: 3px !important;',
|
| 899 |
+
'}',
|
| 900 |
+
'#duration-slider input[type="range"]::-moz-range-thumb {',
|
| 901 |
+
' width: 18px !important; height: 18px !important;',
|
| 902 |
+
' border-radius: 50% !important;',
|
| 903 |
+
' background: linear-gradient(135deg, #00e5c8, #6c5ce7) !important;',
|
| 904 |
+
' border: 2px solid rgba(255,255,255,0.3) !important;',
|
| 905 |
+
' box-shadow: 0 0 8px rgba(0,229,200,0.5) !important;',
|
| 906 |
+
' cursor: pointer !important;',
|
| 907 |
+
'}',
|
| 908 |
+
'#duration-slider input[type="range"]::-moz-range-track {',
|
| 909 |
+
' background: linear-gradient(90deg, #00d4aa, #6c5ce7) !important;',
|
| 910 |
+
' height: 6px !important; border-radius: 3px !important;',
|
| 911 |
+
'}',
|
| 912 |
+
].join('\n');
|
| 913 |
+
document.head.appendChild(s);
|
| 914 |
+
}
|
| 915 |
+
return true;
|
| 916 |
+
}
|
| 917 |
+
if (!styleSlider()) {
|
| 918 |
+
var obs = new MutationObserver(function() {
|
| 919 |
+
if (styleSlider()) obs.disconnect();
|
| 920 |
+
});
|
| 921 |
+
obs.observe(document.body, {childList: true, subtree: true});
|
| 922 |
+
setTimeout(function() { obs.disconnect(); }, 15000);
|
| 923 |
+
}
|
| 924 |
+
})();
|
| 925 |
+
"""
|
| 926 |
+
|
| 927 |
+
with gr.Blocks(delete_cache=(3600, 10800), js=THEME_JS) as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 928 |
gr.Markdown(model_title())
|
| 929 |
gr.Markdown("Run Wan 2.2 in just 4-8 steps, fp8 quantization & AoT compilation - compatible with 🧨 diffusers and ZeroGPU")
|
| 930 |
|