Naveen0312 commited on
Commit
dfb0362
·
verified ·
1 Parent(s): 6eda4a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -1,7 +1,23 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + " 👋"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Load a pre-trained AI text detector model
5
+ detector = pipeline("text-classification", model="roberta-base-openai-detector")
6
+
7
+ def detect_text(text):
8
+ result = detector(text)[0]
9
+ label = result['label']
10
+ score = round(result['score'] * 100, 2)
11
+ return f"Prediction: {label} ({score}%)"
12
+
13
+ # Gradio UI
14
+ interface = gr.Interface(
15
+ fn=detect_text,
16
+ inputs=gr.Textbox(lines=7, label="Enter your text"),
17
+ outputs=gr.Textbox(label="Result"),
18
+ title="Text AI Detector",
19
+ description="This model predicts if the text is AI-generated or human-written."
20
+ )
21
+
22
+ interface.launch()
23