Spaces:
Running
Running
Update demo.py
Browse files
demo.py
CHANGED
@@ -11,13 +11,21 @@ import spaces
|
|
11 |
|
12 |
# Mock function for testing layout
|
13 |
def run_test_power(model_name, real_text, generated_text, N=10):
|
14 |
-
return "Prediction: Human (Mocked)"
|
15 |
|
16 |
|
17 |
|
18 |
# Change mode name
|
19 |
-
#
|
20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
|
@@ -59,36 +67,26 @@ with gr.Blocks(css=css) as app:
|
|
59 |
placeholder="Enter Text Here",
|
60 |
lines=8,
|
61 |
)
|
|
|
|
|
|
|
|
|
|
|
62 |
with gr.Row():
|
63 |
model_name = gr.Dropdown(
|
64 |
[
|
65 |
-
"
|
66 |
-
"
|
67 |
-
"
|
68 |
-
"t5-small",
|
69 |
-
"roberta-base",
|
70 |
-
"roberta-base-openai-detector",
|
71 |
-
"chatgpt-detector-roberta",
|
72 |
-
"gpt3-small-finetune-cnndaily-news",
|
73 |
-
"gpt-neo-125m",
|
74 |
-
"falcon-rw-1b",
|
75 |
],
|
76 |
label="Select Model",
|
77 |
value="gpt2-medium",
|
78 |
)
|
79 |
submit_button = gr.Button("Run Detection", variant="primary")
|
80 |
clear_button = gr.Button("Clear", variant="secondary")
|
81 |
-
|
82 |
-
output = gr.Textbox(
|
83 |
-
label="Inference Result",
|
84 |
-
placeholder="Maked by Human or AI",
|
85 |
-
elem_id="output-text",
|
86 |
-
)
|
87 |
-
submit_button.click(
|
88 |
-
run_test_power, inputs=[model_name, input_text, input_text], outputs=output
|
89 |
-
)
|
90 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
91 |
-
|
92 |
|
93 |
with gr.Accordion("Disclaimer", open=False):
|
94 |
gr.Markdown(
|
|
|
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 |
# Change mode name
|
19 |
+
#def change_mode(mode):
|
20 |
+
# if mode == "Faster Model":
|
21 |
+
# .change_mode("t5-small")
|
22 |
+
# elif mode == "Medium Model":
|
23 |
+
# .change_mode("roberta-base-openai-detector")
|
24 |
+
# elif mode == "Powerful Model":
|
25 |
+
# .change_mode("falcon-rw-1b")
|
26 |
+
# else:
|
27 |
+
# gr.Error(f"Invaild mode selected.")
|
28 |
+
# return mode
|
29 |
|
30 |
|
31 |
|
|
|
67 |
placeholder="Enter Text Here",
|
68 |
lines=8,
|
69 |
)
|
70 |
+
output = gr.Textbox(
|
71 |
+
label="Inference Result",
|
72 |
+
placeholder="Maked by Human or AI",
|
73 |
+
elem_id="output-text",
|
74 |
+
)
|
75 |
with gr.Row():
|
76 |
model_name = gr.Dropdown(
|
77 |
[
|
78 |
+
"Faster Model",
|
79 |
+
"Medium Model",
|
80 |
+
"Powerful Model",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
],
|
82 |
label="Select Model",
|
83 |
value="gpt2-medium",
|
84 |
)
|
85 |
submit_button = gr.Button("Run Detection", variant="primary")
|
86 |
clear_button = gr.Button("Clear", variant="secondary")
|
87 |
+
submit_button.click(run_test_power, inputs=[model_name, input_text, input_text], outputs=output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output])
|
89 |
+
# model_name.change(change_mode, inputs=[model_name], outputs=[model_name])
|
90 |
|
91 |
with gr.Accordion("Disclaimer", open=False):
|
92 |
gr.Markdown(
|