Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from ai_text_detector_valid_final import detect_text | |
| def analyze_text(user_text): | |
| return detect_text(user_text) | |
| with gr.Blocks(theme=gr.themes.Soft()) as demo: | |
| gr.Markdown( | |
| """ | |
| # π€ AI vs Human Text Detector | |
| Paste any text below. Our system will analyze it using **three advanced models** to detect if the text is AI-generated or human-written. | |
| ### π Formatting Preservation | |
| - Your **line breaks, spacing, and Markdown syntax** will be preserved exactly as you paste them. | |
| - You can view it as **raw text** or **rendered Markdown**. | |
| - Perfect for analyzing **code snippets, poetry, or Markdown documents**. | |
| Click **"π Run Detection"** to start. | |
| """ | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=2): | |
| user_input = gr.Textbox( | |
| label="βοΈ Enter Text", | |
| placeholder="Paste text here...", | |
| lines=12, | |
| type="text" | |
| ) | |
| analyze_btn = gr.Button("π Run Detection", variant="primary") | |
| with gr.Column(scale=1): | |
| final_output = gr.JSON(label="π Final Results") | |
| with gr.Row(): | |
| with gr.Accordion("π¬ Detailed Model Results", open=False): | |
| model_output = gr.JSON(label="All Model Scores") | |
| # β Two-tab preview: raw + markdown | |
| with gr.Tab("π Raw Text (Exact Preservation)"): | |
| raw_preview = gr.Textbox( | |
| label="π Raw Input", | |
| interactive=False, | |
| lines=20, | |
| show_copy_button=True | |
| ) | |
| with gr.Tab("β¨ Rendered Markdown"): | |
| md_preview = gr.Markdown() | |
| def run_analysis(user_text): | |
| results = analyze_text(user_text) | |
| return results, results, user_text, user_text | |
| analyze_btn.click( | |
| fn=run_analysis, | |
| inputs=user_input, | |
| outputs=[final_output, model_output, raw_preview, md_preview] | |
| ) | |
| demo.launch() |