yagnik12 commited on
Commit
97cd450
Β·
verified Β·
1 Parent(s): 061d6b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -18
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
- - The input and output text are displayed without any modification.
15
- - Perfect for analyzing **code snippets, poetry, or Markdown documents** without losing formatting.
 
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" # important: raw text mode (not value/number)
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.Accordion("πŸ”¬ Detailed Model Results", open=False):
44
- model_output = gr.JSON(label="All Model Scores")
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  def run_analysis(user_text):
47
  results = analyze_text(user_text)
48
- # return results + original raw input
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, formatted_input_display]
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()