yagnik12 commited on
Commit
be2da4e
·
verified ·
1 Parent(s): d55bed9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -15
app.py CHANGED
@@ -1,18 +1,41 @@
1
  import gradio as gr
2
- import ai_text_detector_valid_final as detector
3
-
4
- def run_detector(text):
5
- try:
6
- return detector.detect_text(text) # change if your function is named differently
7
- except Exception as e:
8
- return f"Error: {e}"
9
-
10
- demo = gr.Interface(
11
- fn=run_detector,
12
- inputs=gr.Textbox(lines=10, placeholder="Paste your text here..."),
13
- outputs="text",
14
- title="AI Text Detector",
15
- description="Check if text is AI-generated or human."
16
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
  demo.launch()
 
1
  import gradio as gr
2
+ from ai_text_detector_valid_final import detect_text
3
+
4
+ def analyze_text(user_text):
5
+ return detect_text(user_text)
6
+
7
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
8
+ gr.Markdown(
9
+ """
10
+ # 🔍 AI vs Human Text Detector
11
+ Paste any text below and our system will analyze it using **3 different models**
12
+ and generate a final average probability.
13
+ """
14
+ )
15
+
16
+ with gr.Row():
17
+ with gr.Column(scale=2):
18
+ user_input = gr.Textbox(
19
+ label="✍️ Enter Text",
20
+ placeholder="Paste text here...",
21
+ lines=10
22
+ )
23
+ analyze_btn = gr.Button("🚀 Run Detection", variant="primary")
24
+
25
+ with gr.Column(scale=1):
26
+ final_output = gr.JSON(label="📊 Final Results")
27
+
28
+ with gr.Accordion("🔬 Detailed Model Results", open=False):
29
+ model_output = gr.JSON(label="All Model Scores")
30
+
31
+ def run_analysis(user_text):
32
+ results = analyze_text(user_text)
33
+ return results, results # send to both JSON outputs
34
+
35
+ analyze_btn.click(
36
+ fn=run_analysis,
37
+ inputs=user_input,
38
+ outputs=[final_output, model_output]
39
+ )
40
 
41
  demo.launch()