Spaces:
Running
Running
Update demo.py
Browse files
demo.py
CHANGED
@@ -43,6 +43,15 @@ css = """
|
|
43 |
margin: 0 5px;
|
44 |
color: black;
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
"""
|
47 |
|
48 |
# Gradio App
|
@@ -50,17 +59,15 @@ with gr.Blocks(css=css) as app:
|
|
50 |
with gr.Row():
|
51 |
gr.HTML('<div id="header">R-detect On HuggingFace</div>')
|
52 |
with gr.Row():
|
53 |
-
gr.HTML(
|
54 |
-
|
55 |
-
<
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
"""
|
63 |
-
)
|
64 |
with gr.Row():
|
65 |
input_text = gr.Textbox(
|
66 |
label="Input Text",
|
@@ -69,7 +76,7 @@ with gr.Blocks(css=css) as app:
|
|
69 |
)
|
70 |
output = gr.Textbox(
|
71 |
label="Inference Result",
|
72 |
-
placeholder="
|
73 |
elem_id="output-text",
|
74 |
)
|
75 |
with gr.Row():
|
@@ -84,31 +91,27 @@ with gr.Blocks(css=css) as app:
|
|
84 |
)
|
85 |
submit_button = gr.Button("Run Detection", variant="primary")
|
86 |
clear_button = gr.Button("Clear", variant="secondary")
|
87 |
-
|
88 |
|
|
|
89 |
submit_button.click(run_test_power, inputs=[model_name, input_text, input_text], outputs=output)
|
90 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
91 |
-
# model_name.change(change_mode, inputs=[model_name], outputs=[model_name])
|
92 |
|
93 |
with gr.Accordion("Disclaimer", open=False):
|
94 |
-
gr.Markdown(
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
)
|
100 |
with gr.Accordion("Citations", open=False):
|
101 |
-
gr.Markdown(
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
"""
|
112 |
-
)
|
113 |
|
114 |
app.launch()
|
|
|
43 |
margin: 0 5px;
|
44 |
color: black;
|
45 |
}
|
46 |
+
.row {
|
47 |
+
display: flex;
|
48 |
+
justify-content: center;
|
49 |
+
width: 100%;
|
50 |
+
}
|
51 |
+
.gradio-row input, .gradio-row select, .gradio-row button {
|
52 |
+
width: 250px; /* Set all elements to the same width */
|
53 |
+
margin: 5px;
|
54 |
+
}
|
55 |
"""
|
56 |
|
57 |
# Gradio App
|
|
|
59 |
with gr.Row():
|
60 |
gr.HTML('<div id="header">R-detect On HuggingFace</div>')
|
61 |
with gr.Row():
|
62 |
+
gr.HTML("""
|
63 |
+
<div class="links">
|
64 |
+
<a href="https://openreview.net/forum?id=z9j7wctoGV" target="_blank">Paper</a>
|
65 |
+
<span class="separator">|</span>
|
66 |
+
<a href="https://github.com/xLearn-AU/R-Detect" target="_blank">Code</a>
|
67 |
+
<span class="separator">|</span>
|
68 |
+
<a href="mailto:[email protected]" target="_blank">Contact</a>
|
69 |
+
</div>
|
70 |
+
""")
|
|
|
|
|
71 |
with gr.Row():
|
72 |
input_text = gr.Textbox(
|
73 |
label="Input Text",
|
|
|
76 |
)
|
77 |
output = gr.Textbox(
|
78 |
label="Inference Result",
|
79 |
+
placeholder="Made by Human or AI",
|
80 |
elem_id="output-text",
|
81 |
)
|
82 |
with gr.Row():
|
|
|
91 |
)
|
92 |
submit_button = gr.Button("Run Detection", variant="primary")
|
93 |
clear_button = gr.Button("Clear", variant="secondary")
|
|
|
94 |
|
95 |
+
# Hooking up the change_mode function to select different models
|
96 |
submit_button.click(run_test_power, inputs=[model_name, input_text, input_text], outputs=output)
|
97 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
|
|
98 |
|
99 |
with gr.Accordion("Disclaimer", open=False):
|
100 |
+
gr.Markdown("""
|
101 |
+
- **Disclaimer**: This tool is for demonstration purposes only. It is not a foolproof AI detector.
|
102 |
+
- **Accuracy**: Results may vary based on input length and quality.
|
103 |
+
""")
|
104 |
+
|
|
|
105 |
with gr.Accordion("Citations", open=False):
|
106 |
+
gr.Markdown("""
|
107 |
+
```
|
108 |
+
@inproceedings{zhangs2024MMDMP,
|
109 |
+
title={Detecting Machine-Generated Texts by Multi-Population Aware Optimization for Maximum Mean Discrepancy},
|
110 |
+
author={Zhang, Shuhai and Song, Yiliao and Yang, Jiahao and Li, Yuanqing and Han, Bo and Tan, Mingkui},
|
111 |
+
booktitle = {International Conference on Learning Representations (ICLR)},
|
112 |
+
year={2024}
|
113 |
+
}
|
114 |
+
```
|
115 |
+
""")
|
|
|
|
|
116 |
|
117 |
app.launch()
|