Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|