import gradio as gr # Mock function for testing layout def run_test_power(model_name, real_text, generated_text, N=10): return "Prediction: Human (Mocked)" css = """ #header { text-align: center; font-size: 1.5em; margin-bottom: 20px; } #output-text { font-weight: bold; font-size: 1.2em; } """ # Gradio App with gr.Blocks(css=css) as app: with gr.Row(): gr.HTML('') with gr.Row(): gr.Markdown( """ [Paper](https://openreview.net/forum?id=z9j7wctoGV) | [Code](https://github.com/xLearn-AU/R-Detect) | [Contact](mailto:1730421718@qq.com) """ ) with gr.Row(): input_text = gr.Textbox( label="Input Text", placeholder="Enter the text to check", lines=8, ) with gr.Row(): model_name = gr.Dropdown( [ "gpt2-medium", "gpt2-large", "t5-large", "t5-small", "roberta-base", "roberta-base-openai-detector", "falcon-rw-1b", ], label="Select Model", value="gpt2-medium", ) with gr.Row(): submit_button = gr.Button("Run Detection", variant="primary") clear_button = gr.Button("Clear", variant="secondary") with gr.Row(): output = gr.Textbox( label="Prediction", placeholder="Prediction: Human or AI", elem_id="output-text", ) submit_button.click( run_test_power, inputs=[model_name, "Example real text", input_text], outputs=output ) clear_button.click(lambda: ("", ""), inputs=[], outputs=[input_text, output]) app.launch()