Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,49 +9,53 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 9 |
"""
|
| 10 |
# π€ AI vs Human Text Detector
|
| 11 |
Paste any text below. Our system will analyze it using **three advanced models** to detect if the text is AI-generated or human-written.
|
|
|
|
| 12 |
### π Formatting Preservation
|
| 13 |
- Your **line breaks, spacing, and Markdown syntax** will be preserved exactly as you paste them.
|
| 14 |
-
-
|
| 15 |
-
- Perfect for analyzing **code snippets, poetry, or Markdown documents
|
|
|
|
| 16 |
Click **"π Run Detection"** to start.
|
| 17 |
"""
|
| 18 |
)
|
| 19 |
|
| 20 |
with gr.Row():
|
| 21 |
-
with gr.Column(scale=1):
|
| 22 |
-
# β
Read-only textbox to display exactly what user pasted
|
| 23 |
-
formatted_input_display = gr.Textbox(
|
| 24 |
-
label="π Your Input (Preserved Formatting)",
|
| 25 |
-
interactive=False,
|
| 26 |
-
lines=20,
|
| 27 |
-
show_copy_button=True
|
| 28 |
-
)
|
| 29 |
-
|
| 30 |
with gr.Column(scale=2):
|
| 31 |
-
# β
Input also preserves formatting (raw text, multi-line)
|
| 32 |
user_input = gr.Textbox(
|
| 33 |
label="βοΈ Enter Text",
|
| 34 |
placeholder="Paste text here...",
|
| 35 |
lines=12,
|
| 36 |
-
type="text"
|
| 37 |
)
|
| 38 |
analyze_btn = gr.Button("π Run Detection", variant="primary")
|
| 39 |
|
| 40 |
with gr.Column(scale=1):
|
| 41 |
final_output = gr.JSON(label="π Final Results")
|
| 42 |
|
| 43 |
-
with gr.
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
def run_analysis(user_text):
|
| 47 |
results = analyze_text(user_text)
|
| 48 |
-
|
| 49 |
-
return results, results, user_text
|
| 50 |
|
| 51 |
analyze_btn.click(
|
| 52 |
fn=run_analysis,
|
| 53 |
inputs=user_input,
|
| 54 |
-
outputs=[final_output, model_output,
|
| 55 |
)
|
| 56 |
|
| 57 |
demo.launch()
|
|
|
|
| 9 |
"""
|
| 10 |
# π€ AI vs Human Text Detector
|
| 11 |
Paste any text below. Our system will analyze it using **three advanced models** to detect if the text is AI-generated or human-written.
|
| 12 |
+
|
| 13 |
### π Formatting Preservation
|
| 14 |
- Your **line breaks, spacing, and Markdown syntax** will be preserved exactly as you paste them.
|
| 15 |
+
- You can view it as **raw text** or **rendered Markdown**.
|
| 16 |
+
- Perfect for analyzing **code snippets, poetry, or Markdown documents**.
|
| 17 |
+
|
| 18 |
Click **"π Run Detection"** to start.
|
| 19 |
"""
|
| 20 |
)
|
| 21 |
|
| 22 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
with gr.Column(scale=2):
|
|
|
|
| 24 |
user_input = gr.Textbox(
|
| 25 |
label="βοΈ Enter Text",
|
| 26 |
placeholder="Paste text here...",
|
| 27 |
lines=12,
|
| 28 |
+
type="text"
|
| 29 |
)
|
| 30 |
analyze_btn = gr.Button("π Run Detection", variant="primary")
|
| 31 |
|
| 32 |
with gr.Column(scale=1):
|
| 33 |
final_output = gr.JSON(label="π Final Results")
|
| 34 |
|
| 35 |
+
with gr.Row():
|
| 36 |
+
with gr.Accordion("π¬ Detailed Model Results", open=False):
|
| 37 |
+
model_output = gr.JSON(label="All Model Scores")
|
| 38 |
+
|
| 39 |
+
# β
Two-tab preview: raw + markdown
|
| 40 |
+
with gr.Tab("π Raw Text (Exact Preservation)"):
|
| 41 |
+
raw_preview = gr.Textbox(
|
| 42 |
+
label="π Raw Input",
|
| 43 |
+
interactive=False,
|
| 44 |
+
lines=20,
|
| 45 |
+
show_copy_button=True
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
with gr.Tab("β¨ Rendered Markdown"):
|
| 49 |
+
md_preview = gr.Markdown()
|
| 50 |
|
| 51 |
def run_analysis(user_text):
|
| 52 |
results = analyze_text(user_text)
|
| 53 |
+
return results, results, user_text, user_text
|
|
|
|
| 54 |
|
| 55 |
analyze_btn.click(
|
| 56 |
fn=run_analysis,
|
| 57 |
inputs=user_input,
|
| 58 |
+
outputs=[final_output, model_output, raw_preview, md_preview]
|
| 59 |
)
|
| 60 |
|
| 61 |
demo.launch()
|