Spaces:
Running
Running
Update demo.py
Browse files
demo.py
CHANGED
@@ -1,89 +1,72 @@
|
|
1 |
import gradio as gr
|
2 |
-
import spaces
|
3 |
-
|
4 |
-
|
5 |
-
# TOKENIZER =
|
6 |
-
# MINIMUM_TOKENS = 64
|
7 |
-
|
8 |
-
# def count_tokens(text):
|
9 |
-
# return len(TOKENIZER(text).input_ids)
|
10 |
-
|
11 |
|
12 |
# Mock function for testing layout
|
13 |
def run_test_power(model_name, real_text, generated_text, N=10):
|
14 |
return f"Prediction: Human (Mocked for {model_name})"
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
# return mode
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
justify-content: flex-end;
|
38 |
-
gap: 10px;
|
39 |
-
margin-right: 10px;
|
40 |
align-items: center;
|
41 |
}
|
|
|
42 |
.separator {
|
43 |
margin: 0 5px;
|
44 |
color: black;
|
45 |
}
|
46 |
|
47 |
-
/* Adjusting layout for Input Text
|
48 |
-
.input-row {
|
49 |
-
display: flex;
|
50 |
-
width: 100%;
|
51 |
-
}
|
52 |
-
|
53 |
.input-text {
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
.output-text {
|
59 |
-
flex: 1; /* 1 part of the row */
|
60 |
-
text-align: center;
|
61 |
}
|
62 |
|
63 |
/* Set button widths to match the Select Model width */
|
64 |
.button {
|
65 |
-
width: 250px;
|
66 |
-
height: 100px;
|
67 |
}
|
68 |
|
69 |
/* Set height for the Select Model dropdown */
|
70 |
.select {
|
71 |
-
height: 100px;
|
72 |
}
|
73 |
|
74 |
/* Accordion Styling */
|
75 |
.accordion {
|
76 |
-
width: 100%;
|
77 |
-
max-height: 200px;
|
78 |
-
overflow-y: auto;
|
79 |
-
margin-bottom: 10px;
|
80 |
-
box-sizing: border-box;
|
81 |
-
}
|
82 |
-
|
83 |
-
/* Accordion content max-height */
|
84 |
-
.accordion-content {
|
85 |
-
max-height: 200px; /* Limit the height of the content */
|
86 |
-
overflow-y: auto; /* Add a scrollbar if content overflows */
|
87 |
}
|
88 |
"""
|
89 |
|
@@ -108,11 +91,11 @@ with gr.Blocks(css=css) as app:
|
|
108 |
lines=8,
|
109 |
elem_classes=["input-text"], # Applying the CSS class
|
110 |
)
|
|
|
111 |
output = gr.Textbox(
|
112 |
label="Inference Result",
|
113 |
placeholder="Made by Human or AI",
|
114 |
elem_id="output-text",
|
115 |
-
elem_classes=["output-text"],
|
116 |
)
|
117 |
with gr.Row():
|
118 |
model_name = gr.Dropdown(
|
@@ -131,13 +114,13 @@ with gr.Blocks(css=css) as app:
|
|
131 |
submit_button.click(run_test_power, inputs=[model_name, input_text, input_text], outputs=output)
|
132 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
133 |
|
134 |
-
with gr.Accordion("Disclaimer", open=False
|
135 |
gr.Markdown("""
|
136 |
- **Disclaimer**: This tool is for demonstration purposes only. It is not a foolproof AI detector.
|
137 |
- **Accuracy**: Results may vary based on input length and quality.
|
138 |
""")
|
139 |
|
140 |
-
with gr.Accordion("Citations", open=False
|
141 |
gr.Markdown("""
|
142 |
```
|
143 |
@inproceedings{zhangs2024MMDMP,
|
@@ -149,4 +132,4 @@ with gr.Blocks(css=css) as app:
|
|
149 |
```
|
150 |
""")
|
151 |
|
152 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
# Mock function for testing layout
|
4 |
def run_test_power(model_name, real_text, generated_text, N=10):
|
5 |
return f"Prediction: Human (Mocked for {model_name})"
|
6 |
|
7 |
+
# CSS to adjust layout for the text boxes and dropdown
|
8 |
+
css = """
|
9 |
+
#header {
|
10 |
+
text-align: center;
|
11 |
+
font-size: 3em;
|
12 |
+
margin-bottom: 20px;
|
13 |
+
}
|
14 |
|
15 |
+
#output-text {
|
16 |
+
font-weight: bold;
|
17 |
+
font-size: 1.2em;
|
18 |
+
text-align: center; /* Center the text inside the box */
|
19 |
+
}
|
20 |
|
21 |
+
/* Flex container for centering output-text */
|
22 |
+
.center-container {
|
23 |
+
display: flex;
|
24 |
+
flex-direction: column;
|
25 |
+
justify-content: center;
|
26 |
+
align-items: center;
|
27 |
+
height: 400px; /* Set a fixed height for the container */
|
28 |
+
margin-top: 20px; /* Add some space above the container */
|
29 |
+
margin-bottom: 20px; /* Add some space below the container */
|
30 |
+
}
|
|
|
|
|
|
|
31 |
|
32 |
+
.links {
|
33 |
+
display: flex;
|
34 |
+
justify-content: flex-end;
|
35 |
+
gap: 10px;
|
36 |
+
margin-right: 10px;
|
|
|
|
|
|
|
37 |
align-items: center;
|
38 |
}
|
39 |
+
|
40 |
.separator {
|
41 |
margin: 0 5px;
|
42 |
color: black;
|
43 |
}
|
44 |
|
45 |
+
/* Adjusting layout for Input Text */
|
|
|
|
|
|
|
|
|
|
|
46 |
.input-text {
|
47 |
+
width: 100%;
|
48 |
+
height: 100px;
|
49 |
+
font-size: 1em;
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
/* Set button widths to match the Select Model width */
|
53 |
.button {
|
54 |
+
width: 250px; /* Same as the select box width */
|
55 |
+
height: 100px; /* Button height */
|
56 |
}
|
57 |
|
58 |
/* Set height for the Select Model dropdown */
|
59 |
.select {
|
60 |
+
height: 100px; /* Set height to 100px */
|
61 |
}
|
62 |
|
63 |
/* Accordion Styling */
|
64 |
.accordion {
|
65 |
+
width: 100%; /* Set the width of the accordion to match the parent */
|
66 |
+
max-height: 200px; /* Set a max-height for accordion */
|
67 |
+
overflow-y: auto; /* Allow scrolling if the content exceeds max height */
|
68 |
+
margin-bottom: 10px; /* Add space below the accordion */
|
69 |
+
box-sizing: border-box; /* Ensure padding is included in width/height */
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
}
|
71 |
"""
|
72 |
|
|
|
91 |
lines=8,
|
92 |
elem_classes=["input-text"], # Applying the CSS class
|
93 |
)
|
94 |
+
with gr.Row(elem_classes=["center-container"]): # Parent container for centering
|
95 |
output = gr.Textbox(
|
96 |
label="Inference Result",
|
97 |
placeholder="Made by Human or AI",
|
98 |
elem_id="output-text",
|
|
|
99 |
)
|
100 |
with gr.Row():
|
101 |
model_name = gr.Dropdown(
|
|
|
114 |
submit_button.click(run_test_power, inputs=[model_name, input_text, input_text], outputs=output)
|
115 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
116 |
|
117 |
+
with gr.Accordion("Disclaimer", open=False):
|
118 |
gr.Markdown("""
|
119 |
- **Disclaimer**: This tool is for demonstration purposes only. It is not a foolproof AI detector.
|
120 |
- **Accuracy**: Results may vary based on input length and quality.
|
121 |
""")
|
122 |
|
123 |
+
with gr.Accordion("Citations", open=False):
|
124 |
gr.Markdown("""
|
125 |
```
|
126 |
@inproceedings{zhangs2024MMDMP,
|
|
|
132 |
```
|
133 |
""")
|
134 |
|
135 |
+
app.launch()
|