SahilSingh0 commited on
Commit
f1fd10a
·
verified ·
1 Parent(s): e0e8533

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +40 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load zero-shot classification pipeline
5
+ classifier = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
6
+
7
+ # Labels to classify as AI-written or Human-written
8
+ labels = ["AI-generated text", "Human-written text"]
9
+
10
+ def detect_ai_content(text):
11
+ result = classifier(text, labels)
12
+ scores = dict(zip(result["labels"], result["scores"]))
13
+ ai_score = scores["AI-generated text"]
14
+ human_score = scores["Human-written text"]
15
+
16
+ if ai_score > human_score:
17
+ verdict = "⚠️ This text looks AI-Generated"
18
+ else:
19
+ verdict = "✅ This text looks Human-Written"
20
+
21
+ return {
22
+ "AI Probability": f"{ai_score:.2%}",
23
+ "Human Probability": f"{human_score:.2%}",
24
+ "Verdict": verdict
25
+ }
26
+
27
+ # Gradio Interface
28
+ demo = gr.Interface(
29
+ fn=detect_ai_content,
30
+ inputs=gr.Textbox(lines=10, placeholder="Paste text here..."),
31
+ outputs=[
32
+ gr.Label(num_top_classes=2, label="Probabilities"),
33
+ gr.Textbox(label="Verdict")
34
+ ],
35
+ title="AI Content Detector",
36
+ description="Detect whether the given text is AI-generated or Human-written."
37
+ )
38
+
39
+ if __name__ == "__main__":
40
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ transformers
3
+ torch