Spaces:
Sleeping
Sleeping
Upload app.py.txt
Browse files- app.py.txt +23 -0
app.py.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Load the model
|
| 5 |
+
clf = pipeline("text-classification", model="MayZhou/e5-small-lora-ai-generated-detector")
|
| 6 |
+
|
| 7 |
+
# Define detection function
|
| 8 |
+
def detect_ai(text):
|
| 9 |
+
result = clf(text)[0]
|
| 10 |
+
label = result['label']
|
| 11 |
+
score = round(result['score'] * 100, 2)
|
| 12 |
+
return f"{label} ({score}%)"
|
| 13 |
+
|
| 14 |
+
# Build the interface
|
| 15 |
+
demo = gr.Interface(
|
| 16 |
+
fn=detect_ai,
|
| 17 |
+
inputs="textbox",
|
| 18 |
+
outputs="text",
|
| 19 |
+
title="AI Text Detector"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Launch the app
|
| 23 |
+
demo.launch()
|