Spaces:
Sleeping
Sleeping
File size: 1,998 Bytes
95b8024 49e474f be2da4e 49e474f be2da4e f464030 97cd450 f464030 97cd450 f464030 be2da4e ccaa0ab 061d6b5 97cd450 ccaa0ab be2da4e 97cd450 be2da4e 49e474f 97cd450 be2da4e 49e474f be2da4e 97cd450 be2da4e 95b8024 061d6b5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
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() |