Upload folder using huggingface_hub
Browse files
test.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
import gradio as gr
|
2 |
-
import os
|
3 |
|
4 |
def create_policy_image_modal_app():
|
5 |
modal_css = """
|
@@ -38,6 +37,7 @@ def create_policy_image_modal_app():
|
|
38 |
border: none;
|
39 |
border-radius: 4px;
|
40 |
padding: 5px 15px;
|
|
|
41 |
}
|
42 |
|
43 |
.img-container {
|
@@ -53,6 +53,17 @@ def create_policy_image_modal_app():
|
|
53 |
border: 1px solid #ddd;
|
54 |
border-radius: 6px;
|
55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
"""
|
57 |
|
58 |
modal_html = """
|
@@ -65,6 +76,8 @@ def create_policy_image_modal_app():
|
|
65 |
</div>
|
66 |
</div>
|
67 |
|
|
|
|
|
68 |
<script>
|
69 |
document.addEventListener('click', function(e) {
|
70 |
const modal = document.getElementById('imgModal');
|
@@ -73,29 +86,13 @@ def create_policy_image_modal_app():
|
|
73 |
document.body.style.overflow = 'auto';
|
74 |
}
|
75 |
});
|
76 |
-
|
77 |
-
function showPolicyModal() {
|
78 |
-
const modal = document.getElementById('imgModal');
|
79 |
-
if (modal) {
|
80 |
-
modal.style.display = 'block';
|
81 |
-
document.body.style.overflow = 'hidden';
|
82 |
-
}
|
83 |
-
}
|
84 |
</script>
|
85 |
"""
|
86 |
|
87 |
with gr.Blocks(css=modal_css) as app:
|
88 |
-
gr.Markdown("
|
89 |
gr.HTML(modal_html)
|
90 |
|
91 |
-
open_button = gr.Button("📄 View Policy (Image Popup)")
|
92 |
-
open_button.click(
|
93 |
-
fn=None,
|
94 |
-
inputs=None,
|
95 |
-
outputs=None,
|
96 |
-
_js="showPolicyModal"
|
97 |
-
)
|
98 |
-
|
99 |
return app
|
100 |
|
101 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
def create_policy_image_modal_app():
|
4 |
modal_css = """
|
|
|
37 |
border: none;
|
38 |
border-radius: 4px;
|
39 |
padding: 5px 15px;
|
40 |
+
z-index: 1001;
|
41 |
}
|
42 |
|
43 |
.img-container {
|
|
|
53 |
border: 1px solid #ddd;
|
54 |
border-radius: 6px;
|
55 |
}
|
56 |
+
|
57 |
+
.open-policy-btn {
|
58 |
+
background-color: #FCA539;
|
59 |
+
color: #000;
|
60 |
+
font-weight: bold;
|
61 |
+
padding: 10px 20px;
|
62 |
+
border: none;
|
63 |
+
border-radius: 6px;
|
64 |
+
font-size: 16px;
|
65 |
+
cursor: pointer;
|
66 |
+
}
|
67 |
"""
|
68 |
|
69 |
modal_html = """
|
|
|
76 |
</div>
|
77 |
</div>
|
78 |
|
79 |
+
<button class="open-policy-btn" onclick="document.getElementById('imgModal').style.display='block'; document.body.style.overflow='hidden';">📄 View Hate Speech Policy</button>
|
80 |
+
|
81 |
<script>
|
82 |
document.addEventListener('click', function(e) {
|
83 |
const modal = document.getElementById('imgModal');
|
|
|
86 |
document.body.style.overflow = 'auto';
|
87 |
}
|
88 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
</script>
|
90 |
"""
|
91 |
|
92 |
with gr.Blocks(css=modal_css) as app:
|
93 |
+
gr.Markdown("# Policy Viewer Demo")
|
94 |
gr.HTML(modal_html)
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
return app
|
97 |
|
98 |
if __name__ == "__main__":
|