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

Delete app.py.txt

Browse files
Files changed (1) hide show
  1. app.py.txt +0 -40
app.py.txt DELETED
@@ -1,40 +0,0 @@
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()